summaryrefslogtreecommitdiff
path: root/source4/smbd/process_standard.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-30 02:55:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:23 -0500
commit1447b9a8c135ddc8d369be9ab970a4cccf4ecf0e (patch)
treefea0e3bc04a63cb7d3eb0dfad86e0589b12a235d /source4/smbd/process_standard.c
parent597142ddd3575a50a491a89dd5ce5fb40945028f (diff)
downloadsamba-1447b9a8c135ddc8d369be9ab970a4cccf4ecf0e.tar.gz
samba-1447b9a8c135ddc8d369be9ab970a4cccf4ecf0e.tar.bz2
samba-1447b9a8c135ddc8d369be9ab970a4cccf4ecf0e.zip
r5104: - added support for task based servers. These are servers that within
themselves are run as a single process, but run as a child of the main process when smbd is run in the standard model, and run as part of the main process when in the single mode. - rewrote the winbind template code to use the new task services. Also fixed the packet queueing - got rid of event_context_merge() as it is no longer needed (This used to be commit 339964a596689278d2138cff05d7d444798a3504)
Diffstat (limited to 'source4/smbd/process_standard.c')
-rw-r--r--source4/smbd/process_standard.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index ee73cfadcf..b7e9076e5d 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -104,11 +104,60 @@ static void standard_accept_connection(struct event_context *ev,
exit(0);
}
+/*
+ called to create a new server task
+*/
+static void standard_new_task(struct event_context *ev,
+ void (*new_task)(struct event_context *, uint32_t , void *),
+ void *private)
+{
+ pid_t pid;
+ struct event_context *ev2;
+
+ pid = fork();
+
+ if (pid != 0) {
+ /* parent or error code ... go back to the event loop */
+ return;
+ }
+
+ /* This is now the child code. We need a completely new event_context to work with */
+ ev2 = event_context_init(NULL);
+
+ /* the service has given us a private pointer that
+ encapsulates the context it needs for this new connection -
+ everything else will be freed */
+ talloc_steal(ev2, private);
+
+ /* this will free all the listening sockets and all state that
+ is not associated with this new connection */
+ talloc_free(ev);
+
+ /* tdb needs special fork handling */
+ if (tdb_reopen_all() == -1) {
+ DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));
+ }
+
+ /* Ensure that the forked children do not expose identical random streams */
+ set_need_random_reseed();
+
+ /* setup this new connection */
+ new_task(ev2, getpid(), private);
+
+ /* we can't return to the top level here, as that event context is gone,
+ so we now process events in the new event context until there are no
+ more to process */
+ event_loop_wait(ev2);
+
+ talloc_free(ev2);
+ exit(0);
+}
+
-/* called when a connection goes down */
-static void standard_terminate_connection(struct event_context *ev, const char *reason)
+/* called when a task goes down */
+static void standard_terminate(struct event_context *ev, const char *reason)
{
- DEBUG(2,("standard_terminate_connection: reason[%s]\n",reason));
+ DEBUG(2,("standard_terminate: reason[%s]\n",reason));
/* this init_iconv() has the effect of freeing the iconv context memory,
which makes leak checking easier */
@@ -128,7 +177,8 @@ static const struct model_ops standard_ops = {
.name = "standard",
.model_init = standard_model_init,
.accept_connection = standard_accept_connection,
- .terminate_connection = standard_terminate_connection,
+ .new_task = standard_new_task,
+ .terminate = standard_terminate,
};
/*