foreground without --quit now tries to wake the daemon and force it
to poll immediately.
+* Add option to set server nonresponse timeout.
+
fetchmail-1.8 (Fri Oct 11 15:08:10 EDT 1996):
features --
static struct method *protocol;
-static int alarmed; /* A flag to indicate that SIGALRM happened */
-int timeout = CLIENT_TIMEOUT;
+static int alarmed; /* a flag to indicate that SIGALRM happened */
+static int mytimeout; /* server-nonresponse timeout for current query */
char tag[TAGLEN];
static int tagnum;
sizeticker -= SIZETICKER;
/* reset timeout so we don't choke on very long messages */
- alarm(timeout);
+ alarm(queryctl->timeout);
}
lines++;
}
alarmed = 0;
sigsave = signal(SIGALRM, alarm_handler);
- alarm (timeout);
+ alarm (mytimeout = queryctl->timeout);
#ifndef KERBEROS_V4
if (queryctl->authenticate == A_KERBEROS)
alarm_handler (int signal)
{
alarmed = 1;
- fprintf(stderr,"fetchmail: timeout after %d seconds.\n", timeout);
+ fprintf(stderr,
+ "fetchmail: timeout after %d seconds.\n", mytimeout);
}
}
def_opts.protocol = P_AUTO;
-
+ def_opts.timeout = CLIENT_TIMEOUT;
strcpy(def_opts.remotename, user);
strcpy(def_opts.smtphost, "localhost");
putchar('\n');
if (queryctl->authenticate == A_KERBEROS)
printf(" Kerberos authentication enabled.\n");
+ printf(" Server nonresponse timeout is %d seconds", queryctl->timeout);
+ if (queryctl->timeout == CLIENT_TIMEOUT)
+ printf(" (default).\n");
+ else
+ printf("\n.");
printf(" %s messages will be retrieved (--all %s).\n",
queryctl->fetchall ? "All" : "Only new",
int protocol;
int port;
int authenticate;
+ int timeout;
/* MDA arguments */
char *mda_argv[32];
a daemon in the background sends a wakeup signal to the daemon,
forcing it to poll mailservers immediately.
.PP
+The
+.B -t
+or
+.B --timeout
+option allows you to set a server-nonresponse timeout in seconds. If
+a mailserver does not send a greeting message or respond to commands for
+the given number of seconds, \fIfetchmail\fR will hang up on it.
+Without such a timeout \fIfetchmail\fR might hang up indefinitely
+trying to fetch mail from a down host. This would be particularly
+annoying for a server running in background.
+.PP
The
.B -L
or
skip
noskip
authenticate (or auth)
+ timeout
Legal user options are
#define LA_PROTOCOL 11
#define LA_PORT 12
#define LA_AUTHENTICATE 13
-#define LA_USERNAME 14
-#define LA_ALL 15
-#define LA_KILL 16
-#define LA_KEEP 17
-#define LA_FLUSH 18
-#define LA_NOREWRITE 19
-#define LA_REMOTEFILE 20
-#define LA_SMTPHOST 21
-#define LA_MDA 22
-#define LA_YYDEBUG 23
+#define LA_TIMEOUT 14
+#define LA_USERNAME 15
+#define LA_ALL 16
+#define LA_KILL 17
+#define LA_KEEP 18
+#define LA_FLUSH 19
+#define LA_NOREWRITE 20
+#define LA_REMOTEFILE 21
+#define LA_SMTPHOST 22
+#define LA_MDA 23
+#define LA_YYDEBUG 24
-static char *shortoptions = "?Vcsvd:qL:f:i:p:P:A:u:akKFnr:S:m:y";
+static char *shortoptions = "?Vcsvd:qL:f:i:p:P:A:t:u:akKFnr:S:m:y";
static struct option longoptions[] = {
{"help", no_argument, (int *) 0, LA_HELP },
{"version", no_argument, (int *) 0, LA_VERSION },
{"proto", required_argument, (int *) 0, LA_PROTOCOL },
{"port", required_argument, (int *) 0, LA_PORT },
{"auth", required_argument, (int *) 0, LA_AUTHENTICATE},
+ {"timeout", required_argument, (int *) 0, LA_TIMEOUT },
{"user", required_argument, (int *) 0, LA_USERNAME },
{"username", required_argument, (int *) 0, LA_USERNAME },
errflag++;
}
break;
+ case 't':
+ queryctl->timeout = atoi(optarg);
+ break;
case 'u':
case LA_USERNAME:
strncpy(queryctl->remotename,optarg,sizeof(queryctl->remotename)-1);
fputs(" -p, --protocol specify pop2, pop3, imap, apop, rpop, kpop\n", stderr);
fputs(" -P, --port TCP/IP service port to connect to\n",stderr);
fputs(" -A, --auth authentication type (password or kerberos)\n",stderr);
+ fputs(" -t, --timeout server nonresponse timeout\n",stderr);
fputs(" -u, --username specify users's login on server\n", stderr);
fputs(" -a, --all retrieve old and new messages\n", stderr);
port { return PORT; }
auth(enticate)? { return AUTHENTICATE; }
kerberos { return KERBEROS; }
+timeout { return TIMEOUT;}
user(name)? { return USERNAME; }
pass(word)? { return PASSWORD; }
char *sval;
}
-%token DEFAULTS SERVER PROTOCOL AUTHENTICATE KPOP KERBEROS
+%token DEFAULTS SERVER PROTOCOL AUTHENTICATE TIMEOUT KPOP KERBEROS
%token USERNAME PASSWORD FOLDER SMTPHOST MDA IS HERE THERE
%token <proto> PROTO
%token <sval> STRING
| SKIP {current.skip = ($1==FLAG_TRUE);}
| AUTHENTICATE PASSWORD {current.authenticate = A_PASSWORD;}
| AUTHENTICATE KERBEROS {current.authenticate = A_KERBEROS;}
+ | TIMEOUT STRING {current.timeout = atoi($2);}
;
/* the first and only the first user spec may omit the USERNAME part */
FLAG_FORCE(skip);
FLAG_FORCE(port);
FLAG_FORCE(authenticate);
+ FLAG_FORCE(timeout);
#undef FLAG_FORCE
(void) hostalloc(¤t);
FLAG_MERGE(skip);
FLAG_MERGE(port);
FLAG_MERGE(authenticate);
+ FLAG_MERGE(timeout);
#undef FLAG_MERGE
}
# protocol (or proto) -- nuat be followed by a protocol ID
# port
# authenticate (or auth) -- must be followed by an authentication type
+# timeout
#
# username (or user)
# is
#include <config.h>
-#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#define INTERNAL_BUFSIZE 2048
-extern int timeout;
-extern void alarm_handler();
-
int Socket(host, clientPort)
char *host;
int clientPort;
while (--len)
{
- /* we have to push alarm in case we receive a large message */
- sigsave = signal (SIGALRM, alarm_handler);
- if (sigsave == alarm_handler)
- alarm (timeout);
- else
- signal (SIGALRM, sigsave);
-
if (SockInternalRead(socket, buf, 1) != 1)
return -1;
else