From owner-freebsd-current@FreeBSD.ORG Tue Sep 30 03:41:16 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF25695B for ; Tue, 30 Sep 2014 03:41:16 +0000 (UTC) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 695A69F for ; Tue, 30 Sep 2014 03:41:15 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XYoJF-0008QG-4F for freebsd-current@freebsd.org; Tue, 30 Sep 2014 05:41:05 +0200 Received: from 97-96-57-7.res.bhn.net ([97.96.57.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 30 Sep 2014 05:41:05 +0200 Received: from dpejesh by 97-96-57-7.res.bhn.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 30 Sep 2014 05:41:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-current@freebsd.org From: David Shane Holden Subject: [PATCH] nscd Date: Mon, 29 Sep 2014 23:40:52 -0400 Lines: 62 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010309000609020107080506" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 97-96-57-7.res.bhn.net User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2014 03:41:16 -0000 This is a multi-part message in MIME format. --------------010309000609020107080506 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit So, I've noticed nscd hasn't worked right for awhile now. Since I upgraded to 10.0 it never seemed to cache properly but I never bothered to really dig into it until recently and here's what I've found. In my environment I have nsswitch set to use caching and LDAP as such: group: files cache ldap passwd: files cache ldap The LDAP part works fine, but caching didn't on 10.0 for some reason. On my 9.2 machines it works as expected though. What I've found is in usr.sbin/nscd/query.c struct query_state * init_query_state(int sockfd, size_t kevent_watermark, uid_t euid, gid_t egid) { ... memcpy(&retval->timeout, &s_configuration->query_timeout, sizeof(struct timeval)); ... } s_configuration->query_timeout is an 'int' which is being memcpy'd into a 'struct timeval' causing it to grab other parts of the s_configuration struct along with the query_timeout value and polluting retval->timeout. In this case it appears to be grabbing s_configuration->threads_num and shoving that into timeout.tv_sec along with the query_timeout. This ends up confusing nscd later on (instead of being 8 it ends up being set to 34359738376) and breaks it's ability to cache. I've attached a patch to set the retval->timeout properly and gets nscd working again. I'm guessing gcc was handling this differently from clang which is why it wasn't a problem before 10.0. --------------010309000609020107080506 Content-Type: text/x-patch; name="nscd.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="nscd.patch" diff --git a/usr.sbin/nscd/query.c b/usr.sbin/nscd/query.c index c233e19..abd8fab 100644 --- a/usr.sbin/nscd/query.c +++ b/usr.sbin/nscd/query.c @@ -1253,8 +1253,8 @@ init_query_state(int sockfd, size_t kevent_watermark, uid_t euid, gid_t egid) retval->read_func = query_socket_read; get_time_func(&retval->creation_time); - memcpy(&retval->timeout, &s_configuration->query_timeout, - sizeof(struct timeval)); + retval->timeout.tv_usec = 0; + retval->timeout.tv_sec = s_configuration->query_timeout; TRACE_OUT(init_query_state); return (retval); --------------010309000609020107080506--