diff options
author | Andrew Bartlett <abartlet@samba.org> | 2013-01-25 23:00:12 +1100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2013-01-26 16:13:04 +0100 |
commit | b9f1c8887ed1c8c29259021d4f2b9a549caa4061 (patch) | |
tree | 5066c851643fc1c51fe99a328cba648a87827582 /source4/smbd | |
parent | a321dd3aafa0f6ec8b39cd4fc64146dfbf24ce65 (diff) | |
download | samba-b9f1c8887ed1c8c29259021d4f2b9a549caa4061.tar.gz samba-b9f1c8887ed1c8c29259021d4f2b9a549caa4061.tar.bz2 samba-b9f1c8887ed1c8c29259021d4f2b9a549caa4061.zip |
s4-process_single: Use pid,task_id as cluster_id in process_single just like process_prefork
This avoids two different process single task servers (eg the drepl
server) sharing the same server id. The task id starts at 2^31 to
avoid collision with the fd based scheme for connections.
Fix-bug: https://bugzilla.samba.org/show_bug.cgi?id=9598
Reported-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sat Jan 26 16:13:05 CET 2013 on sn-devel-104
Diffstat (limited to 'source4/smbd')
-rw-r--r-- | source4/smbd/process_single.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c index ff67750034..a1b785ee41 100644 --- a/source4/smbd/process_single.c +++ b/source4/smbd/process_single.c @@ -91,15 +91,20 @@ static void single_new_task(struct tevent_context *ev, void (*new_task)(struct tevent_context *, struct loadparm_context *, struct server_id, void *), void *private_data) { - /* start our taskids at 1, zero is reserved for the top - level samba task */ - static uint32_t taskid = 1; + pid_t pid = getpid(); + /* start our taskids at MAX_INT32, the first 2^31 tasks are is reserved for fd numbers */ + static uint32_t taskid = INT32_MAX; - /* We use 1 so we cannot collide in with cluster ids generated - * in the accept connection above, and unlikly to collide with - * PIDs from process model standard (don't run samba as - * init) */ - new_task(ev, lp_ctx, cluster_id(1, taskid++), private_data); + /* + * We use the PID so we cannot collide in with cluster ids + * generated in other single mode tasks, and, and won't + * collide with PIDs from process model starndard because a the + * combination of pid/task_id should be unique system-wide + * + * Using the pid unaltered makes debugging of which process + * owns the messaging socket easier. + */ + new_task(ev, lp_ctx, cluster_id(pid, taskid++), private_data); } |