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/io_thread.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/io_thread.cpp') diff --git a/src/io_thread.cpp b/src/io_thread.cpp index dba0f00..df5a623 100644 --- a/src/io_thread.cpp +++ b/src/io_thread.cpp @@ -48,15 +48,18 @@ xs::io_thread_t *xs::io_thread_t::create (xs::ctx_t *ctx_, uint32_t tid_) xs::io_thread_t::io_thread_t (xs::ctx_t *ctx_, uint32_t tid_) : object_t (ctx_, tid_) { + int rc = mailbox_init (&mailbox); + errno_assert (rc == 0); } xs::io_thread_t::~io_thread_t () { + mailbox_close (&mailbox); } void xs::io_thread_t::start () { - mailbox_handle = add_fd (mailbox.get_fd (), this); + mailbox_handle = add_fd (mailbox_fd (&mailbox), this); set_pollin (mailbox_handle); xstart (); } @@ -149,7 +152,7 @@ void xs::io_thread_t::in_event (fd_t fd_) // Get the next command. If there is none, exit. command_t cmd; - int rc = mailbox.recv (&cmd, 0); + int rc = mailbox_recv (&mailbox, &cmd, 0); if (rc != 0 && errno == EINTR) continue; if (rc != 0 && errno == EAGAIN) -- cgit v1.2.3