From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 4 17:16:34 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71C1D106564A for ; Tue, 4 Oct 2011 17:16:33 +0000 (UTC) (envelope-from artemb@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2FC158FC0A for ; Tue, 4 Oct 2011 17:16:32 +0000 (UTC) Received: by yxk36 with SMTP id 36so904404yxk.13 for ; Tue, 04 Oct 2011 10:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=yCRK7gWoAgb/g/JNXMFFqyoOogXiEKmgLFI69kahrWk=; b=CftdcA5Y3mkbYn0gCrMjfLopvHuheZuUU9n+4b9UNlX74PBC8m5qSvUo25eb+uHlRU fPai/kxZUrIbu/kgzCooazKT4zi6EsujCQQYaXJaZQ150j+jl3jRE+vaCp+AhWyVh2Un 5PdhfQwge1ALFGXZiU6YUKn2H4ugQrlBn5DmY= MIME-Version: 1.0 Received: by 10.236.175.164 with SMTP id z24mr7980126yhl.114.1317748592464; Tue, 04 Oct 2011 10:16:32 -0700 (PDT) Sender: artemb@gmail.com Received: by 10.236.103.33 with HTTP; Tue, 4 Oct 2011 10:16:32 -0700 (PDT) In-Reply-To: <86obxw4s4w.fsf@ds4.des.no> References: <86sjn84wco.fsf@ds4.des.no> <86obxw4s4w.fsf@ds4.des.no> Date: Tue, 4 Oct 2011 10:16:32 -0700 X-Google-Sender-Auth: OjhwZU8Axvd2gHj9GZ2TzB-mWTA Message-ID: From: Artem Belevich To: =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: hackers@freebsd.org, =?ISO-8859-1?Q?Trond_Endrest=F8l?= Subject: Re: Does anyone use nscd? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 17:16:34 -0000 2011/10/4 Dag-Erling Sm=F8rgrav : > Trond Endrest=F8l 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_));