From randy Sat May 29 14:15:39 1993 Return-Path: Received: from rip.psg.com by rip.psg.com with uucp (Smail3.1.28.1 #5) id m0nzYFf-000305C; Sat, 29 May 93 14:15 PDT Apparently-To: news Article: 1085 of comp.sources.bugs Xref: news.cc.swarthmore.edu comp.sources.bugs:1085 comp.sys.mac.comm:16467 Newsgroups: comp.sources.bugs,comp.sys.mac.comm Path: news.cc.swarthmore.edu!hirai From: hirai@cc.swarthmore.edu (Eiji Hirai) Subject: Re; UNOFFICIAL PATCH to popper-1.831b Message-ID: Sender: randy Nntp-Posting-Host: gingko Organization: Information Services, Swarthmore College, Swarthmore, PA, USA References: Date: Tue, 10 Nov 1992 20:55:32 GMT Status: O 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 (say 1.3) on a Macintosh with MacTCP (say 1.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 + # include + # 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 */