thesamet / rpcz

RPC implementation for Protocol Buffers over ZeroMQ
http://code.google.com/p/rpcz/
Apache License 2.0
113 stars 40 forks source link

Application hangs on application restart #2

Closed xdmiodz closed 9 years ago

xdmiodz commented 9 years ago

Hi,

The following code hangs an application that uses RPCZ:

#include <rpcz/rpcz.hpp>
#include <memory>
#include <thread>

class SomeService;

int main() {
  std::unique_ptr<rpcz::application> application;
  std::unique_ptr<rpcz::server> server;

  application = std::make_unique<rpcz::application>();
  handle_thread = std::thread(&rpcz::application::run, application.get());

  server = std::make_unique<rpcz::server>(*application);
  SomeService service;
  server->registre_service(&service);
  server->bind("ipc://tmp/myservice");

  server->reset();
  application->terminate();
  handle_thread.join();
  application.reset();
}

The application hangs on rpcz::application destructor, trying to destroy own zmq context. I investigated the issue a bit and found that the destroying of the context hangs because it still has open sockets. I suppose that the socket under question is the connectionmanager::socket, which has type of boost::thread_specific_ptrzmq::socket_t

I changed the type of the socket to boost::scoped_ptr and the issue gone. However I'm not sure that the fix is valid.

xdmiodz commented 9 years ago

actually issue has gone