ruby-protobuf / protobuf

A pure ruby implementation of Google's Protocol Buffers
https://github.com/ruby-protobuf
MIT License
463 stars 101 forks source link

Last ZMQ API call to socket_recv_string failed with "Context was terminated" #301

Open brianstien opened 8 years ago

brianstien commented 8 years ago

When multiple threads are initializing the zmq context at the same time, this instance variable is not threadsafe. The resulting error will read Last ZMQ API call to socket_recv_string failed with "Context was terminated".

I am not sure if it is the responsibility of this gem to initialize the zmq context in a thread-safe manner or is the responsibility of an external caller. I will issue a PR if this should be fixed here.

Also, I can post a minimum viable reproduction if needed but but current reproduction in inside a web server I am testing. Happy to boil this down if someone picks this up.

liveh2o commented 8 years ago

Since the RPC server is part of this gem and that's what initializes the threads, I think we should fix it here. Are you thinking we should use a mutex?