qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [2/3] qpid-proton git commit: PROTON-822: fixed finalizer ordering; fixed corner cases where circular refs were being held; initialize frame counters to zero
Date Wed, 18 Feb 2015 06:53:55 GMT
PROTON-822: fixed finalizer ordering; fixed corner cases where circular refs were being held;
initialize frame counters to zero


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7b81ca96
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7b81ca96
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7b81ca96

Branch: refs/heads/master
Commit: 7b81ca961c331c425e2a15dcb61a5c84d0cf319a
Parents: 7f6442c
Author: Rafael Schloming <rhs@alum.mit.edu>
Authored: Wed Feb 18 00:44:38 2015 -0500
Committer: Rafael Schloming <rhs@alum.mit.edu>
Committed: Wed Feb 18 00:45:09 2015 -0500

----------------------------------------------------------------------
 proton-c/src/engine/engine.c       | 23 +++++++++++++++++------
 proton-c/src/transport/transport.c | 10 +++++++---
 2 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7b81ca96/proton-c/src/engine/engine.c
----------------------------------------------------------------------
diff --git a/proton-c/src/engine/engine.c b/proton-c/src/engine/engine.c
index 09668c5..5e05cbc 100644
--- a/proton-c/src/engine/engine.c
+++ b/proton-c/src/engine/engine.c
@@ -222,6 +222,7 @@ void pn_remove_session(pn_connection_t *conn, pn_session_t *ssn)
 {
   if (pn_list_remove(conn->sessions, ssn)) {
     pn_ep_decref(&conn->endpoint);
+    LL_REMOVE(conn, endpoint, &ssn->endpoint);
   }
 }
 
@@ -252,8 +253,6 @@ void pn_session_free(pn_session_t *session)
   }
   pn_remove_session(session->connection, session);
   pn_list_add(session->connection->freed, session);
-  pn_endpoint_t *endpoint = (pn_endpoint_t *) session;
-  LL_REMOVE(pn_ep_get_connection(endpoint), endpoint, endpoint);
   session->endpoint.freed = true;
   pn_ep_decref(&session->endpoint);
 
@@ -292,6 +291,7 @@ void pn_remove_link(pn_session_t *ssn, pn_link_t *link)
 {
   if (pn_list_remove(ssn->links, link)) {
     pn_ep_decref(&ssn->endpoint);
+    LL_REMOVE(ssn->connection, endpoint, &link->endpoint);
   }
 }
 
@@ -328,10 +328,8 @@ void pn_terminus_free(pn_terminus_t *terminus)
 void pn_link_free(pn_link_t *link)
 {
   assert(!link->endpoint.freed);
-  pn_endpoint_t *endpoint = (pn_endpoint_t *) link;
   pn_remove_link(link->session, link);
   pn_list_add(link->session->freed, link);
-  LL_REMOVE(pn_ep_get_connection(endpoint), endpoint, endpoint);
   pn_delivery_t *delivery = link->unsettled_head;
   while (delivery) {
     pn_delivery_t *next = delivery->unsettled_next;
@@ -692,6 +690,10 @@ void pn_clear_tpwork(pn_delivery_t *delivery)
   {
     LL_REMOVE(connection, tpwork, delivery);
     delivery->tpwork = false;
+    if (pn_refcount(delivery) > 0) {
+      pn_incref(delivery);
+      pn_decref(delivery);
+    }
   }
 }
 
@@ -900,6 +902,13 @@ static void pn_session_finalize(void *object)
   pn_free(session->state.remote_handles);
   pn_remove_session(session->connection, session);
   pn_list_remove(session->connection->freed, session);
+
+  if (session->connection->transport) {
+    pn_transport_t *transport = session->connection->transport;
+    pn_hash_del(transport->local_channels, session->state.local_channel);
+    pn_hash_del(transport->remote_channels, session->state.remote_channel);
+  }
+
   if (endpoint->referenced) {
     pn_decref(session->connection);
   }
@@ -940,8 +949,8 @@ pn_session_t *pn_session(pn_connection_t *conn)
   ssn->state.remote_channel = (uint16_t)-1;
   pn_delivery_map_init(&ssn->state.incoming, 0);
   pn_delivery_map_init(&ssn->state.outgoing, 0);
-  ssn->state.local_handles = pn_hash(PN_OBJECT, 0, 0.75);
-  ssn->state.remote_handles = pn_hash(PN_OBJECT, 0, 0.75);
+  ssn->state.local_handles = pn_hash(PN_WEAKREF, 0, 0.75);
+  ssn->state.remote_handles = pn_hash(PN_WEAKREF, 0, 0.75);
   // end transport state
 
   pn_collector_put(conn->collector, PN_OBJECT, ssn, PN_SESSION_INIT);
@@ -1055,6 +1064,8 @@ static void pn_link_finalize(void *object)
   pn_free(link->name);
   pn_endpoint_tini(endpoint);
   pn_remove_link(link->session, link);
+  pn_hash_del(link->session->state.local_handles, link->state.local_handle);
+  pn_hash_del(link->session->state.remote_handles, link->state.remote_handle);
   pn_list_remove(link->session->freed, link);
   if (endpoint->referenced) {
     pn_decref(link->session);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7b81ca96/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index 593dbca..8b36389 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -44,7 +44,7 @@ static ssize_t transport_consume(pn_transport_t *transport);
 
 void pn_delivery_map_init(pn_delivery_map_t *db, pn_sequence_t next)
 {
-  db->deliveries = pn_hash(PN_OBJECT, 0, 0.75);
+  db->deliveries = pn_hash(PN_WEAKREF, 0, 0.75);
   db->next = next;
 }
 
@@ -341,6 +341,8 @@ static void pn_transport_initialize(void *object)
   transport->args = pn_data(16);
   transport->output_args = pn_data(16);
   transport->frame = pn_buffer(4*1024);
+  transport->input_frames_ct = 0;
+  transport->output_frames_ct = 0;
 
   transport->connection = NULL;
   transport->context = pn_record();
@@ -378,8 +380,8 @@ static void pn_transport_initialize(void *object)
   pn_condition_init(&transport->condition);
   transport->error = pn_error();
 
-  transport->local_channels = pn_hash(PN_OBJECT, 0, 0.75);
-  transport->remote_channels = pn_hash(PN_OBJECT, 0, 0.75);
+  transport->local_channels = pn_hash(PN_WEAKREF, 0, 0.75);
+  transport->remote_channels = pn_hash(PN_WEAKREF, 0, 0.75);
 
   transport->bytes_input = 0;
   transport->bytes_output = 0;
@@ -1257,6 +1259,8 @@ static void pn_full_settle(pn_delivery_map_t *db, pn_delivery_t *delivery)
   assert(!delivery->work);
   pn_clear_tpwork(delivery);
   pn_delivery_map_del(db, delivery);
+  pn_incref(delivery);
+  pn_decref(delivery);
 }
 
 int pn_do_transfer(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, pn_data_t
*args, const pn_bytes_t *payload)


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


Mime
View raw message