From pe@iki.fi Thu Aug  7 20:59:20 1997
Date: Thu, 7 Aug 1997 20:59:07 +0300 (EEST)
From: Pasi Eronen <pe@iki.fi>
To: HTDig mailing list <htdig@sdsu.edu>
Subject: alarm() bug with local filesystem patches

Hi!

There's a bug in Document.cc related to the alarm() function.  If
readHeader() returns anything but Header_ok, the scheduled alarm is
not properly canceled.

This doesn't usually matter, since Retrieve is called again very soon,
and the alarm is rescheduled. With my local filesystem patches,
however, there can be more than 30 seconds (the default timeout)
before the next call to RetrieveHTTP, if most files are retrieved
locally. 

The patch to fix this is available from <http://www.iki.fi/pe/htdig/>.
Thanks to Geoff Hutchison for helping to track down this bug!

Best regards,
Pasi

---
Pasi Eronen <pe@iki.fi>, +358-50-5123499

*** htdig/Document.cc.orig	Thu Aug  7 20:45:37 1997
--- htdig/Document.cc	Thu Aug  7 20:50:54 1997
***************
*** 365,382 ****
      alarm(timeout_interval);
  
      switch (readHeader(c))
      {
  	case Header_ok:
  	    break;
  	case Header_not_changed:
! 	    return Document_not_changed;
  	case Header_not_found:
! 	    return Document_not_found;
  	case Header_redirect:
! 	    return Document_redirect;
  	case Header_not_text:
! 	    return Document_not_html;
  	case Header_not_authorized:
! 	    return Document_not_authorized;
      }
  
--- 365,394 ----
      alarm(timeout_interval);
  
+     int returnStatus;
      switch (readHeader(c))
      {
  	case Header_ok:
+ 	    returnStatus = Document_ok;
  	    break;
  	case Header_not_changed:
! 	    returnStatus = Document_not_changed;
! 	    break;
  	case Header_not_found:
! 	    returnStatus = Document_not_found;
! 	    break;
  	case Header_redirect:
! 	    returnStatus = Document_redirect;
! 	    break;
  	case Header_not_text:
! 	    returnStatus = Document_not_html;
! 	    break;
  	case Header_not_authorized:
! 	    returnStatus = Document_not_authorized;
! 	    break;
!     }
!     if (returnStatus != Document_ok)
!     {
! 	alarm(0);
! 	return returnStatus;
      }
