From f9e1a5c33346829c25f2770d5ab660f9d3ddde11 Mon Sep 17 00:00:00 2001 From: srittau Date: Mon, 14 Jan 2002 02:56:08 +0000 Subject: [PATCH] Back-port from HEAD: New afpd option: -timeout. --- NEWS | 1 + config/afpd.conf.tmpl | 8 +++++++- etc/afpd/afp_dsi.c | 9 +++++---- etc/afpd/afp_options.c | 15 +++++++++++++-- etc/afpd/globals.h | 4 ++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 6b189f85..d0f79813 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ Changes from 1.5.0 * NEW: Added a program called cnid_didname_verify that can be used to verify the consistency of the CNID database. +* NEW: New afpd option: -timeout. See afpd.conf for more information. * UPD: Code cleanups and compatibility fixes to macusers. * UPD: AppleVolumes.system was cleaned up. * FIX: Really fix Tru64 compilation (see last entry). diff --git a/config/afpd.conf.tmpl b/config/afpd.conf.tmpl index 0f8cadf9..93065c8e 100644 --- a/config/afpd.conf.tmpl +++ b/config/afpd.conf.tmpl @@ -111,7 +111,13 @@ # -loginmesg "Message" Client will display "Message" upon logging in # (no default, same as -l "Message" on commandline) # -nodebug Switch off debugging -# -tickleval Specify the tickle timeout interval (in seconds) +# -tickleval Specify the tickle timeout interval (in seconds). +# Note, this defaults to 30 seconds, and really +# shouldn't be changed. If you want to control +# the server idle timeout, use the -timeout option. +# -timeout Specify the number of tickles to send before +# timing out a connection. The default is 4, therefore +# a connection will timeout in 2 minutes. # -icon Use the platform-specific icon. # # Some examples: diff --git a/etc/afpd/afp_dsi.c b/etc/afpd/afp_dsi.c index 64443560..bad585f0 100644 --- a/etc/afpd/afp_dsi.c +++ b/etc/afpd/afp_dsi.c @@ -1,5 +1,5 @@ /* - * $Id: afp_dsi.c,v 1.9.2.2 2002-01-14 02:53:24 srittau Exp $ + * $Id: afp_dsi.c,v 1.9.2.3 2002-01-14 02:56:08 srittau Exp $ * * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu) * Copyright (c) 1990,1993 Regents of The University of Michigan. @@ -45,7 +45,8 @@ extern struct oforks *writtenfork; static struct { AFPObj *obj; - unsigned char tickle, flags; + unsigned char flags; + int tickle; } child; @@ -123,8 +124,8 @@ static void afp_dsi_getmesg (int sig) static void alarm_handler() { /* if we're in the midst of processing something, - don't die. we'll allow 3 missed tickles before we die (2 minutes) */ - if ((child.flags & CHILD_RUNNING) || (child.tickle++ < 4)) { + don't die. */ + if ((child.flags & CHILD_RUNNING) || (child.tickle++ < child.obj->options.timeout)) { dsi_tickle(child.obj->handle); } else { /* didn't receive a tickle. close connection */ syslog(LOG_ERR, "afp_alarm: child timed out"); diff --git a/etc/afpd/afp_options.c b/etc/afpd/afp_options.c index 5da26aae..7ba9fe97 100644 --- a/etc/afpd/afp_options.c +++ b/etc/afpd/afp_options.c @@ -1,5 +1,5 @@ /* - * $Id: afp_options.c,v 1.13.2.1 2001-12-03 05:01:03 jmarcus Exp $ + * $Id: afp_options.c,v 1.13.2.2 2002-01-14 02:56:08 srittau Exp $ * * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu) * Copyright (c) 1990,1993 Regents of The University of Michigan. @@ -141,6 +141,7 @@ void afp_options_init(struct afp_options *options) options->transports = AFPTRANS_ALL; options->passwdfile = _PATH_AFPDPWFILE; options->tickleval = 30; + options->timeout = 4; options->authprintdir = NULL; options->umask = 0; #ifdef ADMIN_GRP @@ -223,8 +224,18 @@ int afp_options_parseline(char *buf, struct afp_options *options) options->passwdminlen = MIN(1, atoi(c)); if ((c = getoption(buf, "-loginmaxfail"))) options->loginmaxfail = atoi(c); - if ((c = getoption(buf, "-tickleval"))) + if ((c = getoption(buf, "-tickleval"))) { options->tickleval = atoi(c); + if (options->tickleval <= 0) { + options->tickleval = 30; + } + } + if ((c = getoption(buf, "-timeout"))) { + options->timeout = atoi(c); + if (options->timeout <= 0) { + options->timeout = 4; + } + } if ((c = getoption(buf, "-server_quantum"))) options->server_quantum = strtoul(c, NULL, 0); diff --git a/etc/afpd/globals.h b/etc/afpd/globals.h index 75fd1ef5..e3be67d2 100644 --- a/etc/afpd/globals.h +++ b/etc/afpd/globals.h @@ -1,5 +1,5 @@ /* - * $Id: globals.h,v 1.6.2.1 2001-12-03 05:01:04 jmarcus Exp $ + * $Id: globals.h,v 1.6.2.2 2002-01-14 02:56:08 srittau Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -40,7 +40,7 @@ /* a couple of these options could get stuck in unions to save * space. */ struct afp_options { - int connections, port, transports, tickleval, flags; + int connections, port, transports, tickleval, timeout, flags; unsigned char passwdbits, passwdminlen, loginmaxfail; u_int32_t server_quantum; char hostname[MAXHOSTNAMELEN + 1], *server, *ipaddr, *configfile; -- 2.39.2