winbind: fix smbd hanging on Solaris when winbindd closes socket.
authorMichael Adam <obnox@samba.org>
Mon, 27 Oct 2008 13:28:44 +0000 (14:28 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 27 Oct 2008 14:07:24 +0000 (15:07 +0100)
On some versions of Solaris, we observed a strange effect of close(2)
on a socket: After the server (here winbindd) called close, the client fd
was not marked as readable for select. And a write call to the fd did
not produce an error EPIPE but just returned as if successful.

So while winbindd had called remove_client(), the corresponding smbd
still thought that it was connected, but failed to retrieve answers
for its queries.

This patch works around the problem by forcing the client fd to
the readable state: Just write one byte into the socket before
closing.

Michael

source/nsswitch/winbindd.c

index 54081abe57bfe8baf2067fa2bc9d325120e65928..48b94f20da34c4ecf96e466fba1efa8f2c4994cf 100644 (file)
@@ -669,12 +669,17 @@ static void new_connection(int listen_sock, BOOL privileged)
 
 static void remove_client(struct winbindd_cli_state *state)
 {
+       char c = 0;
+
        /* It's a dead client - hold a funeral */
        
        if (state == NULL) {
                return;
        }
-               
+
+       /* tell client, we are closing ... */
+       write(state->sock, &c, sizeof(c));
+
        /* Close socket */
                
        close(state->sock);