1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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
This commit is contained in:
Andrew Bartlett 2013-01-25 23:00:12 +11:00 committed by Stefan Metzmacher
parent a321dd3aaf
commit b9f1c8887e

View File

@ -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);
}