From d244415d1e4428aa39cc25082b7f691b461afb22 Mon Sep 17 00:00:00 2001 From: Peter Somogyi Date: Mon, 23 Apr 2007 12:45:14 +0200 Subject: [PATCH] fixed ctdb/ib bug at reject event reverted my suggestion in debug.c (based on my false error detection) (This used to be ctdb commit 5c52c9f37639c65b551c10d1706c49653cd99742) --- ctdb/ib/ibwrapper.c | 36 +++++++++++++++++++++--------------- ctdb/lib/util/debug.c | 4 ++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ctdb/ib/ibwrapper.c b/ctdb/ib/ibwrapper.c index 908d38d5840..5aa2ca9c3c9 100644 --- a/ctdb/ib/ibwrapper.c +++ b/ctdb/ib/ibwrapper.c @@ -428,6 +428,7 @@ static void ibw_event_handler_cm(struct event_context *ev, rc = rdma_get_cm_event(pctx->cm_channel, &event); if (rc) { ctx->state = IBWS_ERROR; + event = NULL; sprintf(ibw_lasterr, "rdma_get_cm_event error %d\n", rc); goto error; } @@ -520,9 +521,10 @@ static void ibw_event_handler_cm(struct event_context *ev, if (conn) { if ((rc=rdma_ack_cm_event(event))) DEBUG(0, ("reject/rdma_ack_cm_event failed with %d\n", rc)); - event = NULL; - pconn = talloc_get_type(conn->internal, struct ibw_conn_priv); - ibw_conn_priv_destruct(pconn); + event = NULL; /* not to touch cma_id or conn */ + conn->state = IBWC_ERROR; + /* it should free the conn */ + pctx->connstate_func(NULL, conn); } goto error; @@ -556,22 +558,26 @@ static void ibw_event_handler_cm(struct event_context *ev, return; error: - if (event!=NULL && (rc=rdma_ack_cm_event(event))) { - DEBUG(0, ("rdma_ack_cm_event failed with %d\n", rc)); - } - DEBUG(0, ("cm event handler: %s", ibw_lasterr)); - if (cma_id!=pctx->cm_id) { - conn = talloc_get_type(cma_id->context, struct ibw_conn); - if (conn) { - conn->state = IBWC_ERROR; - pctx->connstate_func(NULL, conn); + if (event!=NULL) { + if (cma_id!=NULL && cma_id!=pctx->cm_id) { + conn = talloc_get_type(cma_id->context, struct ibw_conn); + if (conn) { + conn->state = IBWC_ERROR; + pctx->connstate_func(NULL, conn); + } + } else { + ctx->state = IBWS_ERROR; + pctx->connstate_func(ctx, NULL); + } + + if ((rc=rdma_ack_cm_event(event))!=0) { + DEBUG(0, ("rdma_ack_cm_event failed with %d\n", rc)); } - } else { - ctx->state = IBWS_ERROR; - pctx->connstate_func(ctx, NULL); } + + return; } static void ibw_event_handler_verbs(struct event_context *ev, diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c index c9c69749644..a048ed807ed 100644 --- a/ctdb/lib/util/debug.c +++ b/ctdb/lib/util/debug.c @@ -30,12 +30,12 @@ void do_debug(const char *format, ...) char *s = NULL; va_start(ap, format); - s = talloc_vasprintf(NULL, format, ap); + vasprintf(&s, format, ap); va_end(ap); gettimeofday(&tm, NULL); printf("%-8.8d.%-6.6d [%d]: %s", (int)tm.tv_sec, (int)tm.tv_usec, (int)getpid(), s); fflush(stdout); - talloc_free(s); + free(s); }