libcql icon indicating copy to clipboard operation
libcql copied to clipboard

critical fix to make callback_storage thread-safe

Open githubmonkey opened this issue 11 years ago • 2 comments

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!

githubmonkey avatar Sep 04 '13 11:09 githubmonkey

Couple of comments about this:

  1. 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.
  2. 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.

dimitry42 avatar Sep 04 '13 13:09 dimitry42

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.

dimitry42 avatar Sep 04 '13 14:09 dimitry42