summaryrefslogtreecommitdiffstats
path: root/src/server/signal.h
diff options
context:
space:
mode:
authorSimon Rettberg2014-12-31 17:19:20 +0100
committerSimon Rettberg2014-12-31 17:19:20 +0100
commit7b8e3ffcbccf6d02bfcb0c9c9c2d259362357fb8 (patch)
tree80dd759e320ff74bc8bb56fb9a9858c57f99320a /src/server/signal.h
parent[SERVER] Add setting to enable/disable background replication, add comments t... (diff)
downloaddnbd3-7b8e3ffcbccf6d02bfcb0c9c9c2d259362357fb8.tar.gz
dnbd3-7b8e3ffcbccf6d02bfcb0c9c9c2d259362357fb8.tar.xz
dnbd3-7b8e3ffcbccf6d02bfcb0c9c9c2d259362357fb8.zip
[SERVER] Create compilation unit for wait/signalling logic (using eventfd)
Diffstat (limited to 'src/server/signal.h')
-rw-r--r--src/server/signal.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/server/signal.h b/src/server/signal.h
new file mode 100644
index 0000000..0504274
--- /dev/null
+++ b/src/server/signal.h
@@ -0,0 +1,42 @@
+#ifndef _SIGNAL_H_
+#define _SIGNAL_H_
+
+#define SIGNAL_OK (0)
+#define SIGNAL_TIMEOUT (-2)
+#define SIGNAL_ERROR (-1)
+
+/**
+ * Create a new signal fd (eventfd), nonblocking.
+ * @return >= 0 on success, which is the fd; < 0 on error
+ */
+int signal_new();
+
+/**
+ * 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);
+
+/**
+ * Wait for given signal, with an optional timeout.
+ * If timeout == 0, wait forever.
+ * @return > 0 telling how many times the signal was called,
+ * SIGNAL_TIMEOUT if the timeout was reached,
+ * SIGNAL_ERROR if some error occured
+ */
+int signal_wait(int signalFd, int timeoutMs);
+
+/**
+ * Clears any pending signals on this signal fd.
+ * @return number of signals that were pending,
+ * SIGNAL_ERROR if some error occured
+ */
+int signal_clear(int signalFd);
+
+/**
+ * Close the given signal.
+ */
+void signal_close(int signalFd);
+
+#endif
+