diff --git a/ctdb/ib/ibwrapper.c b/ctdb/ib/ibwrapper.c index 9778b4e0419..338afb1096d 100644 --- a/ctdb/ib/ibwrapper.c +++ b/ctdb/ib/ibwrapper.c @@ -37,7 +37,7 @@ #include "lib/events/events.h" #include "ibwrapper_internal.h" - +#include "lib/util/dlinklist.h" #define IBW_LASTERR_BUFSIZE 512 static char ibw_lasterr[IBW_LASTERR_BUFSIZE]; @@ -93,23 +93,7 @@ static int ibw_conn_destruct(void *ptr) ctx = ibw_conn->ctx; assert(ctx!=NULL); - /* unhook conn from ctx's linked list */ - assert(ctx->first_conn!=NULL); - assert(ctx->last_conn!=NULL); - - if (conn->prev==NULL) { - assert(ctx->first_conn==conn); - ctx->first_conn = conn->next; - } else { - conn->prev->next = conn->next; - } - - if (conn->next==NULL) { - assert(ctx->last_conn==conn); - ctx->last_conn = conn->prev; - } else { - conn->next->prev = conn->prev; - } + DLIST_REMOVE(ctx->conn_list, conn); return 0; } @@ -128,15 +112,7 @@ static ibw_conn *ibw_new_conn(ibw_ctx *ctx) conn->ctx = ctx; - /* append conn to the end of ctx's linked list */ - conn->prev = ctx->last_conn; - conn->next = NULL; - if (ctx->first_conn) { - assert(ctx->last_conn!=NULL); - conn->prev->next = conn; - } else { - ctx->first_conn = ctx->last_conn = conn; - } + DLIST_ADD(ctx->conn_list, conn); return conn; } diff --git a/ctdb/ib/ibwrapper.h b/ctdb/ib/ibwrapper.h index c5ca0272cc9..6f646a4a08e 100644 --- a/ctdb/ib/ibwrapper.h +++ b/ctdb/ib/ibwrapper.h @@ -38,7 +38,7 @@ typedef struct _ibw_ctx { ibw_state_ctx state; void *internal; - ibw_conn *first_conn, *last_conn; + ibw_conn *conn_list; /* 1st elem of double linked list */ } ibw_ctx; typedef enum {