BUG 9436: Fix leaking sockets of SMB connections to a DC.
authorAndreas Schneider <asn@samba.org>
Wed, 28 Nov 2012 11:53:39 +0000 (12:53 +0100)
committerJim McDonough <jmcd@samba.org>
Wed, 28 Nov 2012 16:17:20 +0000 (17:17 +0100)
As this is a burst of 3 unbound sockets with each try to reach a DC
we're running out of file descriptors pretty fast. So winbind is then
mostly spinning in an accept loop failing with EMFILE.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jim McDonough <jmcd@samba.org>
Autobuild-User(master): Jim McDonough <jmcd@samba.org>
Autobuild-Date(master): Wed Nov 28 17:17:21 CET 2012 on sn-devel-104

source3/winbindd/winbindd_cm.c

index 79b5839d2a7f4f0d75142bed64ce3c927b102076..57027eb04db49cb12a10de772ec10987f8e1252e 100644 (file)
@@ -1598,6 +1598,10 @@ 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 */
+                       close(fd);
+               }
 
                if (!retry)
                        break;