From: Andrew Bartlett Date: Fri, 25 Jan 2013 12:00:12 +0000 (+1100) Subject: s4-process_single: Use pid,task_id as cluster_id in process_single just like process_... X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=b9f1c8887ed1c8c29259021d4f2b9a549caa4061 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 Reviewed-by: Stefan Metzmacher Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Sat Jan 26 16:13:05 CET 2013 on sn-devel-104 --- diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c index ff677500341f..a1b785ee41b7 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); }