From ee66c579dedf7130aa4d59afbf373f28c98eead5 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sat, 14 Apr 2012 10:08:19 +0200 Subject: 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 --- src/ctx.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/ctx.cpp') 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_) -- cgit v1.2.3