Prevent multiple tcs_context_table entries with the same handle

Check if the handle produced by getNextHandle() is already in
tcs_context_table, and retry generating the handle, if so.

BUG=b:111417778
TEST=Run cert provision in the loop, check that we don't hit dbus
     timeouts for chapsd or cryptohomed, and tcsd remains responsive.

Change-Id: I891b9fe71bba655c3ce33d33c8cf070a99b3d741
Reviewed-on: https://chromium-review.googlesource.com/1153656
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
1 file changed