libcql
libcql copied to clipboard
critical fix to make callback_storage thread-safe
Hi Matt,
feel free to discard the changes to demo/main.cpp as I used them mostly to demonstrate the bug.
I do recommend you pull the update to cql_callback_storage.hpp though as it fixes the race condition reported in #44.
Cheers!
Couple of comments about this:
- The callback storage is bound to io_service event loop and there should be one storage per io_service. hence it is thread local and does not need any synchronization.
- I'm not sure how it gets used concurrently but this needs to be fixed in the place where it happens not storage itself. The storage should not be used concurrently. every opened socket should have it's own storage instance allocated.
I'll try to do some investigation next week.
Nevermind, I see it now. You are right, it is easier to make storage thread safe then to move stream_id allocation inside event loop.