1 /* $NetBSD: qmgr_enable.c,v 1.1.1.1 2009/06/23 10:08:52 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* qmgr_enable 6 /* SUMMARY 7 /* enable dead transports or sites 8 /* SYNOPSIS 9 /* #include "qmgr.h" 10 /* 11 /* void qmgr_enable_queue(queue) 12 /* QMGR_QUEUE *queue; 13 /* 14 /* QMGR_QUEUE *qmgr_enable_transport(transport) 15 /* QMGR_TRANSPORT *transport; 16 /* 17 /* void qmgr_enable_all(void) 18 /* DESCRIPTION 19 /* This module purges dead in-core state information, effectively 20 /* re-enabling delivery. 21 /* 22 /* qmgr_enable_queue() enables deliveries to the named dead site. 23 /* Empty queues are destroyed. The existed solely to indicate that 24 /* a site is dead. 25 /* 26 /* qmgr_enable_transport() enables deliveries via the specified 27 /* transport, and calls qmgr_enable_queue() for each destination 28 /* on that transport. Empty queues are destroyed. 29 /* 30 /* qmgr_enable_all() enables all transports and queues. 31 /* See above for the side effects caused by doing this. 32 /* BUGS 33 /* The side effects of calling this module can be quite dramatic. 34 /* DIAGNOSTICS 35 /* Panic: consistency check failure. Fatal: out of memory. 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 library. */ 48 49 #include <sys_defs.h> 50 51 /* Utility library. */ 52 53 #include <msg.h> 54 #include <vstream.h> 55 56 /* Application-specific. */ 57 58 #include "qmgr.h" 59 60 /* qmgr_enable_all - enable transports and queues */ 61 qmgr_enable_all(void)62void qmgr_enable_all(void) 63 { 64 QMGR_TRANSPORT *xport; 65 66 if (msg_verbose) 67 msg_info("qmgr_enable_all"); 68 69 /* 70 * The number of transports does not change as a side effect, so this can 71 * be a straightforward loop. 72 */ 73 for (xport = qmgr_transport_list.next; xport; xport = xport->peers.next) 74 qmgr_enable_transport(xport); 75 } 76 77 /* qmgr_enable_transport - defer todo entries for named transport */ 78 qmgr_enable_transport(QMGR_TRANSPORT * transport)79void qmgr_enable_transport(QMGR_TRANSPORT *transport) 80 { 81 QMGR_QUEUE *queue; 82 QMGR_QUEUE *next; 83 84 /* 85 * Proceed carefully. Queues may disappear as a side effect. 86 */ 87 if (transport->flags & QMGR_TRANSPORT_STAT_DEAD) { 88 if (msg_verbose) 89 msg_info("enable transport %s", transport->name); 90 qmgr_transport_unthrottle(transport); 91 } 92 for (queue = transport->queue_list.next; queue; queue = next) { 93 next = queue->peers.next; 94 qmgr_enable_queue(queue); 95 } 96 } 97 98 /* qmgr_enable_queue - enable and possibly delete queue */ 99 qmgr_enable_queue(QMGR_QUEUE * queue)100void qmgr_enable_queue(QMGR_QUEUE *queue) 101 { 102 if (QMGR_QUEUE_THROTTLED(queue)) { 103 if (msg_verbose) 104 msg_info("enable site %s/%s", queue->transport->name, queue->name); 105 qmgr_queue_unthrottle(queue); 106 } 107 if (QMGR_QUEUE_READY(queue) && queue->todo.next == 0 && queue->busy.next == 0) 108 qmgr_queue_done(queue); 109 } 110