]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbindd: simplify cm_open_connection()
authorRalph Boehme <slow@samba.org>
Thu, 24 Nov 2022 14:18:23 +0000 (15:18 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 21 Dec 2022 19:10:35 +0000 (19:10 +0000)
Simplify to retry logic: if cm_prepare_connection() succeeded just exit the
retry loop, only if it failed check the "retry" variable.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_cm.c

index 73bc441fd59299c83268d2dfeaa774a4a7a55ce8..761f808e3c61933519c99b698d05171e058a15cd 100644 (file)
@@ -1712,16 +1712,14 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
 
                result = cm_prepare_connection(domain, fd, domain->dcname,
                        &new_conn->cli, &retry);
-               if (!NT_STATUS_IS_OK(result)) {
-                       /* Don't leak the smb connection socket */
-                       if (fd != -1) {
-                               close(fd);
-                               fd = -1;
-                       }
+               if (NT_STATUS_IS_OK(result)) {
+                       break;
                }
-
-               if (!retry)
+               close(fd);
+               fd = -1;
+               if (!retry) {
                        break;
+               }
        }
 
        if (!NT_STATUS_IS_OK(result)) {