diff options
author | Michael Adam <obnox@samba.org> | 2013-02-26 16:39:46 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-09-19 09:15:12 +0200 |
commit | 1d615ee923a2b46ffd7f943a9ba9e362b6322e5e (patch) | |
tree | 013c27d3d5327ad2715e28b0ceb44084c466cbf4 | |
parent | 9afc37bef4e60ea4a13db8ae68ba30d73b5b719c (diff) | |
download | samba-1d615ee923a2b46ffd7f943a9ba9e362b6322e5e.tar.gz samba-1d615ee923a2b46ffd7f943a9ba9e362b6322e5e.tar.xz samba-1d615ee923a2b46ffd7f943a9ba9e362b6322e5e.zip |
s3:smbd: use tevent_loop_wait() in the parent smbd process.
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r-- | source3/smbd/server.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 1a0d3c9c9b..658f26870e 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -939,23 +939,55 @@ static void smbd_stdin_handler(struct tevent_context *ev, } } +struct smbd_parent_tevent_trace_state { + TALLOC_CTX *frame; +}; + +static void smbd_parent_tevent_trace_callback(enum tevent_trace_point point, + void *private_data) +{ + struct smbd_parent_tevent_trace_state *state = + (struct smbd_parent_tevent_trace_state *)private_data; + + switch (point) { + case TEVENT_TRACE_BEFORE_WAIT: + break; + case TEVENT_TRACE_AFTER_WAIT: + break; + case TEVENT_TRACE_BEFORE_LOOP_ONCE: + TALLOC_FREE(state->frame); + state->frame = talloc_stackframe(); + break; + case TEVENT_TRACE_AFTER_LOOP_ONCE: + TALLOC_FREE(state->frame); + break; + } + + errno = 0; +} + static void smbd_parent_loop(struct tevent_context *ev_ctx, struct smbd_parent_context *parent) { + struct smbd_parent_tevent_trace_state trace_state = { + .frame = NULL, + }; + int ret = 0; + + tevent_set_trace_callback(ev_ctx, smbd_parent_tevent_trace_callback, + &trace_state); + /* now accept incoming connections - forking a new process for each incoming connection */ DEBUG(2,("waiting for connections\n")); - while (1) { - int ret; - TALLOC_CTX *frame = talloc_stackframe(); - ret = tevent_loop_once(ev_ctx); - if (ret != 0) { - exit_server_cleanly("tevent_loop_once() error"); - } + ret = tevent_loop_wait(ev_ctx); + if (ret != 0) { + DEBUG(0, ("tevent_loop_wait failed: %d, %s, exiting\n", + ret, strerror(errno))); + } - TALLOC_FREE(frame); - } /* end while 1 */ + TALLOC_FREE(trace_state.frame); /* NOTREACHED return True; */ } |