aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-08 13:25:18 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-08 13:25:18 +0200
commit14795c8cdcf6a15e369736be955c8a8a21495f88 (patch)
tree85c793a480118c060436b8d9f6e56cb450540f6c
parentmove reconnect_to_display todo into todo file (diff)
downloadmds-14795c8cdcf6a15e369736be955c8a8a21495f88.tar.gz
mds-14795c8cdcf6a15e369736be955c8a8a21495f88.tar.bz2
mds-14795c8cdcf6a15e369736be955c8a8a21495f88.tar.xz
add received_danger
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--doc/info/mds.texinfo10
-rw-r--r--src/mds-base.c42
-rw-r--r--src/mds-base.h11
3 files changed, 51 insertions, 12 deletions
diff --git a/doc/info/mds.texinfo b/doc/info/mds.texinfo
index 3c5e1ce..0d721b8 100644
--- a/doc/info/mds.texinfo
+++ b/doc/info/mds.texinfo
@@ -4157,6 +4157,16 @@ implementation if the server is multi-threaded. It sends
the singal @code{signo} to all threads except the current
thread.
+@item @code{received_danger} [(@code{int signo}) @arrow{} @code{void}]
+This function is called when a signal that signals the
+system is running out of memory has been received. The exact
+received signal is specified by the parameter @code{signo}.
+When this function is invoked, the server should free up
+all memory it can spare. If the server never has any memory
+that could be freed this function does not been to be
+overridden. If @code{server_characteristics.danger_is_deadly}
+is set, this function will never be called.
+
@item @code{received_reexec} [(@code{int signo}) @arrow{} @code{void}]
This function is called when a signal that signals the
server to re-execute has been received. The exact
diff --git a/src/mds-base.c b/src/mds-base.c
index 4584670..3553c69 100644
--- a/src/mds-base.c
+++ b/src/mds-base.c
@@ -275,29 +275,32 @@ int __attribute__((weak)) server_initialised(void)
}
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
/**
- * This function is called when an intraprocess signal
- * that used to send a notification to a thread
+ * This function should be implemented by the actual server implementation
+ * if the server is multi-threaded
*
- * @param signo The signal that has been received
+ * Send a singal to all threads except the current thread
+ *
+ * @param signo The signal
*/
-static void __attribute__((const)) received_noop(int signo)
+void __attribute__((weak)) signal_all(int signo)
{
(void) signo;
}
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
/**
- * This function should be implemented by the actual server implementation
- * if the server is multi-threaded
+ * This function is called when a signal that
+ * signals that the system is running out of memory
+ * has been received
*
- * Send a singal to all threads except the current thread
+ * By default this function does not do anything
*
- * @param signo The signal
+ * @param signo The signal that has been received
*/
-void __attribute__((weak)) signal_all(int signo)
+void __attribute__((weak)) received_danger(int signo)
{
(void) signo;
}
@@ -305,6 +308,21 @@ void __attribute__((weak)) signal_all(int signo)
/**
+ * This function is called when an intraprocess signal
+ * that used to send a notification to a thread
+ *
+ * @param signo The signal that has been received
+ */
+static void __attribute__((const)) received_noop(int signo)
+{
+ (void) signo;
+ /* This function is used rather than SIG_IGN because we
+ * want blocking functions to return with errno set to
+ * `EINTR` rather than continue blocking. */
+}
+
+
+/**
* This function is called when a signal that
* signals the server to re-exec has been received
*
@@ -611,7 +629,7 @@ int trap_signals(void)
if (server_characteristics.danger_is_deadly && !is_immortal)
{ fail_if (xsigaction(SIGDANGER, commit_suicide) < 0); }
else
- { fail_if (xsigaction(SIGDANGER, SIG_IGN) < 0); }
+ { fail_if (xsigaction(SIGDANGER, received_danger) < 0); }
return 0;
pfail:
diff --git a/src/mds-base.h b/src/mds-base.h
index 1ea132a..0b5f85a 100644
--- a/src/mds-base.h
+++ b/src/mds-base.h
@@ -203,6 +203,17 @@ void signal_all(int signo); /* __attribute__((weak)) */
/**
* This function is called when a signal that
+ * signals that the system is running out of memory
+ * has been received
+ *
+ * By default this function does not do anything
+ *
+ * @param signo The signal that has been received
+ */
+void received_danger(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 `reexecing` and