From: Ralph Boehme Date: Thu, 24 Nov 2022 14:18:23 +0000 (+0100) Subject: winbindd: simplify cm_open_connection() X-Git-Tag: talloc-2.4.0~171 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7315c5f4a5dd08216885f4a7588f57753de6038d;p=thirdparty%2Fsamba.git winbindd: simplify cm_open_connection() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 73bc441fd59..761f808e3c6 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -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)) {