[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Sat Apr 8 14:22:01 UTC 2017
The branch, master has been updated
via 6d6117b s4: process_standard: Add a simplified SIGTERM handler based on code from source4/smbd/server.c. Use from a tevent handler added to standard_accept_connection() and standard_new_task()
via d354be9 s4: process_standard: Add tevent SIGHUP signal handler to standard_accept_connection() and standard_new_task().
via 513eb8b s4: process_standard: Add return checking for tevent_add_fd() to standard_accept_connection() and standard_new_task().
via c977143 s4: process_standard: Always free tevent_context before exit().
via 7c01723 s4: process_standard: Move talloc_free of event context so it is last thing freed before exit().
from a9bd9a1 s3:tests: Create a test directory for a clean test
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6d6117b5ba510d169cbc0c285edc75c24f60625a
Author: Jeremy Allison <jra at samba.org>
Date: Fri Apr 7 15:45:41 2017 -0700
s4: process_standard: Add a simplified SIGTERM handler based on code from source4/smbd/server.c. Use from a tevent handler added to standard_accept_connection() and standard_new_task()
Allows us to be independent of parent SIGTERM signal handling.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Sat Apr 8 16:21:57 CEST 2017 on sn-devel-144
commit d354be9e078730505462623225295e675d73fd86
Author: Jeremy Allison <jra at samba.org>
Date: Fri Apr 7 15:31:57 2017 -0700
s4: process_standard: Add tevent SIGHUP signal handler to standard_accept_connection() and standard_new_task().
This makes us independent of parent SIGHUP signal handling.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 513eb8b8d397a9d6a5b7f029590b2e7dc0c1b743
Author: Jeremy Allison <jra at samba.org>
Date: Fri Apr 7 15:12:51 2017 -0700
s4: process_standard: Add return checking for tevent_add_fd() to standard_accept_connection() and standard_new_task().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit c97714319bdd0c3d54fb3ba64798c3aa674bb60b
Author: Jeremy Allison <jra at samba.org>
Date: Fri Apr 7 15:10:09 2017 -0700
s4: process_standard: Always free tevent_context before exit().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 7c017234ab486859829aeaab2ce728956db30b60
Author: Jeremy Allison <jra at samba.org>
Date: Fri Apr 7 15:08:13 2017 -0700
s4: process_standard: Move talloc_free of event context so it is last thing freed before exit().
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source4/smbd/process_standard.c | 90 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 86 insertions(+), 4 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index ca93f93..92f07ad 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -29,6 +29,7 @@
#include "param/param.h"
#include "ldb_wrap.h"
#include "lib/messaging/messaging.h"
+#include "lib/util/debug.h"
struct standard_child_state {
const char *name;
@@ -58,6 +59,34 @@ static void standard_model_init(void)
}
}
+static void sighup_signal_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum, int count, void *siginfo,
+ void *private_data)
+{
+ debug_schedule_reopen_logs();
+}
+
+static void sigterm_signal_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum, int count, void *siginfo,
+ void *private_data)
+{
+#if HAVE_GETPGRP
+ if (getpgrp() == getpid()) {
+ /*
+ * We're the process group leader, send
+ * SIGTERM to our process group.
+ */
+ DEBUG(0,("SIGTERM: killing children\n"));
+ kill(-getpgrp(), SIGTERM);
+ }
+#endif
+ DEBUG(0,("Exiting pid %u on SIGTERM\n", (unsigned int)getpid()));
+ talloc_free(ev);
+ exit(127);
+}
+
/*
handle EOF on the parent-to-all-children pipe in the child
*/
@@ -65,6 +94,7 @@ static void standard_pipe_handler(struct tevent_context *event_ctx, struct teven
uint16_t flags, void *private_data)
{
DEBUG(10,("Child %d exiting\n", (int)getpid()));
+ talloc_free(event_ctx);
exit(0);
}
@@ -211,6 +241,8 @@ static void standard_accept_connection(struct tevent_context *ev,
pid_t pid;
struct socket_address *c, *s;
struct standard_child_state *state;
+ struct tevent_fd *fde = NULL;
+ struct tevent_signal *se = NULL;
state = setup_standard_child_pipe(ev, NULL);
if (state == NULL) {
@@ -277,13 +309,37 @@ static void standard_accept_connection(struct tevent_context *ev,
smb_panic("Failed to re-initialise imessaging after fork");
}
- tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
+ fde = tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
standard_pipe_handler, NULL);
+ if (fde == NULL) {
+ smb_panic("Failed to add fd handler after fork");
+ }
+
if (child_pipe[1] != -1) {
close(child_pipe[1]);
child_pipe[1] = -1;
}
+ se = tevent_add_signal(ev,
+ ev,
+ SIGHUP,
+ 0,
+ sighup_signal_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("Failed to add SIGHUP handler after fork");
+ }
+
+ se = tevent_add_signal(ev,
+ ev,
+ SIGTERM,
+ 0,
+ sigterm_signal_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("Failed to add SIGTERM handler after fork");
+ }
+
/* setup the process title */
c = socket_get_peer_addr(sock2, ev);
s = socket_get_my_addr(sock2, ev);
@@ -318,6 +374,8 @@ static void standard_new_task(struct tevent_context *ev,
pid_t pid;
NTSTATUS status;
struct standard_child_state *state;
+ struct tevent_fd *fde = NULL;
+ struct tevent_signal *se = NULL;
state = setup_standard_child_pipe(ev, service_name);
if (state == NULL) {
@@ -360,13 +418,36 @@ static void standard_new_task(struct tevent_context *ev,
smb_panic("Failed to re-initialise imessaging after fork");
}
- tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
+ fde = tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ,
standard_pipe_handler, NULL);
+ if (fde == NULL) {
+ smb_panic("Failed to add fd handler after fork");
+ }
if (child_pipe[1] != -1) {
close(child_pipe[1]);
child_pipe[1] = -1;
}
+ se = tevent_add_signal(ev,
+ ev,
+ SIGHUP,
+ 0,
+ sighup_signal_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("Failed to add SIGHUP handler after fork");
+ }
+
+ se = tevent_add_signal(ev,
+ ev,
+ SIGTERM,
+ 0,
+ sigterm_signal_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("Failed to add SIGTERM handler after fork");
+ }
+
setproctitle("task %s server_id[%d]", service_name, (int)pid);
/* setup this new task. Cluster ID is PID based for this process model */
@@ -388,12 +469,13 @@ _NORETURN_ static void standard_terminate(struct tevent_context *ev, struct load
{
DEBUG(2,("standard_terminate: reason[%s]\n",reason));
- talloc_free(ev);
-
/* this reload_charcnv() has the effect of freeing the iconv context memory,
which makes leak checking easier */
reload_charcnv(lp_ctx);
+ /* Always free event context last before exit. */
+ talloc_free(ev);
+
/* terminate this process */
exit(0);
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list