1 /* $NetBSD: master_service.c,v 1.1.1.2 2013/01/02 18:59:01 tron Exp $ */
2
3 /*++
4 /* NAME
5 /* master_service 3
6 /* SUMMARY
7 /* Postfix master - start/stop services
8 /* SYNOPSIS
9 /* #include "master.h"
10 /*
11 /* void master_start_service(serv)
12 /* MASTER_SERV *serv;
13 /*
14 /* void master_stop_service(serv)
15 /* MASTER_SERV *serv;
16 /*
17 /* void master_restart_service(serv, conf_reload)
18 /* MASTER_SERV *serv;
19 /* int conf_reload;
20 /* DESCRIPTION
21 /* master_start_service() enables the named service.
22 /*
23 /* master_stop_service() disables named service.
24 /*
25 /* master_restart_service() requests all running child processes to
26 /* commit suicide. The conf_reload argument is either DO_CONF_RELOAD
27 /* (configuration files were reloaded, re-evaluate the child process
28 /* creation policy) or NO_CONF_RELOAD.
29 /* DIAGNOSTICS
30 /* BUGS
31 /* SEE ALSO
32 /* master_avail(3), process creation policy
33 /* master_wakeup(3), service automatic wakeup
34 /* master_status(3), child status reports
35 /* master_listen(3), unix/inet listeners
36 /* LICENSE
37 /* .ad
38 /* .fi
39 /* The Secure Mailer license must be distributed with this software.
40 /* AUTHOR(S)
41 /* Wietse Venema
42 /* IBM T.J. Watson Research
43 /* P.O. Box 704
44 /* Yorktown Heights, NY 10598, USA
45 /*--*/
46
47 /* System libraries. */
48
49 #include <sys_defs.h>
50 #include <string.h>
51 #include <unistd.h>
52
53 /* Utility library. */
54
55 #include <msg.h>
56 #include <mymalloc.h>
57
58 /* Application-specific. */
59
60 #include "master.h"
61
62 MASTER_SERV *master_head;
63
64 /* master_start_service - activate service */
65
master_start_service(MASTER_SERV * serv)66 void master_start_service(MASTER_SERV *serv)
67 {
68
69 /*
70 * Enable connection requests, wakeup timers, and status updates from
71 * child processes.
72 */
73 master_listen_init(serv);
74 master_avail_listen(serv);
75 master_status_init(serv);
76 master_wakeup_init(serv);
77 }
78
79 /* master_stop_service - deactivate service */
80
master_stop_service(MASTER_SERV * serv)81 void master_stop_service(MASTER_SERV *serv)
82 {
83
84 /*
85 * Undo the things that master_start_service() did.
86 */
87 master_wakeup_cleanup(serv);
88 master_status_cleanup(serv);
89 master_avail_cleanup(serv);
90 master_listen_cleanup(serv);
91 }
92
93 /* master_restart_service - restart service after configuration reload */
94
master_restart_service(MASTER_SERV * serv,int conf_reload)95 void master_restart_service(MASTER_SERV *serv, int conf_reload)
96 {
97
98 /*
99 * Undo some of the things that master_start_service() did.
100 */
101 master_wakeup_cleanup(serv);
102 master_status_cleanup(serv);
103
104 /*
105 * Now undo the undone.
106 */
107 master_status_init(serv);
108 master_wakeup_init(serv);
109
110 /*
111 * Respond to configuration change.
112 */
113 if (conf_reload)
114 master_avail_listen(serv);
115 }
116