From 14795c8cdcf6a15e369736be955c8a8a21495f88 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 8 Sep 2014 13:25:18 +0200 Subject: add received_danger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-base.c | 42 ++++++++++++++++++++++++++++++------------ src/mds-base.h | 11 +++++++++++ 2 files changed, 41 insertions(+), 12 deletions(-) (limited to 'src') 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,35 +275,53 @@ 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; } # pragma GCC diagnostic pop +/** + * 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 @@ -201,6 +201,17 @@ int server_initialised(void); /* __attribute__((weak)) */ */ 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 -- cgit v1.2.3-70-g09d2