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/10/19 19:56:31 UTC

[qpid-dispatch] branch dev-protocol-adaptors-2 updated: DISPATCH-1744: fix cleanup of outstanding requests

This is an automated email from the ASF dual-hosted git repository.

kgiusti pushed a commit to branch dev-protocol-adaptors-2
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/dev-protocol-adaptors-2 by this push:
     new a964332  DISPATCH-1744: fix cleanup of outstanding requests
a964332 is described below

commit a964332950285bc7530de02778e3c370ae068437
Author: Kenneth Giusti <kg...@apache.org>
AuthorDate: Mon Oct 19 14:46:26 2020 -0400

    DISPATCH-1744: fix cleanup of outstanding requests
---
 src/adaptors/http1/http1_adaptor.c | 25 +++++++------------------
 src/adaptors/http1/http1_client.c  |  7 +++----
 src/adaptors/http1/http1_private.h |  4 ++--
 src/adaptors/http1/http1_server.c  |  8 +++-----
 4 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/src/adaptors/http1/http1_adaptor.c b/src/adaptors/http1/http1_adaptor.c
index 4cdd44f..bb318f3 100644
--- a/src/adaptors/http1/http1_adaptor.c
+++ b/src/adaptors/http1/http1_adaptor.c
@@ -100,10 +100,13 @@ void qdr_http1_connection_free(qdr_http1_connection_t *hconn)
         }
         sys_mutex_unlock(qdr_http1_adaptor->lock);
 
-        // request expected to be clean up by caller
-#if 0  // JIRA ME!
-        assert(DEQ_IS_EMPTY(hconn->requests));
-#endif
+        // cleanup outstanding requests
+        //
+        if (hconn->type == HTTP1_CONN_SERVER)
+            qdr_http1_server_conn_cleanup(hconn);
+        else
+            qdr_http1_client_conn_cleanup(hconn);
+
         qd_timer_free(t1);
         qd_timer_free(t2);
 
@@ -112,20 +115,6 @@ void qdr_http1_connection_free(qdr_http1_connection_t *hconn)
             pn_raw_connection_set_context(rconn, 0);
             pn_raw_connection_close(rconn);
         }
-#if 0
-        if (hconn->out_link) {
-            qdr_link_set_context(hconn->out_link, 0);
-            qdr_link_detach(hconn->out_link, QD_CLOSED, 0);
-        }
-        if (hconn->in_link) {
-            qdr_link_set_context(hconn->in_link, 0);
-            qdr_link_detach(hconn->in_link, QD_CLOSED, 0);
-        }
-        if (hconn->qdr_conn) {
-            qdr_connection_set_context(hconn->qdr_conn, 0);
-            qdr_connection_closed(hconn->qdr_conn);
-        }
-#endif
 
         free(hconn->cfg.host);
         free(hconn->cfg.port);
diff --git a/src/adaptors/http1/http1_client.c b/src/adaptors/http1/http1_client.c
index 1976f84..0f508db 100644
--- a/src/adaptors/http1/http1_client.c
+++ b/src/adaptors/http1/http1_client.c
@@ -105,7 +105,6 @@ static void _client_request_complete_cb(h1_codec_request_state_t *lib_rs, bool c
 static void _handle_connection_events(pn_event_t *e, qd_server_t *qd_server, void *context);
 static void _client_response_msg_free(_client_request_t *req, _client_response_msg_t *rmsg);
 static void _client_request_free(_client_request_t *req);
-static void _client_connection_free(qdr_http1_connection_t *hconn);
 static void _write_pending_response(_client_request_t *req);
 
 
@@ -398,7 +397,7 @@ static void _handle_connection_events(pn_event_t *e, qd_server_t *qd_server, voi
             hconn->qdr_conn = 0;
         }
 
-        _client_connection_free(hconn);
+        qdr_http1_connection_free(hconn);
         return;  // hconn no longer valid
     }
     case PN_RAW_CONNECTION_NEED_WRITE_BUFFERS: {
@@ -1303,12 +1302,12 @@ static void _client_request_free(_client_request_t *hreq)
 }
 
 
-static void _client_connection_free(qdr_http1_connection_t *hconn)
+// release client-specific state
+void qdr_http1_client_conn_cleanup(qdr_http1_connection_t *hconn)
 {
     for (_client_request_t *hreq = (_client_request_t*) DEQ_HEAD(hconn->requests);
          hreq;
          hreq = (_client_request_t*) DEQ_HEAD(hconn->requests)) {
         _client_request_free(hreq);
     }
-    qdr_http1_connection_free(hconn);
 }
diff --git a/src/adaptors/http1/http1_private.h b/src/adaptors/http1/http1_private.h
index ce10362..fbc7b9e 100644
--- a/src/adaptors/http1/http1_private.h
+++ b/src/adaptors/http1/http1_private.h
@@ -243,7 +243,7 @@ void qdr_http1_client_core_delivery_update(qdr_http1_adaptor_t      *adaptor,
                                            qdr_delivery_t           *dlv,
                                            uint64_t                  disp,
                                            bool                      settled);
-
+void qdr_http1_client_conn_cleanup(qdr_http1_connection_t *hconn);
 
 // http1_server.c protocol adaptor callbacks
 //
@@ -262,5 +262,5 @@ void qdr_http1_server_core_delivery_update(qdr_http1_adaptor_t      *adaptor,
                                            qdr_delivery_t           *dlv,
                                            uint64_t                  disp,
                                            bool                      settled);
-
+void qdr_http1_server_conn_cleanup(qdr_http1_connection_t *hconn);
 #endif // http1_private_H
diff --git a/src/adaptors/http1/http1_server.c b/src/adaptors/http1/http1_server.c
index b3a17f2..c58ba1b 100644
--- a/src/adaptors/http1/http1_server.c
+++ b/src/adaptors/http1/http1_server.c
@@ -115,8 +115,7 @@ static void _handle_connection_events(pn_event_t *e, qd_server_t *qd_server, voi
 static void _do_reconnect(void *context);
 static void _do_activate(void *context);
 static void _server_response_msg_free(_server_request_t *req, _server_response_msg_t *rmsg);
-static void _server_request_free(_server_request_t *req);
-static void _server_connection_free(qdr_http1_connection_t *hconn);
+static void _server_request_free(_server_request_t *hreq);
 static void _write_pending_request(_server_request_t *req);
 static void _cancel_request(_server_request_t *req);
 
@@ -436,7 +435,7 @@ static void _handle_connection_events(pn_event_t *e, qd_server_t *qd_server, voi
             // re-establish it
             qd_log(log, QD_LOG_INFO, "[C%i] Connection closed", hconn->conn_id);
             hconn->raw_conn = 0;
-            _server_connection_free(hconn);
+            qdr_http1_connection_free(hconn);
             return;
         }
 
@@ -1407,14 +1406,13 @@ static void _write_pending_request(_server_request_t *hreq)
 }
 
 
-static void _server_connection_free(qdr_http1_connection_t *hconn)
+void qdr_http1_server_conn_cleanup(qdr_http1_connection_t *hconn)
 {
     for (_server_request_t *hreq = (_server_request_t*) DEQ_HEAD(hconn->requests);
          hreq;
          hreq = (_server_request_t*) DEQ_HEAD(hconn->requests)) {
         _server_request_free(hreq);
     }
-    qdr_http1_connection_free(hconn);
 }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org