25
25
#include "server_config.h"
26
26
#include "dispatch_private.h"
27
27
#include "entity.h"
28
- #include "server_private.h"
29
28
30
29
#include "qpid/dispatch/ctools.h"
31
30
#include "qpid/dispatch/failoverlist.h"
42
41
43
42
44
43
struct qd_connection_manager_t {
45
- qd_server_t * server ;
46
44
qd_listener_list_t listeners ;
47
45
qd_connector_config_list_t connector_configs ;
48
46
};
@@ -60,58 +58,11 @@ static void log_config(qd_server_config_t *c, const char *what, bool create)
60
58
QD_EXPORT qd_listener_t * qd_dispatch_configure_listener (qd_dispatch_t * qd , qd_entity_t * entity )
61
59
{
62
60
qd_connection_manager_t * cm = qd -> connection_manager ;
63
- qd_listener_t * li = qd_listener (qd -> server );
64
- if (!li || qd_server_config_load (& li -> config , entity , true) != QD_ERROR_NONE ) {
65
- qd_log (LOG_CONN_MGR , QD_LOG_ERROR , "Unable to create listener: %s" , qd_error_message ());
66
- qd_listener_decref (li );
61
+ qd_listener_t * li = qd_listener_create (qd , entity );
62
+ if (!li ) {
67
63
return 0 ;
68
64
}
69
65
70
- if (li -> config .ssl_profile_name ) {
71
- li -> tls_config = qd_tls_config (li -> config .ssl_profile_name ,
72
- QD_TLS_TYPE_PROTON_AMQP ,
73
- QD_TLS_CONFIG_SERVER_MODE ,
74
- li -> config .verify_host_name ,
75
- li -> config .ssl_require_peer_authentication );
76
- if (!li -> tls_config ) {
77
- // qd_tls_config() sets qd_error_message():
78
- qd_log (LOG_CONN_MGR , QD_LOG_ERROR , "Failed to configure TLS for Listener %s: %s" ,
79
- li -> config .name , qd_error_message ());
80
- qd_listener_decref (li );
81
- return 0 ;
82
- }
83
- li -> tls_ordinal = qd_tls_config_get_ordinal (li -> tls_config );
84
- li -> tls_oldest_valid_ordinal = qd_tls_config_get_oldest_valid_ordinal (li -> tls_config );
85
- }
86
-
87
- char * fol = qd_entity_opt_string (entity , "failoverUrls" , 0 );
88
- if (fol ) {
89
- li -> config .failover_list = qd_failover_list (fol );
90
- free (fol );
91
- if (li -> config .failover_list == 0 ) {
92
- qd_log (LOG_CONN_MGR , QD_LOG_ERROR , "Unable to create listener, bad failover list: %s" ,
93
- qd_error_message ());
94
- qd_listener_decref (li );
95
- return 0 ;
96
- }
97
- } else {
98
- li -> config .failover_list = 0 ;
99
- }
100
-
101
- //
102
- // Set up the vanflow record for this listener (ROUTER_ACCESS).
103
- // Do this only for router-to-router links: not mgmt/metrics/healthz/websockets listeners
104
- //
105
- if (strcmp (li -> config .role , "inter-router" ) == 0 ||
106
- strcmp (li -> config .role , "edge" ) == 0 ||
107
- strcmp (li -> config .role , "inter-edge" ) == 0 ) {
108
- li -> vflow_record = vflow_start_record (VFLOW_RECORD_ROUTER_ACCESS , 0 );
109
- vflow_set_string (li -> vflow_record , VFLOW_ATTRIBUTE_NAME , li -> config .name );
110
- vflow_set_string (li -> vflow_record , VFLOW_ATTRIBUTE_ROLE , li -> config .role );
111
- vflow_set_uint64 (li -> vflow_record , VFLOW_ATTRIBUTE_LINK_COUNT , 0 );
112
- }
113
-
114
- DEQ_ITEM_INIT (li );
115
66
DEQ_INSERT_TAIL (cm -> listeners , li );
116
67
log_config (& li -> config , "Listener" , true);
117
68
return li ;
@@ -299,7 +250,6 @@ qd_connection_manager_t *qd_connection_manager(qd_dispatch_t *qd)
299
250
if (!cm )
300
251
return 0 ;
301
252
302
- cm -> server = qd -> server ;
303
253
DEQ_INIT (cm -> listeners );
304
254
DEQ_INIT (cm -> connector_configs );
305
255
@@ -315,17 +265,7 @@ void qd_connection_manager_free(qd_connection_manager_t *cm)
315
265
qd_listener_t * li = DEQ_HEAD (cm -> listeners );
316
266
while (li ) {
317
267
DEQ_REMOVE_HEAD (cm -> listeners );
318
- if (li -> pn_listener ) {
319
- // DISPATCH-1508: force cleanup of pn_listener context. This is
320
- // usually done in the PN_LISTENER_CLOSE event handler in server.c,
321
- // but since the router is going down those events will no longer
322
- // be generated.
323
- pn_listener_set_context (li -> pn_listener , 0 );
324
- pn_listener_close (li -> pn_listener );
325
- li -> pn_listener = 0 ;
326
- qd_listener_decref (li ); // for the pn_listener's context
327
- }
328
- qd_listener_decref (li );
268
+ qd_listener_delete (li , true); // true == router is shutting down
329
269
li = DEQ_HEAD (cm -> listeners );
330
270
}
331
271
@@ -351,6 +291,10 @@ QD_EXPORT void qd_connection_manager_start(qd_dispatch_t *qd)
351
291
352
292
while (li ) {
353
293
if (!li -> pn_listener ) {
294
+ // DISPATCH-55: failure to bind on router initialization can result in a router that cannot be accessed by
295
+ // management, preventing diagnosing/fixing the issue. Treat listener failure on initial bring up as a
296
+ // critical issue. Failure of listeners added after the router has been successfully started will simply
297
+ // result in a logged error.
354
298
if (!qd_listener_listen (li ) && first_start ) {
355
299
qd_log (LOG_CONN_MGR , QD_LOG_CRITICAL , "Listen on %s failed during initial config" ,
356
300
li -> config .host_port );
@@ -375,17 +319,9 @@ QD_EXPORT void qd_connection_manager_delete_listener(qd_dispatch_t *qd, void *im
375
319
{
376
320
qd_listener_t * li = (qd_listener_t * ) impl ;
377
321
if (li ) {
378
- if (li -> pn_listener ) {
379
- pn_listener_close (li -> pn_listener );
380
- }
381
- else if (li -> http ) {
382
- qd_lws_listener_close (li -> http );
383
- }
384
-
385
- log_config (& li -> config , "Listener" , false);
386
-
387
322
DEQ_REMOVE (qd -> connection_manager -> listeners , li );
388
- qd_listener_decref (li );
323
+ log_config (& li -> config , "Listener" , false);
324
+ qd_listener_delete (li , false); // false == do a clean listener close
389
325
}
390
326
}
391
327
0 commit comments