[Prev][Next][Index][Thread]

2 small bugs in HTEvntrg.c



Well, I finally upgraded to 4.0D and found two bugs.

The first is that the select() timeout won't work under linux ---
linux, being a more annoying flavor of UNIX, will zero-out the timeval
passed to select. Yeah, I think it's dumb too. Anyway, the following
#ifdef's in the patch fix it.

The second is that HTEvent_stopLoop is a bit to permanent --- in
HTEvent_Loop (at least the non-Windows one), HTEndLoop is never set to
zero, so if HTEvent_stopLoop() is called, HTEvent_Loop cannot be
successfully called again.

A quick initialization statement fixed that bug.

Anyway, here's a quick patch which fixes both of them.

Cheers!
-Erik



*** /afs/cs/project/metacrawler/src/libwww4.0d/WWW/Library/Implementation/HTEvntrg.c~	Tue Feb 13 17:36:29 1996
--- /afs/cs/project/metacrawler/src/libwww4.0d/WWW/Library/Implementation/HTEvntrg.c	Mon Mar 18 15:43:11 1996
***************
*** 653,658 ****
--- 653,664 ----
      SOCKET s ;
      BOOL consoleReady = NO;
      int status = 0 ;
+ 
+ #ifdef __linux__
+     /* added 1/12/96 by Erik Selberg */
+     struct timeval tvtmp;
+ #endif
+ 
  #ifdef _WINSOCKAPI_
      unsigned ui ;
  #endif
***************
*** 665,670 ****
--- 671,679 ----
          maxfds = max_sock ; 
          readings = writings = exceptions = 0; 
  	consoleReady = NO;
+ 	
+ 	/* added 3/18/96 Erik Selberg <selberg@cs.washington.edu> */
+ 	HTEndLoop = 0;
  
  	if (console_in_use) { 
  
***************
*** 714,719 ****
--- 723,742 ----
  	    HTTrace("Event Loop.. calling select: maxfds is %d\n",
  		    maxfds);
  
+ 	/* added 1/12/96 by Erik Selberg */
+ 	/* we do this 'cuz some unixen, like linux, zero-out the
+ 	   time-out value when they timeout. Yes, I think it's a linux
+ 	   bug, but I don't want to hack the kernel.
+ 
+ 	   Anyway, we save a copy here, and then re-copy it over.
+ 	   Yes, we could just pass it into the select call, but this patch
+ 	   is a little cleaner.
+ 	   */
+ #ifdef __linux__
+ 	tvtmp.tv_sec = tvptr->tv_sec;
+ 	tvtmp.tv_usec = tvptr->tv_usec;
+ #endif
+ 
  #ifdef __hpux 
          active_sockets = select(maxfds+1, (int *)&treadset, (int *)&twriteset,
  				(int *)&texceptset, (struct timeval *) tvptr);
***************
*** 721,726 ****
--- 744,755 ----
          active_sockets = select(maxfds+1, &treadset, &twriteset, &texceptset,
  				(struct timeval *) tvptr);
  #endif
+ 
+ #ifdef __linux__
+ 	tvptr->tv_sec = tvtmp.tv_sec;
+ 	tvptr->tv_usec = tvtmp.tv_sec;
+ #endif
+ 
  	if (THD_TRACE)
  	    HTTrace("Event Loop.. select returns %d\n",active_sockets);
  


Follow-Ups: