diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2010-09-09 08:25:00 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-09-09 08:25:00 +0200 |
commit | a68e6739f4248e25a0f9a64c89729f55dfacb842 (patch) | |
tree | 4686061e52137cfa373587162f59536cd3f55d32 /src/socket_base.cpp | |
parent | 47e87b7e4b8dd6a0cfbc1f30ffcb06edfa83c853 (diff) |
when no I/O threads are available error is raised instead of assertion
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r-- | src/socket_base.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp index cdad09d..288a627 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -289,8 +289,17 @@ int zmq::socket_base_t::bind (const char *addr_) return register_endpoint (addr_, this); if (protocol == "tcp" || protocol == "ipc") { + + // Choose I/O thread to run the listerner in. + io_thread_t *io_thread = choose_io_thread (options.affinity); + if (!io_thread) { + errno = EMTHREAD; + return -1; + } + + // Create and run the listener. zmq_listener_t *listener = new (std::nothrow) zmq_listener_t ( - choose_io_thread (options.affinity), this, options); + io_thread, this, options); zmq_assert (listener); int rc = listener->set_address (protocol.c_str(), address.c_str ()); if (rc != 0) { @@ -376,10 +385,16 @@ int zmq::socket_base_t::connect (const char *addr_) return 0; } + // Choose the I/O thread to run the session in. + io_thread_t *io_thread = choose_io_thread (options.affinity); + if (!io_thread) { + errno = EMTHREAD; + return -1; + } + // Create session. connect_session_t *session = new (std::nothrow) connect_session_t ( - choose_io_thread (options.affinity), this, options, - protocol.c_str (), address.c_str ()); + io_thread, this, options, protocol.c_str (), address.c_str ()); zmq_assert (session); // If 'immediate connect' feature is required, we'll create the pipes |