summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2015-10-13 02:34:41 +0000
committeradrian <adrian@FreeBSD.org>2015-10-13 02:34:41 +0000
commit3f29c57f4e49e776c97179f241e351c17b7493d4 (patch)
tree7f8e4265a5658025456b3cc816fcd4538826a76d /sbin
parent91b919580f090dddcab0a4ee47ef473f67c5eb43 (diff)
downloadFreeBSD-src-3f29c57f4e49e776c97179f241e351c17b7493d4.zip
FreeBSD-src-3f29c57f4e49e776c97179f241e351c17b7493d4.tar.gz
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: <lidl@pix.net>
Diffstat (limited to 'sbin')
-rw-r--r--sbin/casperd/casperd.88
-rw-r--r--sbin/casperd/casperd.c16
2 files changed, 18 insertions, 6 deletions
diff --git a/sbin/casperd/casperd.8 b/sbin/casperd/casperd.8
index d60b9f3..945b517 100644
--- a/sbin/casperd/casperd.8
+++ b/sbin/casperd/casperd.8
@@ -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.
diff --git a/sbin/casperd/casperd.c b/sbin/casperd/casperd.c
index e9a4a94..65da58a 100644
--- a/sbin/casperd/casperd.c
+++ b/sbin/casperd/casperd.c
@@ -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 pidfh *pfh)
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);
}
OpenPOWER on IntegriCloud