home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sources / bugs / 270 < prev    next >
Encoding:
Text File  |  1992-11-10  |  4.8 KB  |  170 lines

  1. Xref: sparky comp.sources.bugs:270 comp.sys.mac.comm:10796
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!jvnc.net!netnews.upenn.edu!news.cc.swarthmore.edu!hirai
  3. From: hirai@cc.swarthmore.edu (Eiji Hirai)
  4. Newsgroups: comp.sources.bugs,comp.sys.mac.comm
  5. Subject: Re; UNOFFICIAL PATCH to popper-1.831b
  6. Message-ID: <M0ZSB51M@cc.swarthmore.edu>
  7. Date: 10 Nov 92 20:55:32 GMT
  8. References: <Q0YSBG55@cc.swarthmore.edu>
  9. Sender: news@cc.swarthmore.edu (USENET News System)
  10. Organization: Information Services, Swarthmore College, Swarthmore, PA, USA
  11. Lines: 156
  12. Nntp-Posting-Host: gingko
  13.  
  14. I wrote:
  15. : This adds an idle timeout routine to popper 1.831b
  16.  
  17. sdorner@qualcomm.com (Steve Dorner) pointed out a potential problem with the
  18. patch.  Thanks Steve.  Here's a fixed patch.  You'll need to apply this
  19. patch to the original popper source, not the patched source.  If you need the
  20. original, it's at lilac.berkeley.edu:/pub/popper/.
  21.  
  22. --
  23. hirai@cc.swarthmore.edu (Eiji Hirai)    :     :    :   :  : :: ::: :::: :::::
  24. Unix Geek for Swarthmore College        :     :    :   :  : :: ::: :::: :::::
  25. Information Services, Swarthmore, PA, US.       Copyright 1992 by Eiji Hirai.
  26. I don't speak for Swarthmore College.                    All Rights Reserved.
  27.  
  28. Subject: idle timeout routines
  29.  
  30. Description:
  31.  
  32.     If a pop client has opened a connection to the popper server and the
  33.     client host crashes, the connection to the popper server is never
  34.     closed and the popper server will never quit.  After a large number
  35.     of client host crashes, the server host will run out of file
  36.     descriptors and memory.
  37.  
  38. Repeat-By:
  39.  
  40.     Run Eudora (1.2.2 or 1.3b102) on a Macintosh with MacTCP 1.1, then
  41.     download a large mail file.  During the download, restart the
  42.     Macintosh.  The popper server which was talking to that client will
  43.     be running on your server host until you manually kill it.  Shout,
  44.     "eek!"
  45.  
  46. Fix:
  47.     Apply this patch.  Add -DTIMEOUT to CFLAGS in Makefile.
  48.  
  49. Index: version.h
  50. Prereq: "1.831beta"
  51. *** version.h.old    Wed Apr  3 18:25:44 1991
  52. --- version.h    Mon Nov  9 20:34:28 1992
  53. ***************
  54. *** 12,15 ****
  55. --- 12,19 ----
  56.    *  Current version of this POP implementation
  57.    */
  58.   
  59. + #ifdef TIMEOUT
  60. + #define VERSION         "1.831beta+timeout"
  61. + #else
  62.   #define VERSION         "1.831beta"
  63. + #endif /* TIMEOUT */
  64. *** popper.h.old    Wed Apr  3 18:25:43 1991
  65. --- popper.h    Tue Nov 10 14:40:48 1992
  66. ***************
  67. *** 170,172 ****
  68. --- 170,176 ----
  69.   extern int  pop_xtnd();
  70.   extern int  pop_xmit();
  71.   
  72. + #ifdef TIMEOUT
  73. + # define CHECKIDLE    60
  74. + # define MAXIDLE    600
  75. + #endif /* TIMEOUT */
  76. *** popper.c.old    Wed Apr  3 18:25:42 1991
  77. --- popper.c    Tue Nov 10 15:48:11 1992
  78. ***************
  79. *** 15,20 ****
  80. --- 15,28 ----
  81.   
  82.   extern  state_table *   pop_get_command();
  83.   
  84. + #ifdef TIMEOUT
  85. + # include <signal.h>
  86. + # include <time.h>
  87. + # define p    main_p
  88. + POP    p;
  89. + time_t    lasttime;
  90. + #endif /* TIMEOUT */
  91.   /* 
  92.    *  popper: Handle a Post Office Protocol version 3 session
  93.    */
  94. ***************
  95. *** 22,28 ****
  96. --- 30,40 ----
  97.   int         argc;
  98.   char    **  argv;
  99.   {
  100. + #ifdef TIMEOUT
  101. +     void timeout();
  102. + #else
  103.       POP                 p;
  104. + #endif /* TIMEOUT */
  105.       state_table     *   s;
  106.       char                message[MAXLINELEN];
  107.   
  108. ***************
  109. *** 33,38 ****
  110. --- 45,56 ----
  111.       pop_msg(&p,POP_SUCCESS,
  112.           "UCB Pop server (version %s) at %s starting.",VERSION,p.myhost);
  113.   
  114. + #ifdef TIMEOUT
  115. +     lasttime = time((time_t *)0);
  116. +     signal(SIGALRM, timeout);
  117. +     alarm(CHECKIDLE);  /* turn on idle timer */
  118. + #endif /* TIMEOUT */
  119.       /*  State loop.  The POP server is always in a particular state in 
  120.           which a specific suite of commands can be executed.  The following 
  121.           loop reads a line from the client, gets the command, and processes 
  122. ***************
  123. *** 47,52 ****
  124. --- 65,73 ----
  125.               pop_msg(&p,POP_FAILURE,"POP server at %s signing off.",p.myhost);
  126.           }
  127.           else {
  128. + #ifdef TIMEOUT
  129. +         alarm(0); /* turn off idle timer */
  130. + #endif /* TIMEOUT */
  131.               /*  Search for the command in the command/state table */
  132.               if ((s = pop_get_command(&p,message)) == NULL) continue;
  133.   
  134. ***************
  135. *** 59,64 ****
  136. --- 80,89 ----
  137.                   p.CurrentState = s->success_state;
  138.                   pop_msg(&p,POP_SUCCESS,NULL);
  139.               }
  140. + #ifdef TIMEOUT
  141. +         lasttime = time((time_t *)0);
  142. +         alarm(CHECKIDLE);  /* turn on idle timer */
  143. + #endif /* TIMEOUT */
  144.           }       
  145.       }
  146.   
  147. ***************
  148. *** 100,102 ****
  149. --- 125,142 ----
  150.       return(0);
  151.   }
  152.   #endif STRNCASECMP
  153. + #ifdef TIMEOUT
  154. + void    timeout() {
  155. +     if (time((time_t *)0) - lasttime >= MAXIDLE) {
  156. +         pop_msg(&p,POP_SUCCESS,
  157. +             "Pop server at %s signing off.",p.myhost);
  158. +         pop_log(&p,POP_PRIORITY,
  159. +     "(v%s) Idle timeout from \"%s\" at %s",VERSION,p.client,p.ipaddr);
  160. +         closelog();
  161. +         exit(0);
  162. +     }
  163. +     else
  164. +         alarm(CHECKIDLE);
  165. + }
  166. + #endif /* TIMEOUT */
  167.