libwbclient: Fix a fd-leak at dlclose-time
authorVolker Lendecke <vl@samba.org>
Mon, 10 May 2010 10:05:01 +0000 (12:05 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 10 May 2010 10:11:20 +0000 (12:11 +0200)
__attribute__((destructor)) makes winbind_close_sock() being called at
dlclose() time.

Found while testing apache on Linux with mod_auth_pam.

Other platforms will have to find a different fix. One possibility would be to
always close the socket after each operation, but this badly sucks
performance-wise.

nsswitch/wb_common.c

index f989d194e1d008445a4d2826617270eb96fd3d9e..f27c68880b4a7d579b29f9b21123028a61185acc 100644 (file)
@@ -62,6 +62,9 @@ static void init_response(struct winbindd_response *response)
 
 /* Close established socket */
 
+#if HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR
+__attribute__((destructor))
+#endif
 static void winbind_close_sock(void)
 {
        if (winbindd_fd != -1) {