digitalocean / go-openvswitch

Go packages which enable interacting with Open vSwitch and related tools. Apache 2.0 Licensed.
Other
295 stars 95 forks source link

ovsdb: add ClientStats, fix callback leak #17

Closed mdlayher closed 6 years ago

mdlayher commented 6 years ago

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.

mdlayher commented 6 years ago

Need to figure out a way to release callback if Send fails too!

mdlayher commented 6 years ago

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.

mdlayher commented 6 years ago

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.

mdlayher commented 6 years ago

Merging, and we can iterate.