From: jmarcus Date: Sat, 15 Dec 2001 06:25:43 +0000 (+0000) Subject: Add a new -timeout option to afpd. This option specifies how many tickles X-Git-Tag: point-backport-1-5-1~37 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=2050bc901314591b74c773eb326aad7d6e82d2a6 Add a new -timeout option to afpd. This option specifies how many tickles should be sent before the server closes a AFPoTCP (DSI) session. The default is 4 tickles 30 seconds apart, for a timeout of 2 minutes. This option should be used instead of -tickleval to control timeouts. --- diff --git a/ChangeLog b/ChangeLog index 7e443fd7..30a6b937 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-12-14 joe c + * etc/afpd/afp_options.c, etc/afpd/afp_dsi.c, etc/afpd/globals.h: + Add a new option to afpd called -timeout to specify the number of + server tickles to send before killing a AFPoTCP session. + 2001-12-10 joe c * bin/cnid/cnid_didname_verify,c: Add a utility to verify the consistency of didname.db. Using the stock db_verify utility will fail as the sort 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_config.c b/etc/afpd/afp_config.c index 25580336..de520e5d 100644 --- a/etc/afpd/afp_config.c +++ b/etc/afpd/afp_config.c @@ -1,5 +1,5 @@ /* - * $Id: afp_config.c,v 1.9 2001-12-10 20:16:53 srittau Exp $ + * $Id: afp_config.c,v 1.10 2001-12-15 06:25:44 jmarcus Exp $ * * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu) * All Rights Reserved. See COPYRIGHT. @@ -173,6 +173,8 @@ static int dsi_start(AFPConfig *config, AFPConfig *configs, exit( 1 ); } + config->obj.handle = dsi; + /* we've forked. */ if (dsi->child) { configfree(configs, config); diff --git a/etc/afpd/afp_dsi.c b/etc/afpd/afp_dsi.c index 6ae44dc6..c73fa2df 100644 --- a/etc/afpd/afp_dsi.c +++ b/etc/afpd/afp_dsi.c @@ -1,5 +1,5 @@ /* - * $Id: afp_dsi.c,v 1.11 2001-12-10 20:16:53 srittau Exp $ + * $Id: afp_dsi.c,v 1.12 2001-12-15 06:25:44 jmarcus 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; @@ -70,7 +71,7 @@ static void afp_dsi_die(int sig) dsi_attention(child.obj->handle, AFPATTN_SHUTDOWN); afp_dsi_close(child.obj); if (sig) /* if no signal, assume dieing because logins are disabled & - don't log it (maintenance mode)*/ + don't log it (maintenance mode)*/ syslog (LOG_INFO, "Connection terminated"); if (sig == SIGTERM || sig == SIGALRM) { exit( 0 ); @@ -124,7 +125,8 @@ 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)) { + if ((child.flags & CHILD_RUNNING) || (child.tickle++ < child.obj->options.timeout)) { + syslog(LOG_INFO, "afp_dsi: alarm_handler: tickling client..."); 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 dbba992a..ab64f79a 100644 --- a/etc/afpd/afp_options.c +++ b/etc/afpd/afp_options.c @@ -1,5 +1,5 @@ /* - * $Id: afp_options.c,v 1.14 2001-12-03 05:03:38 jmarcus Exp $ + * $Id: afp_options.c,v 1.15 2001-12-15 06:25:44 jmarcus 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 70fffde4..e67550c7 100644 --- a/etc/afpd/globals.h +++ b/etc/afpd/globals.h @@ -1,5 +1,5 @@ /* - * $Id: globals.h,v 1.7 2001-12-03 05:03:38 jmarcus Exp $ + * $Id: globals.h,v 1.8 2001-12-15 06:25:44 jmarcus 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; diff --git a/etc/afpd/parse_mtab.c b/etc/afpd/parse_mtab.c index 6a8920f2..67962caf 100644 --- a/etc/afpd/parse_mtab.c +++ b/etc/afpd/parse_mtab.c @@ -1,5 +1,5 @@ /* - * $Id: parse_mtab.c,v 1.6 2001-12-10 20:16:54 srittau Exp $ + * $Id: parse_mtab.c,v 1.7 2001-12-15 06:25:44 jmarcus Exp $ * * afpd_mtab_parse & support. -- rgr, 9-Apr-01. */ @@ -42,7 +42,7 @@ char *strchr (), *strrchr (); /* global mount table; afpd_st_cnid uses this to lookup the right entry. */ static struct afpd_mount_table *afpd_mount_table; - + static int ceil_log_2 __P((int n)) /* Return the number of bits required to represent n. Only works for