Author: rhs Date: Thu Jun 19 17:22:27 2014 New Revision: 1603953 URL: http://svn.apache.org/r1603953 Log: added PN_{CONNECTION,SESSION,LINK}_FINAL events
Modified: qpid/proton/trunk/proton-c/include/proton/event.h qpid/proton/trunk/proton-c/src/engine/engine-internal.h qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c qpid/proton/trunk/proton-c/src/messenger/messenger.c Modified: qpid/proton/trunk/proton-c/include/proton/event.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/event.h?rev=1603953&r1=1603952&r2=1603953&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/event.h (original) +++ qpid/proton/trunk/proton-c/include/proton/event.h Thu Jun 19 17:22:27 2014 @@ -132,7 +132,29 @@ typedef enum { * type point to the relevant transport as well as its associated * connection. */ - PN_TRANSPORT = PN_EVENT_CATEGORY_PROTOCOL+9 + PN_TRANSPORT = PN_EVENT_CATEGORY_PROTOCOL+9, + + /** + * The connection has been freed and any outstanding processing has + * been completed. This is the final event that will ever be issued + * for a connection. + */ + PN_CONNECTION_FINAL = PN_EVENT_CATEGORY_PROTOCOL+10, + + /** + * The session has been freed and any outstanding processing has + * been completed. This is the final event that will ever be issued + * for a session. + */ + PN_SESSION_FINAL = PN_EVENT_CATEGORY_PROTOCOL+11, + + /** + * The link has been freed and any outstanding processing has been + * completed. This is the final event that will ever be issued for a + * link. + */ + PN_LINK_FINAL = PN_EVENT_CATEGORY_PROTOCOL+12 + } pn_event_type_t; /** Modified: qpid/proton/trunk/proton-c/src/engine/engine-internal.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine-internal.h?rev=1603953&r1=1603952&r2=1603953&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/engine/engine-internal.h (original) +++ qpid/proton/trunk/proton-c/src/engine/engine-internal.h Thu Jun 19 17:22:27 2014 @@ -51,6 +51,7 @@ struct pn_endpoint_t { pn_endpoint_t *transport_prev; bool modified; bool freed; + bool posted_final; }; typedef struct { Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603953&r1=1603952&r2=1603953&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:22:27 2014 @@ -348,6 +348,7 @@ void pn_endpoint_init(pn_endpoint_t *end endpoint->transport_prev = NULL; endpoint->modified = false; endpoint->freed = false; + endpoint->posted_final = false; LL_ADD(conn, endpoint, endpoint); } @@ -359,16 +360,39 @@ void pn_endpoint_tini(pn_endpoint_t *end pn_condition_tini(&endpoint->condition); } +#include "event.h" + +static bool pni_post_final(pn_endpoint_t *endpoint, pn_event_type_t type) +{ + pn_connection_t *conn = pn_ep_get_connection(endpoint); + if (!endpoint->posted_final) { + endpoint->posted_final = true; + pn_event_t *event = pn_collector_put(conn->collector, type); + if (event) { + pn_event_init(event, endpoint); + return true; + } + } + + return false; +} + static void pn_connection_finalize(void *object) { pn_connection_t *conn = (pn_connection_t *) object; + + pn_endpoint_t *endpoint = &conn->endpoint; + if (pni_post_final(endpoint, PN_CONNECTION_FINAL)) { + return; + } + pn_free(conn->sessions); pn_free(conn->container); pn_free(conn->hostname); pn_free(conn->offered_capabilities); pn_free(conn->desired_capabilities); pn_free(conn->properties); - pn_endpoint_tini(&conn->endpoint); + pn_endpoint_tini(endpoint); } #define pn_connection_initialize NULL @@ -376,8 +400,6 @@ static void pn_connection_finalize(void #define pn_connection_compare NULL #define pn_connection_inspect NULL -#include "event.h" - pn_connection_t *pn_connection() { static const pn_class_t clazz = PN_CLASS(pn_connection); @@ -687,6 +709,7 @@ pn_link_t *pn_link_next(pn_link_t *link, static void pn_session_finalize(void *object) { pn_session_t *session = (pn_session_t *) object; + pn_endpoint_t *endpoint = &session->endpoint; //pn_transport_t *transport = session->connection->transport; //if (transport) { /* if ((int16_t)session->state.local_channel >= 0) // END not sent */ @@ -695,8 +718,12 @@ static void pn_session_finalize(void *ob /* pn_unmap_channel(transport, session); */ /* } */ + if (pni_post_final(endpoint, PN_SESSION_FINAL)) { + return; + } + pn_free(session->links); - pn_endpoint_tini(&session->endpoint); + pn_endpoint_tini(endpoint); pn_delivery_map_free(&session->state.incoming); pn_delivery_map_free(&session->state.outgoing); pn_free(session->state.local_handles); @@ -792,17 +819,22 @@ void pn_terminus_init(pn_terminus_t *ter static void pn_link_finalize(void *object) { pn_link_t *link = (pn_link_t *) object; + pn_endpoint_t *endpoint = &link->endpoint; // assumptions: all deliveries freed assert(link->settled_head == NULL); assert(link->unsettled_head == NULL); + if (pni_post_final(endpoint, PN_LINK_FINAL)) { + return; + } + pn_terminus_free(&link->source); pn_terminus_free(&link->target); pn_terminus_free(&link->remote_source); pn_terminus_free(&link->remote_target); pn_free(link->name); - pn_endpoint_tini(&link->endpoint); + pn_endpoint_tini(endpoint); pn_decref(link->session); } Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1603953&r1=1603952&r2=1603953&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/engine/event.c (original) +++ qpid/proton/trunk/proton-c/src/engine/event.c Thu Jun 19 17:22:27 2014 @@ -202,6 +202,7 @@ pn_connection_t *pn_event_connection(pn_ switch (pn_event_type(event)) { case PN_CONNECTION_REMOTE_STATE: case PN_CONNECTION_LOCAL_STATE: + case PN_CONNECTION_FINAL: return (pn_connection_t *)event->context; case PN_TRANSPORT: transport = pn_event_transport(event); @@ -222,6 +223,7 @@ pn_session_t *pn_event_session(pn_event_ switch (pn_event_type(event)) { case PN_SESSION_REMOTE_STATE: case PN_SESSION_LOCAL_STATE: + case PN_SESSION_FINAL: return (pn_session_t *)event->context; default: link = pn_event_link(event); @@ -238,6 +240,7 @@ pn_link_t *pn_event_link(pn_event_t *eve case PN_LINK_REMOTE_STATE: case PN_LINK_LOCAL_STATE: case PN_LINK_FLOW: + case PN_LINK_FINAL: return (pn_link_t *)event->context; default: dlv = pn_event_delivery(event); @@ -273,16 +276,22 @@ const char *pn_event_type_name(pn_event_ return "PN_CONNECTION_REMOTE_STATE"; case PN_CONNECTION_LOCAL_STATE: return "PN_CONNECTION_LOCAL_STATE"; + case PN_CONNECTION_FINAL: + return "PN_CONNECTION_FINAL"; case PN_SESSION_REMOTE_STATE: return "PN_SESSION_REMOTE_STATE"; case PN_SESSION_LOCAL_STATE: return "PN_SESSION_LOCAL_STATE"; + case PN_SESSION_FINAL: + return "PN_SESSION_FINAL"; case PN_LINK_REMOTE_STATE: return "PN_LINK_REMOTE_STATE"; case PN_LINK_LOCAL_STATE: return "PN_LINK_LOCAL_STATE"; case PN_LINK_FLOW: return "PN_LINK_FLOW"; + case PN_LINK_FINAL: + return "PN_LINK_FINAL"; case PN_DELIVERY: return "PN_DELIVERY"; case PN_TRANSPORT: Modified: qpid/proton/trunk/proton-c/src/messenger/messenger.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger/messenger.c?rev=1603953&r1=1603952&r2=1603953&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/messenger/messenger.c (original) +++ qpid/proton/trunk/proton-c/src/messenger/messenger.c Thu Jun 19 17:22:27 2014 @@ -1247,6 +1247,12 @@ int pn_messenger_process_events(pn_messe break; case PN_EVENT_NONE: break; + case PN_CONNECTION_FINAL: + break; + case PN_SESSION_FINAL: + break; + case PN_LINK_FINAL: + break; } pn_collector_pop(messenger->collector); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org