You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2020/03/12 20:14:24 UTC
[qpid-dispatch] branch master updated: DISPATCH-1597: release the
qd_connection in libwebsockets on transport close
This is an automated email from the ASF dual-hosted git repository.
kgiusti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new 428d4e2 DISPATCH-1597: release the qd_connection in libwebsockets on transport close
428d4e2 is described below
commit 428d4e2c64adce29d1d9d4c472db918e064d65e8
Author: Kenneth Giusti <kg...@apache.org>
AuthorDate: Thu Mar 12 14:23:17 2020 -0400
DISPATCH-1597: release the qd_connection in libwebsockets on transport close
---
src/http-libwebsockets.c | 4 +++-
src/server.c | 8 +++++++-
src/server_private.h | 2 +-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/http-libwebsockets.c b/src/http-libwebsockets.c
index f47b556..d1ba7f9 100644
--- a/src/http-libwebsockets.c
+++ b/src/http-libwebsockets.c
@@ -178,7 +178,9 @@ static int handle_events(connection_t* c) {
}
pn_event_t *e;
while ((e = pn_connection_driver_next_event(&c->driver))) {
- qd_connection_handle(c->qd_conn, e);
+ if (!qd_connection_handle(c->qd_conn, e)) {
+ c->qd_conn = 0; // connection closed
+ }
}
if (pn_connection_driver_write_buffer(&c->driver).size) {
lws_callback_on_writable(c->wsi);
diff --git a/src/server.c b/src/server.c
index ae1d886..0e62aa8 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1642,10 +1642,16 @@ const char* qd_connection_remote_ip(const qd_connection_t *c) {
}
/* Expose event handling for HTTP connections */
-void qd_connection_handle(qd_connection_t *c, pn_event_t *e) {
+bool qd_connection_handle(qd_connection_t *c, pn_event_t *e) {
pn_connection_t *pn_conn = pn_event_connection(e);
qd_connection_t *qd_conn = !!pn_conn ? (qd_connection_t*) pn_connection_get_context(pn_conn) : 0;
handle(c->server, e, pn_conn, qd_conn);
+ if (qd_conn && pn_event_type(e) == PN_TRANSPORT_CLOSED) {
+ pn_connection_set_context(pn_conn, NULL);
+ qd_connection_free(qd_conn);
+ return false;
+ }
+ return true;
}
bool qd_connection_strip_annotations_in(const qd_connection_t *c) {
diff --git a/src/server_private.h b/src/server_private.h
index 4176429..7a81b8f 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -43,7 +43,7 @@ qd_connection_t *qd_server_connection(qd_server_t *server, qd_server_config_t* c
qd_connector_t* qd_connection_connector(const qd_connection_t *c);
-void qd_connection_handle(qd_connection_t *c, pn_event_t *e);
+bool qd_connection_handle(qd_connection_t *c, pn_event_t *e);
const qd_server_config_t *qd_connector_config(const qd_connector_t *c);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org