Problem: in case of exhausted resources on creation of a context, assertions are triggered

Solution: signal error to caller, and apply appropriate cleanup
This commit is contained in:
sigiesec
2018-01-31 17:03:29 +01:00
committed by Giesecke
parent 4e2b9e6e07
commit 206c832167
12 changed files with 146 additions and 49 deletions

View File

@@ -37,13 +37,16 @@
#include "ctx.hpp"
zmq::io_thread_t::io_thread_t (ctx_t *ctx_, uint32_t tid_) :
object_t (ctx_, tid_)
object_t (ctx_, tid_),
mailbox_handle (NULL)
{
poller = new (std::nothrow) poller_t (*ctx_);
alloc_assert (poller);
mailbox_handle = poller->add_fd (mailbox.get_fd (), this);
poller->set_pollin (mailbox_handle);
if (mailbox.get_fd () != retired_fd) {
mailbox_handle = poller->add_fd (mailbox.get_fd (), this);
poller->set_pollin (mailbox_handle);
}
}
zmq::io_thread_t::~io_thread_t ()
@@ -109,6 +112,8 @@ zmq::poller_t *zmq::io_thread_t::get_poller ()
void zmq::io_thread_t::process_stop ()
{
poller->rm_fd (mailbox_handle);
if (mailbox_handle) {
poller->rm_fd (mailbox_handle);
}
poller->stop ();
}