From 05799e60fce24f957f4597af249eadff38ed42f4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 14 May 2003 21:28:54 +0000 Subject: Ok, try and fix this correctly... Simplify the nasty loop logic. Jeremy. (This used to be commit c19599a5624ac7ea63b529bf7d36cdcd7c8ef89f) --- source3/nsswitch/winbindd_cm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c index 90df5019d4..05ea317d18 100644 --- a/source3/nsswitch/winbindd_cm.c +++ b/source3/nsswitch/winbindd_cm.c @@ -446,25 +446,25 @@ static BOOL connection_ok(struct winbindd_cm_conn *conn) static void find_cm_connection(const char *domain, const char *pipe_name, struct winbindd_cm_conn **conn_out) { - struct winbindd_cm_conn *conn, conn_temp; - - *conn_out = NULL; + struct winbindd_cm_conn *conn; - for (conn = cm_conns; conn; conn = conn->next) { + for (conn = cm_conns; conn; ) { if (strequal(conn->domain, domain) && strequal(conn->pipe_name, pipe_name)) { if (!connection_ok(conn)) { + /* Dead connection - remove it. */ + struct winbindd_cm_conn *conn_temp = conn->next; if (conn->cli) cli_shutdown(conn->cli); - ZERO_STRUCT(conn_temp); - conn_temp.next = conn->next; DLIST_REMOVE(cm_conns, conn); SAFE_FREE(conn); - conn = &conn_temp; /* Just to keep the loop moving */ + conn = conn_temp; /* Keep the loop moving */ + continue; } else { break; } } + conn = conn->next; } *conn_out = conn; -- cgit