aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-base.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-20 02:53:21 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-20 02:53:21 +0200
commit2c357793ae7136b5f8e9bc7e9f015906b55655a2 (patch)
treead1fb967be12efd06cddfc6de9dacf28014ce32e /src/mds-base.h
parentadd broadcast support (diff)
downloadmds-2c357793ae7136b5f8e9bc7e9f015906b55655a2.tar.gz
mds-2c357793ae7136b5f8e9bc7e9f015906b55655a2.tar.bz2
mds-2c357793ae7136b5f8e9bc7e9f015906b55655a2.tar.xz
misc, mostly mds-base re-exec
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-base.h102
1 files changed, 95 insertions, 7 deletions
diff --git a/src/mds-base.h b/src/mds-base.h
index b4e4ad7..28d7432 100644
--- a/src/mds-base.h
+++ b/src/mds-base.h
@@ -20,6 +20,11 @@
#include <pthread.h>
+#include <signal.h>
+
+
+#define MDS_BASE_VARS_VERSION 0
+
/**
@@ -30,9 +35,15 @@ typedef struct server_characteristics
/**
* Setting this to zero will cause the server to drop privileges as a security precaution
*/
- int require_privileges;
+ int require_privileges : 1;
-} server_characteristics_t;
+ /**
+ * Setting this to non-zero will cause the server to connect to the display
+ */
+ int require_display : 1;
+
+} __attribute__((packed)) server_characteristics_t;
+
/**
@@ -67,17 +78,28 @@ extern int is_respawn;
*/
extern int is_reexec;
+/**
+ * The thread that runs the master loop
+ */
+extern pthread_t master_thread;
+
/**
- * The file descriptor of the socket
- * that is connected to the server
+ * Whether the server has been signaled to terminate
*/
-extern int socket_fd;
+extern volatile sig_atomic_t terminating;
/**
- * The thread that runs the master loop
+ * Whether the server has been signaled to re-exec
*/
-extern pthread_t master_thread;
+extern volatile sig_atomic_t reexecing;
+
+
+/**
+ * The file descriptor of the socket
+ * that is connected to the server
+ */
+extern int socket_fd;
@@ -95,6 +117,8 @@ int trap_signals(void);
* This function is called when a signal that
* signals the server to re-exec has been received
*
+ * When this function is invoked, it should set `reexecing` to a non-zero value
+ *
* @param signo The signal that has been received
*/
extern void received_reexec(int signo);
@@ -105,10 +129,74 @@ extern void received_reexec(int signo);
* This function is called when a signal that
* signals the server to re-exec has been received
*
+ * When this function is invoked, it should set `terminating` to a non-zero value
+ *
* @param signo The signal that has been received
*/
extern void received_terminate(int signo);
+/**
+ * This function should be implemented by the actual server implementation
+ *
+ * This function should initialise the server,
+ * and it not invoked after a re-exec.
+ *
+ * @return Non-zero on error
+ */
+extern int initialise_server(void);
+
+/**
+ * This function should be implemented by the actual server implementation
+ *
+ * Unmarshal server implementation specific data and update the servers state accordingly
+ *
+ * @param state_buf The marshalled data that as not been read already
+ * @return Non-zero on error
+ */
+extern int unmarshal_server(char* state_buf);
+
+/**
+ * This function should be implemented by the actual server implementation
+ *
+ * Marshal server implementation specific data into a buffer
+ *
+ * @param state_buf The buffer for the marshalled data
+ * @return Non-zero on error
+ */
+extern int marshal_server(char* state_buf);
+
+/**
+ * This function should be implemented by the actual server implementation
+ *
+ * Calculate the number of bytes that will be stored by `marshal_server`
+ *
+ * On failure the program should `abort()` or exit by other means.
+ * However it should not be possible for this function to fail.
+ *
+ * @return The number of bytes that will be stored by `marshal_server`
+ */
+extern size_t marshal_server_size(void);
+
+/**
+ * This function should be implemented by the actual server implementation
+ *
+ * Attempt to recover from an re-exec failure that has been
+ * detected after the server successfully updated it execution image
+ *
+ * @return Non-zero on error
+ */
+extern int reexec_failure_recover(void);
+
+
+/**
+ * This function should be implemented by the actual server implementation
+ *
+ * Perform the server's mission
+ *
+ * @return Non-zero on error
+ */
+extern int master_loop(void);
+
#endif