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