Skip to content

Commit af70e0a

Browse files
committed
fixup: add log on denial of incoming client connection
1 parent d5dd725 commit af70e0a

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/adaptors/adaptor_listener.c

+25-16
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,31 @@ static void _listener_event_handler(pn_event_t *e, qd_server_t *qd_server, void
140140
break;
141141
}
142142

143-
case PN_LISTENER_ACCEPT:
144-
// Log incoming client connections at DEBUG level since these can flood the router logs.
145-
qd_log(log_module, QD_LOG_DEBUG, "Listener %s: new incoming client connection to %s", li->name,
146-
li->host_port);
147-
148-
// block qd_adapter_listener_close() from returning during the accept call:
149-
sys_mutex_lock(&li->lock);
150-
if (li->on_accept)
151-
li->on_accept(li, pn_event_listener(e), li->user_context);
152-
else {
153-
// The adaptor_listener is closing but a connection attempt arrived before the
154-
// cleanup is complete. Deny the connection attempt.
155-
qd_adaptor_listener_deny_conn(li, pn_event_listener(e));
156-
}
157-
sys_mutex_unlock(&li->lock);
158-
break;
143+
case PN_LISTENER_ACCEPT: {
144+
bool denied = false;
145+
146+
// Log incoming client connections at DEBUG level since these can flood the router logs.
147+
qd_log(log_module, QD_LOG_DEBUG, "Listener %s: new incoming client connection to %s", li->name,
148+
li->host_port);
149+
150+
// block qd_adapter_listener_close() from returning during the accept call:
151+
sys_mutex_lock(&li->lock);
152+
if (li->on_accept)
153+
li->on_accept(li, pn_event_listener(e), li->user_context);
154+
else {
155+
// The adaptor_listener is closing but a connection attempt arrived before the
156+
// cleanup is complete. Deny the connection attempt.
157+
qd_adaptor_listener_deny_conn(li, pn_event_listener(e));
158+
denied = true;
159+
}
160+
sys_mutex_unlock(&li->lock);
161+
162+
if (denied)
163+
qd_log(log_module, QD_LOG_DEBUG,
164+
"Listener %s: denied new incoming client connection to %s: service not available",
165+
li->name, li->host_port);
166+
break;
167+
}
159168

160169
case PN_LISTENER_CLOSE: {
161170
pn_condition_t *cond = pn_listener_condition(pn_event_listener(e));

0 commit comments

Comments
 (0)