🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #18145

Re: INN-1.5.1 dying

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

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

coneill@blah.erols.com wrote:
> Jeff Garzik <jeff.garzik@spinne.com> writes:

> > 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...
> > +     hash_val = dbzhash(Data->MessageID, Data->MessageIDLength);

> This line is probably the problem.  MessageIDLength is not always valid.
> You need to replace Data->MessageIDLength with strlen(Data->MessageID).


That's exactly the problem.  In CCcancel() and one other place,
Data->MessageID is set without setting the respective
Data->MessageIDLength variable.

I have attached the corrected version of the patch.  I've been running
this for about 12 hours without any problems.
-- 
Jeff Garzik
News Administrator, Spinne, Inc.
http://www.spinne.com/usenet/

--------------29E5AA957A2579D2DECFDBB
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 10:48:51 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	(64 * 1024L)	/* num. elements in cache array */
+ #define HISCACHELOGTIME	1400L		/* 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,67 ----
  	    exit(1);
  	}
      }
+ 
+     syslog(L_NOTICE, "SERVER history cache reset: %ld entries, %u bytes",
+     	   HISCACHESIZE, sizeof(HIScache));
+     memset((void *)&HIScache, 0, sizeof(HIScache));
+     HIScachehits = HIScachelookups = 0;
+     HIScachelastreported = Now.time;
  }
  
  
***************
*** 84,89 ****
--- 100,108 ----
  	    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 ****
--- 217,246 ----
  {
      datum	key;
      datum	val;
+     long	hash_pos, hash_val;
+ 
+     hash_val = dbzhash(MessageID, strlen(MessageID));
+     hash_pos = hash_val % HISCACHESIZE;
+ 
+     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);
--- 277,288 ----
      char		*paths;
  {
      static char		NOPATHS[] = "";
!     long		offset, hash_val, hash_pos;
      datum		key;
      datum		val;
      int			i;
  
+ 
      HISsetkey(Data->MessageID, &key);
      if (paths != NULL && paths[0] != '\0')
  	HISslashify(paths);
***************
*** 279,284 ****
--- 320,332 ----
  	return FALSE;
      }
  
+     /* store hashed message id value in lookup cache */
+     hash_val = dbzhash(Data->MessageID, strlen(Data->MessageID));
+     hash_pos = hash_val % HISCACHESIZE;
+ 
+     HIScache[hash_pos].MessageIDHash = hash_val;
+     HIScache[hash_pos].Found = TRUE;
+     
      if (++HISdirty >= ICD_SYNC_COUNT)
  	HISsync();
      return TRUE;
*** ../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

--------------29E5AA957A2579D2DECFDBB--


Technical Details
Message-ID: <339349DB.4FB59B52@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> <3392B6AC.3940FE37@spinne.com> <86raekr8jt.fsf@blah.erols.com>

Show Full Headers
Complete Article Headers
Message-ID: <339349DB.4FB59B52@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> <3392B6AC.3940FE37@spinne.com> <86raekr8jt.fsf@blah.erols.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
X-Deja-AN: 245682493
Organization: Spinne http://spinne.com
Newsgroups: news.software.nntp