Closed mdlayher closed 6 years ago
Need to figure out a way to release callback if Send fails too!
I think that with these questions, it might make sense to make a smarter, concurrency-safe, callbacks type that stores its own map and can process operations in a transaction with a single lock.
Just pushed a new commit that ensures the callback is cleaned up by the consumer. The comment explains the rationale, and I think this approach is better and safer, and can be iterated on.
Merging, and we can iterate.
Could be used as a basis for future metrics and such.
The test shows that the callback leak is now fixed. I didn't add a new method because it seemed easy enough to do it all in the rpc method. If I had made a new one, I would have had to release the callback mutex in doCallback, and then re-acquire it to delete the finished callback, which seems inherently race condition prone.