🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #18136

Re: INN-1.5.1 dying

#18136
From: Jeff Garzik
Date: Mon, 02 Jun 1997 00:00
337 lines
10230 bytes
This is a multi-part message in MIME format.

--------------5E7231E2664EC1B6C398B18
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here's what I have.  The patch you posted was already diff'd by J.
Porter Clark at
ftp://ftp.isc.org/isc/inn/unoff-patches/canceled-history-arrival-time.patch 
:)

My patch conflicts with the above patch, and includes
ftp://ftp.isc.org/isc/inn/unoff-patches/null-pointer.patch

It models itself after Clayton O'Neill's patch, but stores hash values
instead of copying the msg id string each time.  It also adds cache
stats and logging of said stats, and some warnings to debug the history
cache code.

It still crashes...
-- 
Jeff Garzik
News Administrator, Spinne, Inc.
http://www.spinne.com/usenet/

--------------5E7231E2664EC1B6C398B18
Content-Type: text/plain; charset=us-ascii; name="history-cache.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="history-cache.patch"

*** ../inn-plain/innd/his.c	Tue Dec 17 09:40:40 1996
--- innd/his.c	Mon Jun  2 07:50:20 1997
***************
*** 1,4 ****
! /*  $Revision: 1.23 $
  **
  **  History file routines.
  */
--- 1,4 ----
! /*  $Revision: 1.2 $
  **
  **  History file routines.
  */
***************
*** 9,21 ****
  #include "innd.h"
  #include "dbz.h"
  
  
  STATIC char	HIShistpath[] = _PATH_HISTORY;
  STATIC FILE	*HISwritefp;
  STATIC int	HISreadfd;
  STATIC int	HISdirty;
  STATIC int	HISincore = INND_DBZINCORE;
! 
  
  /*
  **  Set up the history files.
--- 9,31 ----
  #include "innd.h"
  #include "dbz.h"
  
+ #define HISCACHESIZE	(256 * 1024L) /* num. elements in cache array */
+ #define HISCACHELOGTIME	500 /* seconds between cache hit reports to syslog */
+ 
+ typedef struct {
+     long		MessageIDHash;
+     BOOL		Found;
+ } _HIScache;
  
  STATIC char		HIShistpath[] = _PATH_HISTORY;
  STATIC FILE		*HISwritefp;
  STATIC int		HISreadfd;
  STATIC int		HISdirty;
  STATIC int		HISincore = INND_DBZINCORE;
! STATIC _HIScache	HIScache[HISCACHESIZE];
! STATIC unsigned long	HIScachehits;
! STATIC unsigned long	HIScachelookups;
! STATIC time_t		HIScachelastreported;
  
  /*
  **  Set up the history files.
***************
*** 46,51 ****
--- 56,66 ----
  	    exit(1);
  	}
      }
+ 
+     syslog(L_NOTICE, "SERVER history cache reset: %ld entries", HISCACHESIZE);
+     memset((void *)&HIScache, 0, sizeof(HIScache));
+     HIScachehits = HIScachelookups = 0;
+     HIScachelastreported = Now.time;
  }
  
  
***************
*** 84,89 ****
--- 99,107 ----
  	    syslog(L_ERROR, "%s cant close history %m", LogName);
  	HISreadfd = -1;
      }
+ 
+   syslog(L_NOTICE, "SERVER history cache final: %lu lookups, %lu hits",
+   	 HIScachelookups, HIScachehits);
  }
  
  
***************
*** 198,206 ****
--- 216,253 ----
  {
      datum	key;
      datum	val;
+     long	hash_pos, hash_val;
+ 
+     if ((MessageID == NULL) || (*MessageID == 0)) {
+       syslog(L_ERROR, "SERVER HIShavearticle(): missing message id");
+       return FALSE;
+     }
+ 
+     hash_val = dbzhash(MessageID, strlen(MessageID));
+     hash_pos = hash_val % HISCACHESIZE;
+     if ((hash_pos < 0) || (hash_pos >= HISCACHESIZE))
+       syslog(L_FATAL, "SERVER HIShavearticle(): invalid hash_pos: %ld", hash_pos);
+     HIScachelookups++;
+     if (HIScache[hash_pos].MessageIDHash == hash_val) {
+ 	HIScachehits++;
+ 
+ 	if (Now.time > (HIScachelastreported + HISCACHELOGTIME)) {
+ 	  syslog(L_NOTICE,
+ 	  	 "SERVER history cache: %lu lookups, %lu hits",
+ 	  	 HIScachelookups,
+ 		 HIScachehits);
+ 
+ 	  HIScachelastreported = Now.time;
+ 	}
+ 
+     	return HIScache[hash_pos].Found;
+     }
  
      HISsetkey(MessageID, &key);
      val = dbzfetch(key);
+ 
+     HIScache[hash_pos].MessageIDHash = hash_val;
+     HIScache[hash_pos].Found = (char)(val.dptr != NULL);  
      return val.dptr != NULL;
  }
  
***************
*** 237,247 ****
      char		*paths;
  {
      static char		NOPATHS[] = "";
!     long		offset;
      datum		key;
      datum		val;
      int			i;
  
      HISsetkey(Data->MessageID, &key);
      if (paths != NULL && paths[0] != '\0')
  	HISslashify(paths);
--- 284,297 ----
      char		*paths;
  {
      static char		NOPATHS[] = "";
!     long		offset, hash_val, hash_pos;
      datum		key;
      datum		val;
      int			i;
  
+     if ((Data->MessageID == NULL) || (Data->MessageIDLength < 1))
+       return FALSE;
+ 
      HISsetkey(Data->MessageID, &key);
      if (paths != NULL && paths[0] != '\0')
  	HISslashify(paths);
***************
*** 279,284 ****
--- 329,342 ----
  	return FALSE;
      }
  
+     hash_val = dbzhash(Data->MessageID, Data->MessageIDLength);
+     hash_pos = hash_val % HISCACHESIZE;
+     if ((hash_pos < 0) || (hash_pos >= HISCACHESIZE))
+       syslog(L_FATAL, "SERVER HISwrite(): invalid hash_pos: %ld", hash_pos);
+ 
+     HIScache[hash_pos].MessageIDHash = hash_val;
+     HIScache[hash_pos].Found = TRUE;
+     
      if (++HISdirty >= ICD_SYNC_COUNT)
  	HISsync();
      return TRUE;
*** ../inn-plain/innd/art.c	Tue Dec 17 09:40:40 1996
--- innd/art.c	Mon Jun  2 05:18:59 1997
***************
*** 1784,1790 ****
  	(void)sprintf(buff, "%d %s", NNTP_REJECTIT_VAL, error);
  	ARTlog(&Data, ART_REJECT, buff);
  #if	defined(DO_REMEMBER_TRASH)
!         if (Mode == OMrunning && !HISwrite(&Data, ""))
              syslog(L_ERROR, "%s cant write history %s %m",
                     LogName, Data.MessageID);
  #endif	/* defined(DO_REMEMBER_TRASH) */
--- 1784,1790 ----
  	(void)sprintf(buff, "%d %s", NNTP_REJECTIT_VAL, error);
  	ARTlog(&Data, ART_REJECT, buff);
  #if	defined(DO_REMEMBER_TRASH)
!         if (Data.MessageID && Mode == OMrunning && !HISwrite(&Data, ""))
              syslog(L_ERROR, "%s cant write history %s %m",
                     LogName, Data.MessageID);
  #endif	/* defined(DO_REMEMBER_TRASH) */
***************
*** 1799,1805 ****
          syslog(L_NOTICE, "rejecting[perl] %s %s", HDR(_message_id), buff);
          ARTlog(&Data, ART_REJECT, buff);
  #if	defined(DO_REMEMBER_TRASH)
!         if (Mode == OMrunning && !HISwrite(&Data, ""))
              syslog(L_ERROR, "%s cant write history %s %m",
                     LogName, Data.MessageID);
  #endif	/* defined(DO_REMEMBER_TRASH) */
--- 1799,1805 ----
          syslog(L_NOTICE, "rejecting[perl] %s %s", HDR(_message_id), buff);
          ARTlog(&Data, ART_REJECT, buff);
  #if	defined(DO_REMEMBER_TRASH)
!         if (Data.MessageID && Mode == OMrunning && !HISwrite(&Data, ""))
              syslog(L_ERROR, "%s cant write history %s %m",
                     LogName, Data.MessageID);
  #endif	/* defined(DO_REMEMBER_TRASH) */
***************
*** 1843,1849 ****
                         buff);
  		ARTlog(&Data, ART_REJECT, buff);
  #if	defined(DO_REMEMBER_TRASH)
!                 if (Mode == OMrunning && !HISwrite(&Data, ""))
                      syslog(L_ERROR, "%s cant write history %s %m",
                             LogName, Data.MessageID);
  #endif	/* defined(DO_REMEMBER_TRASH) */
--- 1843,1849 ----
                         buff);
  		ARTlog(&Data, ART_REJECT, buff);
  #if	defined(DO_REMEMBER_TRASH)
!                 if (Data.MessageID && Mode == OMrunning && !HISwrite(&Data, ""))
                      syslog(L_ERROR, "%s cant write history %s %m",
                             LogName, Data.MessageID);
  #endif	/* defined(DO_REMEMBER_TRASH) */
*** ../inn-plain/innd/cc.c	Tue Dec 17 09:40:40 1996
--- innd/cc.c	Mon Jun  2 05:21:16 1997
***************
*** 410,416 ****
      ARTDATA	Data;
      STRING	p;
  
!     Data.Posted = Now.time;
      Data.Expires = 0;
      Data.Feedsite = "?";
      if ((p = CCgetid(av[0], &Data.MessageID)) != NULL)
--- 410,417 ----
      ARTDATA	Data;
      STRING	p;
  
!     memset ((void *)&Data, 0, sizeof(Data));
!     Data.Posted = Data.Arrived = Now.time;
      Data.Expires = 0;
      Data.Feedsite = "?";
      if ((p = CCgetid(av[0], &Data.MessageID)) != NULL)
*** ../inn-plain/dbz/dbz.c	Tue Dec 17 09:40:40 1996
--- dbz/dbz.c	Mon Jun  2 05:24:59 1997
***************
*** 355,361 ****
  extern void CloseOnExec();
  
  /* misc. forwards */
- static long hash();
  static void crcinit();
  static char *cipoint();
  static char *mapcase();
--- 355,360 ----
***************
*** 1426,1432 ****
  {
  	register long h;
  
! 	h = hash(kp->dptr, kp->dsize);
  	if (osp != FRESH && osp->hash == h) {
  		if (sp != osp)
  			*sp = *osp;
--- 1425,1431 ----
  {
  	register long h;
  
! 	h = dbzhash(kp->dptr, kp->dsize);
  	if (osp != FRESH && osp->hash == h) {
  		if (sp != osp)
  			*sp = *osp;
***************
*** 1716,1725 ****
  }
  
  /*
!  - hash - Honeyman's nice hashing function
   */
! static long
! hash(name, size)
  register char *name;
  register int size;
  {
--- 1715,1724 ----
  }
  
  /*
!  - dbzhash - Honeyman's nice hashing function
   */
! long
! dbzhash(name, size)
  register char *name;
  register int size;
  {
*** ../inn-plain/dbz/dbz.h	Tue Dec 17 09:40:40 1996
--- dbz/dbz.h	Mon Jun  2 05:24:59 1997
***************
*** 24,29 ****
--- 24,30 ----
  extern int dbzcancel();
  extern int dbzdebug();
  extern int dbzwritethrough();
+ extern long dbzhash();
  
  /*
   * In principle we could handle unlimited-length keys by operating a chunk

--------------5E7231E2664EC1B6C398B18--


Technical Details
Message-ID: <3392B6AC.3940FE37@spinne.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <5mt7et$s52$1@turing.mathworks.com> <5mtdlr$ndu$1@hammer.msfc.nasa.gov> <5mtnuo$ehr@news.webspan.net>

Show Full Headers
Complete Article Headers
Message-ID: <3392B6AC.3940FE37@spinne.com>
Subject: Re: INN-1.5.1 dying
Date: Mon, 02 Jun 1997 00:00:00 +0000
From: Jeff Garzik <jeff.garzik@spinne.com>
References: <5mt7et$s52$1@turing.mathworks.com> <5mtdlr$ndu$1@hammer.msfc.nasa.gov> <5mtnuo$ehr@news.webspan.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 245607260
To: Gary Palmer <gpalmer@SPAM.webspan.net>
Organization: Spinne http://spinne.com
Newsgroups: news.software.nntp