7 /* Postfix master - status notification protocol
9 /* #include <master_proto.h>
11 /* int master_notify(pid, generation, status)
13 /* unsigned generation;
16 /* The master process provides a standard environment for its
17 /* child processes. Part of this environment is a pair of file
18 /* descriptors that the master process shares with all child
19 /* processes that provide the same service.
20 /* .IP MASTER_LISTEN_FD
21 /* The shared file descriptor for accepting client connection
22 /* requests. The master process listens on this socket or FIFO
23 /* when all child processes are busy.
24 /* .IP MASTER_STATUS_FD
25 /* The shared file descriptor for sending child status updates to
26 /* the master process.
28 /* A child process uses master_notify() to send a status notification
29 /* message to the master process.
30 /* .IP MASTER_STAT_AVAIL
31 /* The child process is ready to accept client connections.
32 /* .IP MASTER_STAT_TAKEN
33 /* Until further notice, the child process is unavailable for
34 /* accepting client connections.
36 /* When a child process terminates without sending a status update,
37 /* the master process will figure out that the child is no longer
40 /* The result is -1 in case of problems. This usually means that
41 /* the parent disconnected after a reload request, in order to
42 /* force children to commit suicide.
46 /* The Secure Mailer license must be distributed with this software.
49 /* IBM T.J. Watson Research
51 /* Yorktown Heights, NY 10598, USA
59 /* Utility library. */
65 #include "master_proto.h"
67 int master_notify(int pid
, unsigned generation
, int status
)
69 const char *myname
= "master_notify";
73 * We use a simple binary protocol to minimize security risks. Since this
74 * is local IPC, there are no byte order or word length issues. The
75 * server treats this information as gossip, so sending a bad PID or a
76 * bad status code will only have amusement value.
79 stat
.gen
= generation
;
82 if (write(MASTER_STATUS_FD
, (char *) &stat
, sizeof(stat
)) != sizeof(stat
)) {
84 msg_info("%s: status %d: %m", myname
, status
);
88 msg_info("%s: status %d", myname
, status
);