[SCM] Samba Shared Repository - branch master updated - b881d2ee78f685aea7ae8b67b3e0fb3c4f5205ed

Derrell Lipman derrell.lipman at unwireduniverse.com
Mon Oct 27 14:07:16 GMT 2008


On Mon, Oct 27, 2008 at 9:58 AM, Michael Adam <obnox at samba.org> wrote:

> The branch, master has been updated
>       via  b881d2ee78f685aea7ae8b67b3e0fb3c4f5205ed (commit)
>      from  68aa9bd67f9556f608bfb321d593617bd346915f (commit)
>
> http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
>
>
> - Log -----------------------------------------------------------------
> commit b881d2ee78f685aea7ae8b67b3e0fb3c4f5205ed
> Author: Michael Adam <obnox at samba.org>
> Date:   Mon Oct 27 14:28:44 2008 +0100
>
>    [s3]winbind: fix smbd hanging on Solaris when winbindd closes socket.
>
>    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
>
> -----------------------------------------------------------------------
>
> Summary of changes:
>  source3/winbindd/winbindd.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
>
> Changeset truncated at 500 lines:
>
> diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
> index 5d4f21a..ac2a87f 100644
> --- a/source3/winbindd/winbindd.c
> +++ b/source3/winbindd/winbindd.c
> @@ -727,12 +727,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);


Michael, although this should help in the majority of cases, it looks like
it still leaves a race condition where you write the single byte, the peer
reads that byte so the socket is no longer in a readable state, you then
close the socket, and the original problem occurs.  I wonder if there is
some ioctl you can issue here that will force the peer into readable state
upon close...???

Derrell


More information about the samba-cvs mailing list