summaryrefslogtreecommitdiff
path: root/src/ctx.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-14 10:08:19 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-15 06:55:29 +0200
commitee66c579dedf7130aa4d59afbf373f28c98eead5 (patch)
tree2b29d8e236b02789877da88ecf05d5b463c046da /src/ctx.cpp
parent19894e0a1b6fbbcb62028fc6513ef3904a6f5c76 (diff)
Report EMFILE/ENFILE from xs_socket()
This patch propoagates the error from signaler and mailbox initialisation up the stack. To achieve this signaler and mailbox classes were re-written is C-like syntax. Finally, shutdown_stress test now ignores EMFILE/ENFILE errors. Thus, the tests should pass even on OSX which sets the max number of file descriptors pretty low by default. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/ctx.cpp')
-rw-r--r--src/ctx.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 46fa984..8bd3506 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -47,9 +47,12 @@ xs::ctx_t::ctx_t () :
max_sockets (512),
io_thread_count (1)
{
+ int rc = mailbox_init (&term_mailbox);
+ errno_assert (rc == 0);
+
// Plug in the standard plugins.
- int rc = plug (prefix_filter);
- xs_assert (rc == 0);
+ rc = plug (prefix_filter);
+ errno_assert (rc == 0);
}
bool xs::ctx_t::check_tag ()
@@ -81,6 +84,9 @@ xs::ctx_t::~ctx_t ()
if (slots)
free (slots);
+ // Deallocate the termination mailbox.
+ mailbox_close (&term_mailbox);
+
// Remove the tag, so that the object is considered dead.
tag = 0xdeadbeef;
}
@@ -112,7 +118,7 @@ int xs::ctx_t::terminate ()
// Wait till reaper thread closes all the sockets.
command_t cmd;
- int rc = term_mailbox.recv (&cmd, -1);
+ int rc = mailbox_recv (&term_mailbox, &cmd, -1);
if (rc == -1 && errno == EINTR)
return -1;
xs_assert (rc == 0);
@@ -297,7 +303,7 @@ xs_filter_t *xs::ctx_t::get_filter (int filter_id_)
void xs::ctx_t::send_command (uint32_t tid_, const command_t &command_)
{
- slots [tid_]->send (command_);
+ mailbox_send (slots [tid_], command_);
}
xs::io_thread_t *xs::ctx_t::choose_io_thread (uint64_t affinity_)