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/signaler.hpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'src/signaler.hpp') diff --git a/src/signaler.hpp b/src/signaler.hpp index c289490..20c2c36 100644 --- a/src/signaler.hpp +++ b/src/signaler.hpp @@ -31,32 +31,30 @@ namespace xs // given moment. Attempt to send a signal before receiving the previous // one will result in undefined behaviour. - class signaler_t - { - public: + typedef struct { + fd_t w; + fd_t r; + } signaler_t; - signaler_t (); - ~signaler_t (); + // Initialise the signaler. + int signaler_init (signaler_t *self_); - fd_t get_fd (); - void send (); - int wait (int timeout_); - void recv (); - - private: + // Destroy the signaler. + void signaler_close (signaler_t *self_); - // Creates a pair of filedescriptors that will be used - // to pass the signals. - static int make_fdpair (fd_t *r_, fd_t *w_); + // Return file decriptor that you can poll on to get notified when + // signal is sent. + fd_t signaler_fd (signaler_t *self_); - // Underlying write & read file descriptor. - fd_t w; - fd_t r; + // Send a signal. + void signaler_send (signaler_t *self_); + + // Wait for a signal. up to timout_ milliseconds. + // The signale is *not* consumed by this function. + int signaler_wait (signaler_t *self_, int timeout_); - // Disable copying of signaler_t object. - signaler_t (const signaler_t&); - const signaler_t &operator = (const signaler_t&); - }; + // Wait for and consume a signal. + void signaler_recv (signaler_t *self_); } -- cgit v1.2.3