Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make nextTransactionID an atomic variable
This commit has 2 main benefits: 1) It makes it impossible to access nextTransactionID un-atomically 2) It fixes a small bug where we would have racy (albeit atomic) accesses to nextTransactionID. Consider the following interleaving: Dispactcher Call #1 and #2: Read nextTransactioID Dispactcher Call #1 and #2: Bump nextTransactionId *locally* and then write it back. The same value is written back twice. Dispactcher Call #1 and #2: Send a message with the newly minted transaction ID, x. Note, *two* messages are sent with x! So two responses will come back. First response arrives: Entry is deleted from dispatcher's waited hash map. Second response arrives: Received message with id x, but no record of it, because the entry was deleted when the first message arrived. The solution is just to use an atomic read-modify-write operation in the form of .Add(1)
- Loading branch information