From owner-svn-src-head@freebsd.org Tue Oct 13 02:34:43 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31339A1010A; Tue, 13 Oct 2015 02:34:43 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E077C152D; Tue, 13 Oct 2015 02:34:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9D2Yfwm034411; Tue, 13 Oct 2015 02:34:41 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9D2Yf1a034409; Tue, 13 Oct 2015 02:34:41 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201510130234.t9D2Yf1a034409@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 13 Oct 2015 02:34:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289204 - head/sbin/casperd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2015 02:34:43 -0000 Author: adrian Date: Tue Oct 13 02:34:41 2015 New Revision: 289204 URL: https://svnweb.freebsd.org/changeset/base/289204 Log: casperd: bump default socket queue length to SOMAXCONN; make length configurable. The current default listen queue for casperd is too small (8) and hard-coded. This patch increases the default to SOMAXCONN, and introduces a command line flag that can used to further increase or decrease the queue length. PR: bin/202147 Submitted by: Modified: head/sbin/casperd/casperd.8 head/sbin/casperd/casperd.c Modified: head/sbin/casperd/casperd.8 ============================================================================== --- head/sbin/casperd/casperd.8 Tue Oct 13 02:32:15 2015 (r289203) +++ head/sbin/casperd/casperd.8 Tue Oct 13 02:34:41 2015 (r289204) @@ -35,8 +35,8 @@ .Nd "Capability Services friendly daemon" .Sh SYNOPSIS .Nm -[-Fhv] [-D servconfdir] [-P pidfile] [-S sockpath] .Op Fl Fhv +.Op Fl l Ar listenqueue .Op Fl D Ar servconfdir .Op Fl P Ar pidfile .Op Fl S Ar sockpath @@ -74,6 +74,12 @@ starts in the background. Print the .Nm usage message. +.It Fl l Ar listenqueue +Specify depth of socket listen queue for the +.Nm +daemon. +The default queue length is +.Pa SOMAXCONN . .It Fl P Ar pidfile Specify alternative location of a file where main process PID will be stored. Modified: head/sbin/casperd/casperd.c ============================================================================== --- head/sbin/casperd/casperd.c Tue Oct 13 02:32:15 2015 (r289203) +++ head/sbin/casperd/casperd.c Tue Oct 13 02:34:41 2015 (r289204) @@ -534,7 +534,7 @@ casper_accept(int lsock) } static void -main_loop(const char *sockpath, struct pidfh *pfh) +main_loop(int lqlen, const char *sockpath, struct pidfh *pfh) { fd_set fds; struct sockaddr_un sun; @@ -559,7 +559,7 @@ main_loop(const char *sockpath, struct p if (bind(lsock, (struct sockaddr *)&sun, sizeof(sun)) == -1) pjdlog_exit(1, "Unable to bind to %s", sockpath); (void)umask(oldumask); - if (listen(lsock, 8) == -1) + if (listen(lsock, lqlen) == -1) pjdlog_exit(1, "Unable to listen on %s", sockpath); for (;;) { @@ -627,18 +627,19 @@ main(int argc, char *argv[]) struct pidfh *pfh; const char *pidfile, *servconfdir, *sockpath; pid_t otherpid; - int ch, debug; + int ch, debug, lqlen; bool foreground; pjdlog_init(PJDLOG_MODE_STD); debug = 0; foreground = false; + lqlen = SOMAXCONN; pidfile = CASPERD_PIDFILE; servconfdir = CASPERD_SERVCONFDIR; sockpath = CASPERD_SOCKPATH; - while ((ch = getopt(argc, argv, "D:FhP:S:v")) != -1) { + while ((ch = getopt(argc, argv, "D:Fhl:P:S:v")) != -1) { switch (ch) { case 'D': servconfdir = optarg; @@ -646,6 +647,11 @@ main(int argc, char *argv[]) case 'F': foreground = true; break; + case 'l': + lqlen = strtol(optarg, NULL, 0); + if (lqlen < 1) + lqlen = SOMAXCONN; + break; case 'P': pidfile = optarg; break; @@ -711,5 +717,5 @@ main(int argc, char *argv[]) /* * Wait for connections. */ - main_loop(sockpath, pfh); + main_loop(lqlen, sockpath, pfh); }