diff options
| author | Simon Rettberg | 2016-02-05 15:05:30 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2016-02-05 15:05:30 +0100 |
| commit | 627645acc074eab7a3694a267bc2a643d8b3e57a (patch) | |
| tree | 5f61225803c369ab1295ce0ee36a33ae6cb51eb8 /src/shared/signal.h | |
| parent | [SERVER] BREAKING: Get rid of pseudo case-insensitivity (diff) | |
| download | dnbd3-627645acc074eab7a3694a267bc2a643d8b3e57a.tar.gz dnbd3-627645acc074eab7a3694a267bc2a643d8b3e57a.tar.xz dnbd3-627645acc074eab7a3694a267bc2a643d8b3e57a.zip | |
First steps in make signals more abstract from the underlying mechanism; replace epoll with poll.
We now don't assume that a signal equals a single fd (eventfd on Linux).
The next step would be to create a version of signal.c that uses a pipe
internally, so it can be used on other platforms, like *BSD.
This is also the reason epoll was replaced with poll in uplink.c
Diffstat (limited to 'src/shared/signal.h')
| -rw-r--r-- | src/shared/signal.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/shared/signal.h b/src/shared/signal.h index 6fd2765..3eea6fb 100644 --- a/src/shared/signal.h +++ b/src/shared/signal.h @@ -5,23 +5,25 @@ #define SIGNAL_TIMEOUT (-2) #define SIGNAL_ERROR (-1) +typedef struct _dnbd3_signal dnbd3_signal_t; + /** - * Create a new signal fd (eventfd), nonblocking. - * @return >= 0 on success, which is the fd; < 0 on error + * Create a new signal, nonblocking. + * @return NULL on error, pointer to dnbd3_signal_t on success. */ -int signal_new(); +dnbd3_signal_t* signal_new(); /** - * Create a new signal fd (eventfd), blocking. - * @return >= 0 on success, which is the fd; < 0 on error + * Create a new signal, blocking. + * @return NULL on error, pointer to dnbd3_signal_t on success. */ -int signal_newBlocking(); +dnbd3_signal_t* signal_newBlocking(); /** * Trigger the given signal, so a wait or clear call will succeed. * @return SIGNAL_OK on success, SIGNAL_ERROR on error */ -int signal_call(int signalFd); +int signal_call(const dnbd3_signal_t* const signal); /** * Wait for given signal, with an optional timeout. @@ -31,18 +33,25 @@ int signal_call(int signalFd); * SIGNAL_TIMEOUT if the timeout was reached, * SIGNAL_ERROR if some error occured */ -int signal_wait(int signalFd, int timeoutMs); +int signal_wait(const dnbd3_signal_t* const signal, int timeoutMs); /** - * Clears any pending signals on this signal fd. + * Clears any pending signals on this signal. * @return number of signals that were pending, * SIGNAL_ERROR if some error occured */ -int signal_clear(int signalFd); +int signal_clear(const dnbd3_signal_t* const signal); /** * Close the given signal. */ -void signal_close(int signalFd); +void signal_close(const dnbd3_signal_t* const signal); + +/** + * Get a file descriptor for the given signal that can be + * waited on using poll or similar. + * @return -1 if the signal is invalid + */ +int signal_getWaitFd(const dnbd3_signal_t* const signal); #endif |
