summaryrefslogtreecommitdiff
path: root/src/signaler.hpp
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/signaler.hpp
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/signaler.hpp')
-rw-r--r--src/signaler.hpp40
1 files changed, 19 insertions, 21 deletions
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_);
}