1 /* $NetBSD: master_service.c,v 1.1.1.1 2009/06/23 10:08:49 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) 18 /* MASTER_SERV *serv; 19 /* DESCRIPTION 20 /* master_start_service() enables the named service. 21 /* 22 /* master_stop_service() disables named service. 23 /* 24 /* master_restart_service() requests all running child processes to 25 /* commit suicide. This is typically used after a configuration reload. 26 /* DIAGNOSTICS 27 /* BUGS 28 /* SEE ALSO 29 /* master_avail(3), process creation policy 30 /* master_wakeup(3), service automatic wakeup 31 /* master_status(3), child status reports 32 /* master_listen(3), unix/inet listeners 33 /* LICENSE 34 /* .ad 35 /* .fi 36 /* The Secure Mailer license must be distributed with this software. 37 /* AUTHOR(S) 38 /* Wietse Venema 39 /* IBM T.J. Watson Research 40 /* P.O. Box 704 41 /* Yorktown Heights, NY 10598, USA 42 /*--*/ 43 44 /* System libraries. */ 45 46 #include <sys_defs.h> 47 #include <string.h> 48 #include <unistd.h> 49 50 /* Utility library. */ 51 52 #include <msg.h> 53 #include <mymalloc.h> 54 55 /* Application-specific. */ 56 57 #include "master.h" 58 59 MASTER_SERV *master_head; 60 61 /* master_start_service - activate service */ 62 63 void master_start_service(MASTER_SERV *serv) 64 { 65 66 /* 67 * Enable connection requests, wakeup timers, and status updates from 68 * child processes. 69 */ 70 master_listen_init(serv); 71 master_avail_listen(serv); 72 master_status_init(serv); 73 master_wakeup_init(serv); 74 } 75 76 /* master_stop_service - deactivate service */ 77 78 void master_stop_service(MASTER_SERV *serv) 79 { 80 81 /* 82 * Undo the things that master_start_service() did. 83 */ 84 master_wakeup_cleanup(serv); 85 master_status_cleanup(serv); 86 master_avail_cleanup(serv); 87 master_listen_cleanup(serv); 88 } 89 90 /* master_restart_service - restart service after configuration reload */ 91 92 void master_restart_service(MASTER_SERV *serv) 93 { 94 95 /* 96 * Undo some of the things that master_start_service() did. 97 */ 98 master_wakeup_cleanup(serv); 99 master_status_cleanup(serv); 100 101 /* 102 * Now undo the undone. 103 */ 104 master_status_init(serv); 105 master_wakeup_init(serv); 106 } 107