Article View: comp.sources.bugs
Article #539Re; UNOFFICIAL PATCH to popper-1.831b
From: Eiji Hirai
Date: Tue, 10 Nov 1992 20:55
Date: Tue, 10 Nov 1992 20:55
156 lines
5014 bytes
5014 bytes
I wrote:
: This adds an idle timeout routine to popper 1.831b
sdorner@qualcomm.com (Steve Dorner) pointed out a potential problem with the
patch. Thanks Steve. Here's a fixed patch. You'll need to apply this
patch to the original popper source, not the patched source. If you need the
original, it's at lilac.berkeley.edu:/pub/popper/.
--
hirai@cc.swarthmore.edu (Eiji Hirai) : : : : : :: ::: :::: :::::
Unix Geek for Swarthmore College : : : : : :: ::: :::: :::::
Information Services, Swarthmore, PA, US. Copyright 1992 by Eiji Hirai.
I don't speak for Swarthmore College. All Rights Reserved.
Subject: idle timeout routines
Description:
If a pop client has opened a connection to the popper server and the
client host crashes, the connection to the popper server is never
closed and the popper server will never quit. After a large number
of client host crashes, the server host will run out of file
descriptors and memory.
Repeat-By:
Run Eudora (1.2.2 or 1.3b102) on a Macintosh with MacTCP 1.1, then
download a large mail file. During the download, restart the
Macintosh. The popper server which was talking to that client will
be running on your server host until you manually kill it. Shout,
"eek!"
Fix:
Apply this patch. Add -DTIMEOUT to CFLAGS in Makefile.
Index: version.h
Prereq: "1.831beta"
*** version.h.old Wed Apr 3 18:25:44 1991
--- version.h Mon Nov 9 20:34:28 1992
***************
*** 12,15 ****
--- 12,19 ----
* Current version of this POP implementation
*/
+ #ifdef TIMEOUT
+ #define VERSION "1.831beta+timeout"
+ #else
#define VERSION "1.831beta"
+ #endif /* TIMEOUT */
*** popper.h.old Wed Apr 3 18:25:43 1991
--- popper.h Tue Nov 10 14:40:48 1992
***************
*** 170,172 ****
--- 170,176 ----
extern int pop_xtnd();
extern int pop_xmit();
+ #ifdef TIMEOUT
+ # define CHECKIDLE 60
+ # define MAXIDLE 600
+ #endif /* TIMEOUT */
*** popper.c.old Wed Apr 3 18:25:42 1991
--- popper.c Tue Nov 10 15:48:11 1992
***************
*** 15,20 ****
--- 15,28 ----
extern state_table * pop_get_command();
+ #ifdef TIMEOUT
+ # include <signal.h>
+ # include <time.h>
+ # define p main_p
+ POP p;
+ time_t lasttime;
+ #endif /* TIMEOUT */
+
/*
* popper: Handle a Post Office Protocol version 3 session
*/
***************
*** 22,28 ****
--- 30,40 ----
int argc;
char ** argv;
{
+ #ifdef TIMEOUT
+ void timeout();
+ #else
POP p;
+ #endif /* TIMEOUT */
state_table * s;
char message[MAXLINELEN];
***************
*** 33,38 ****
--- 45,56 ----
pop_msg(&p,POP_SUCCESS,
"UCB Pop server (version %s) at %s starting.",VERSION,p.myhost);
+ #ifdef TIMEOUT
+ lasttime = time((time_t *)0);
+ signal(SIGALRM, timeout);
+ alarm(CHECKIDLE); /* turn on idle timer */
+ #endif /* TIMEOUT */
+
/* State loop. The POP server is always in a particular state in
which a specific suite of commands can be executed. The following
loop reads a line from the client, gets the command, and processes
***************
*** 47,52 ****
--- 65,73 ----
pop_msg(&p,POP_FAILURE,"POP server at %s signing off.",p.myhost);
}
else {
+ #ifdef TIMEOUT
+ alarm(0); /* turn off idle timer */
+ #endif /* TIMEOUT */
/* Search for the command in the command/state table */
if ((s = pop_get_command(&p,message)) == NULL) continue;
***************
*** 59,64 ****
--- 80,89 ----
p.CurrentState = s->success_state;
pop_msg(&p,POP_SUCCESS,NULL);
}
+ #ifdef TIMEOUT
+ lasttime = time((time_t *)0);
+ alarm(CHECKIDLE); /* turn on idle timer */
+ #endif /* TIMEOUT */
}
}
***************
*** 100,102 ****
--- 125,142 ----
return(0);
}
#endif STRNCASECMP
+
+ #ifdef TIMEOUT
+ void timeout() {
+ if (time((time_t *)0) - lasttime >= MAXIDLE) {
+ pop_msg(&p,POP_SUCCESS,
+ "Pop server at %s signing off.",p.myhost);
+ pop_log(&p,POP_PRIORITY,
+ "(v%s) Idle timeout from \"%s\" at %s",VERSION,p.client,p.ipaddr);
+ closelog();
+ exit(0);
+ }
+ else
+ alarm(CHECKIDLE);
+ }
+ #endif /* TIMEOUT */
Technical Details
Message-ID:
<M0ZSB51M@cc.swarthmore.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!jvnc.net!netnews.upenn.edu!news.cc.swarthmore.edu!hiraiReferences:
<Q0YSBG55@cc.swarthmore.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!jvnc.net!netnews.upenn.edu!news.cc.swarthmore.edu!hirai From: hirai@cc.swarthmore.edu (Eiji Hirai) Newsgroups: comp.sources.bugs,comp.sys.mac.comm Subject: Re; UNOFFICIAL PATCH to popper-1.831b Message-ID: <M0ZSB51M@cc.swarthmore.edu> Date: 10 Nov 92 20:55:32 GMT References: <Q0YSBG55@cc.swarthmore.edu> Sender: news@cc.swarthmore.edu (USENET News System) Organization: Information Services, Swarthmore College, Swarthmore, PA, USA Lines: 156 Nntp-Posting-Host: gingko