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

@@ -111,8 +111,19 @@ int zmq::socket_poller_t::add (socket_base_t *socket_, void* user_data_, short e
zmq_assert (rc == 0);
if (thread_safe) {
if (signaler == NULL)
signaler = new signaler_t ();
if (signaler == NULL) {
signaler = new (std::nothrow) signaler_t ();
if (!signaler) {
errno = ENOMEM;
return -1;
}
if (!signaler->valid ()) {
delete signaler;
signaler = NULL;
errno = EMFILE;
return -1;
}
}
rc = socket_->add_signaler (signaler);
zmq_assert (rc == 0);