source4 smbd: remove global control pipe from process_standard.
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 21 Aug 2017 19:58:14 +0000 (07:58 +1200)
committerRalph Boehme <slow@samba.org>
Thu, 28 Sep 2017 00:08:34 +0000 (02:08 +0200)
commit099df25f567a34bf0c159e18b62cd67b073c3002
treeb3b259d68abbafbf3099283a7261fa2caef6998e
parent575f1e2bf51131709f55d565568198f56a0cbdda
source4 smbd: remove global control pipe from process_standard.

The standard model uses a pipe to signal the worker processes spawned on
accept that the controlling process has terminated and that they should
shut down.  This pipe is currently a static global variable in
process_standard.c.

This patch replaces that global pipe with a file descriptor passed into
the process model init functions, giving  a single mechanism across all process
models.  This paves the way for the addition of a pre-fork process model.

Ensuring that the correct file descriptors are closed, is difficult so
it is best do this only once rather than require the process models to
do this individually.

Notes on debugging pipe ownership:

Add code to log the process id and the file descriptor of the writeable
pipe.

run:
   lsof | grep FIFO | grep samba | grep <process id>
   this will produce lines like:

   samba 25624 him 4w FIFO 0,10 0t0 472206 pipe

   where: 4w is the file descriptor and mode and the number to the left
          of "pipe" is the pipe id.
then:
   lsof | grep FIFO | grep samba | grep <pipe id>

   This will display all the processes with the pipe open and the mode
   only the smbd master process should have it open in write mode.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Sep 28 02:08:34 CEST 2017 on sn-devel-144
source4/smbd/process_model.h
source4/smbd/process_single.c
source4/smbd/process_standard.c
source4/smbd/server.c
source4/smbd/service.c
source4/smbd/service_task.c