Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Oct 2011 10:16:32 -0700
From:      Artem Belevich <art@freebsd.org>
To:        =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= <des@des.no>
Cc:        hackers@freebsd.org, =?ISO-8859-1?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no>
Subject:   Re: Does anyone use nscd?
Message-ID:  <CAFqOu6iw12BbvmS9NH3fNzWqQR1YvYrqyM6JFrYDfs2=HQ3w_w@mail.gmail.com>
In-Reply-To: <86obxw4s4w.fsf@ds4.des.no>
References:  <86sjn84wco.fsf@ds4.des.no> <alpine.BSF.2.00.1110041800290.18373@mail.fig.ol.no> <86obxw4s4w.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
2011/10/4 Dag-Erling Sm=F8rgrav <des@des.no>:
> Trond Endrest=F8l <Trond.Endrestol@fagskolen.gjovik.no> writes:
>> It's in daily use at Gj=F8vik Technical College (Fagskolen i Gj=F8vik),
>> here in Norway. Both the mail and web servers authenticates our users
>> by LDAP, and nscd certainly speeds up the lookups.
>
> OK. =A0No trouble with clients dying of SIGPIPE? =A0I could never reprodu=
ce
> the bug, but both users who reported problems used ldap, and I don't
> have an LDAP server to test against, so I thought it might be specific
> to LDAP.

I do use nscd at work where we have fairly large NIS database.

And I do have a way to reproduce the SIGPIPE problem. Populate ~30K
entries in NIS passwd database, enable nscd and then run top. In my
case top used to die with SIGPIPE pretty reliably. I've fixed the
issue locally by setting SO_NOSIGPIPE on the socket in
__open_cached_connection() in lib/libc/net/nscachedcli.c and I've been
running with the fix for few months now.

--Artem

diff --git a/lib/libc/net/nscachedcli.c b/lib/libc/net/nscachedcli.c
index 1323805..cd941db 100644
--- a/lib/libc/net/nscachedcli.c
+++ b/lib/libc/net/nscachedcli.c
@@ -196,6 +196,7 @@ __open_cached_connection(struct
cached_connection_params const *params)
        struct sockaddr_un client_address;
        int client_address_len, client_socket;
        int res;
+       int on =3D 1;

        assert(params !=3D NULL);

@@ -214,6 +215,8 @@ __open_cached_connection(struct
cached_connection_params const *params)
        }
        _fcntl(client_socket, F_SETFL, O_NONBLOCK);

+       _setsockopt(client_socket, SOL_SOCKET, SO_NOSIGPIPE, (void
*)&on, sizeof(on));
+
        retval =3D malloc(sizeof(struct cached_connection_));
        assert(retval !=3D NULL);
        memset(retval, 0, sizeof(struct cached_connection_));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFqOu6iw12BbvmS9NH3fNzWqQR1YvYrqyM6JFrYDfs2=HQ3w_w>