DISPATCH-739: Delay free of query object till after all uses
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/ef478007 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/ef478007 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/ef478007 Branch: refs/heads/master Commit: ef4780071d0621253f324b49600d4e53b529a9f1 Parents: 77aea8e Author: Alan Conway <[email protected]> Authored: Thu Apr 20 07:54:28 2017 -0400 Committer: Alan Conway <[email protected]> Committed: Thu Apr 20 10:03:47 2017 -0400 ---------------------------------------------------------------------- src/router_core/management_agent.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ef478007/src/router_core/management_agent.c ---------------------------------------------------------------------- diff --git a/src/router_core/management_agent.c b/src/router_core/management_agent.c index 4fb955c..aa58dbf 100644 --- a/src/router_core/management_agent.c +++ b/src/router_core/management_agent.c @@ -156,19 +156,22 @@ static void qd_set_properties(qd_message_t *msg, static void qd_manage_response_handler(void *context, const qd_amqp_error_t *status, bool more) { qd_management_context_t *ctx = (qd_management_context_t*) context; - + bool need_free = false; if (ctx->operation_type == QD_ROUTER_OPERATION_QUERY) { if (status->status / 100 == 2) { // There is no error, proceed to conditionally call get_next if (more) { - ctx->current_count++; // Increment how many you have at hand - if (ctx->count != ctx->current_count) { - qdr_query_get_next(ctx->query); - return; - } else - // - // This is the one case where the core agent won't free the query itself. - // - qdr_query_free(ctx->query); + ctx->current_count++; // Increment how many you have at hand + if (ctx->count != ctx->current_count) { + qdr_query_get_next(ctx->query); + return; + } else { + // + // This is one case where the core agent won't free the query itself. + // Don't free immediately as we need status below and it may belong + // to the query. + // + need_free = true; + } } } qd_compose_end_list(ctx->field); @@ -211,6 +214,9 @@ static void qd_manage_response_handler(void *context, const qd_amqp_error_t *sta qd_message_free(ctx->source); qd_compose_free(ctx->field); + if (need_free) { + qdr_query_free(ctx->query); + } free_qd_management_context_t(ctx); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
