Patches to 1.0.7.1 BETA

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

 



I'm still doing stuff as I can on this, but am supposed to be working on 
other stuff, so I am flushing these patches out to let people reject or 
try out as they wish...

Changes are:-
  + SIGINT toggles debugging on full (in current process)
  + Fixing of some stats stuff - *much* more needs doing
  + another log message fudged to look like nnrpd
  + tiddly bug fixes.

It compiles and runs on Linux, but is not heavily tested.  I have done 
nothing that should break any other port.

Additionally I have set planete.theplanet.net to mirror the nntpcache 
stuff at
	ftp://planete.theplanet.net/pub/nntpcache/
	http://planete.theplanet.net/pub/nntpcache/

This box is basically an internal resource, but I'll leave it open for use 
unless it *really* starts being hit.  We have good bandwidth to most 
places - UK, Europe, US - in fact everywhere except Australia and Norway 
(ie where the current nntpcache sites are!).

I intend to continue with additional instrumentation of nntpcache - which 
seems to be a little wierd in places probably because the stats were 
unusable for so long - and any changes needed for stability on Linux in 
particular.

	Nigel.

Index: nntpcache/article.c
diff -u nntpcache/article.c:1.1.1.2 nntpcache/article.c:1.7
--- nntpcache/article.c:1.1.1.2	Mon Jul 14 18:18:03 1997
+++ nntpcache/article.c	Tue Jul 15 18:18:57 1997
@@ -686,8 +686,10 @@
 			{
 				if (type==c_head)
 				{
-					Stats->head_proxy++;
-					Stats->head_proxy_bytes += art_stack->used - 1;
+					Stats->head_cache++;
+					Stats->head_cache_bytes += art_stack->used - 1;
+					Stats->head_cached++;
+					Stats->head_cached_bytes += art_stack->used - 1;
 				}
 				emit(art_stack->data);	/* emit the head */
 			}
@@ -728,11 +730,15 @@
 			{
 				if (type==c_article)
 				{
-					Stats->article_proxy++;
-					Stats->article_proxy_bytes += art_stack->used - 1;
+					Stats->article_cache++;
+					Stats->article_cache_bytes += art_stack->used - 1;
+					Stats->article_cached++;
+					Stats->article_cached_bytes += art_stack->used - 1;
 				} else {
-					Stats->body_proxy++;
-					Stats->body_proxy_bytes += art_stack->used - head_len - 1;
+					Stats->body_cache++;
+					Stats->body_cache_bytes += art_stack->used - head_len - 1;
+					Stats->body_cached++;
+					Stats->body_cached_bytes += art_stack->used - head_len - 1;
 				}
 				emit ((type == c_body && !CurrentScfg->article_timeout)? art_stack->data+head_len+2: art_stack->data);
 			}
@@ -841,15 +847,15 @@
 			/* avoid buffering, push it out in one hit */
 			wsize = write (fileno(clientout), buf, len);
 			Stats->client_write_bytes += wsize;
-			Stats->article_proxy_bytes += wsize;
-			Stats->article_proxy++;
+			Stats->article_cache_bytes += wsize;
+			Stats->article_cache++;
 			break;
 		case c_head:
 			/* head's tend to be small */
 			wsize = fwrite (buf, body? body-2-buf: len, 1, clientout);
 			Stats->client_write_bytes += wsize;
-			Stats->head_proxy_bytes += wsize;
-			Stats->head_proxy++;
+			Stats->head_cache_bytes += wsize;
+			Stats->head_cache++;
 			break;
 		case c_body:
 			/* bodies can be large or small */
@@ -861,8 +867,8 @@
 			} else
 				wsize = fwrite (body, buf+len-body, 1, clientout);
 			Stats->client_write_bytes += wsize;
-			Stats->body_proxy_bytes += wsize;
-			Stats->body_proxy++;
+			Stats->body_cache_bytes += wsize;
+			Stats->body_cache++;
 			break;
 		case c_stat:
 			break;
Index: nntpcache/genextern.sh
diff -u nntpcache/genextern.sh:1.1.1.3 nntpcache/genextern.sh:1.3
--- nntpcache/genextern.sh:1.1.1.3	Mon Jul 14 18:18:06 1997
+++ nntpcache/genextern.sh	Tue Jul 15 12:26:07 1997
@@ -1,4 +1,3 @@
-#!/bin/sh
 # $Id$
 # cute huh? 
 #           --proff
Index: nntpcache/ipc.c
diff -u nntpcache/ipc.c:1.1.1.2 nntpcache/ipc.c:1.4
--- nntpcache/ipc.c:1.1.1.2	Mon Jul 14 18:18:04 1997
+++ nntpcache/ipc.c	Tue Jul 15 12:26:07 1997
@@ -33,7 +33,7 @@
 			unlink(f);
 		} else
 		{
-			*Stats = st;
+			memcpy(Stats, &st, sizeof st);
 			close (fd);
 			goto good;
 		}
Index: nntpcache/nntpcache.c
diff -u nntpcache/nntpcache.c:1.1.1.3 nntpcache/nntpcache.c:1.9
--- nntpcache/nntpcache.c:1.1.1.3	Mon Jul 14 18:18:04 1997
+++ nntpcache/nntpcache.c	Tue Jul 15 18:18:58 1997
@@ -88,14 +88,38 @@
 static RETSIGTYPE sigterm (int sig)
 {
 	signal (SIGTERM, sigterm);
-	signal (SIGINT, sigterm);
 	if (!Daemon || InDaemon) {
 		errno = 0;
-		logw (("caught SIGTERM or SIGINT..syncing database...syncing disks...exiting"));
+		logw (("caught SIGTERM ..syncing database...syncing disks...exiting"));
 	}
 	Exit (1);
 }
 
+static RETSIGTYPE sigint (int sig)
+{
+	static bool saved_conf = FALSE;
+	static struct confused saved_conf_data;
+
+	signal (SIGINT, sigint);
+	if (saved_conf) {
+		memcpy(&con, &saved_conf_data, sizeof(con));
+		saved_conf = FALSE;
+		log(("Caught SIGINT - logging set normal"));
+	} else {
+		memcpy(&saved_conf_data, &con, sizeof(con));
+		saved_conf 		= TRUE;
+		con.logFromClient	= TRUE;
+		con.logToClient		= TRUE;
+		con.logFromServer	= TRUE;
+		con.logToServer		= TRUE;
+		con.logDebug		= TRUE;
+		con.logInfo		= TRUE;
+		con.logWarnings		= TRUE;
+		con.logErrors		= TRUE;
+		log(("Caught SIGINT - full debug logging set"));
+	}
+}
+
 static RETSIGTYPE sigsegv (int sig)
 {
 	signal (SIGSEGV, SIG_DFL);
@@ -126,7 +150,7 @@
 static RETSIGTYPE sigalrm (int sig)
 {
 	emitf ("%d Timeout after %s, closing connection.\r\n", NNTP_TEMPERR_VAL, nnitod(con.idleTimeout));
-	log (("client idled out after %s", nnitod(con.idleTimeout)));
+	log (("timeout (client) after %s", nnitod(con.idleTimeout)));
 	Exit (1);
 }
 
@@ -177,8 +201,11 @@
 		unsigned long u, s;
 
 	  	if (CurrentGroupArtRead && CurrentGroupScfg && CurrentGroupScfg->group)
+		{
 			log (("%s group %s %d", ClientHostNormal, 
 			      CurrentGroupScfg->group, CurrentGroupArtRead));
+			ArtRead+=CurrentGroupArtRead;
+		}
 		log (("%s exit articles %d groups %d", ClientHostNormal, 
 			ArtRead, GroupsEntered));
 		times(&buffer);
@@ -816,7 +843,7 @@
 	}
 	logd(("cwd now %s", con.cacheDir));
 	signal (SIGTERM, sigterm);
-	signal (SIGINT, sigterm);
+	signal (SIGINT, sigint);
 	signal (SIGSEGV, sigsegv);
 	signal (SIGFPE, SIG_IGN);
 	if (MakeHistory)
Index: nntpcache/post.c
diff -u nntpcache/post.c:1.1.1.2 nntpcache/post.c:1.4
--- nntpcache/post.c:1.1.1.2	Mon Jul 14 18:18:06 1997
+++ nntpcache/post.c	Tue Jul 15 12:26:08 1997
@@ -35,6 +35,7 @@
 	char *group;
 	char *post_err = NULL;
 	int bytes = 0;
+	int numGroups = 0;
 	bool f_have_organization=FALSE;
 
 	emitrn ("340 Ok");
@@ -88,6 +89,7 @@
 		struct group_cfg *gcf;
 		struct server_cfg *last_cfg = NULL;
 		struct authent *gp;
+		numGroups++;
 		strStripLeftRight (group);
 		gp = authorise(RemoteHosts, group);
 		if (!gp || !gp->post)
@@ -188,5 +190,8 @@
 		return FALSE;
 	}
 	Stats->posts++;
+	Stats->posts_bytes += bytes;
+	if (numGroups > 1)
+		Stats->posts_cross++;
 	return TRUE;
 }
Index: nntpcache/xover.c
diff -u nntpcache/xover.c:1.1.1.3 nntpcache/xover.c:1.5
--- nntpcache/xover.c:1.1.1.3	Mon Jul 14 18:18:05 1997
+++ nntpcache/xover.c	Tue Jul 15 12:26:08 1997
@@ -637,6 +637,10 @@
 			*tab = '\t';
 	} else
 		len+=emitrn("(none)");
+	if (con.statistics) {
+		Stats->xhdr_cache++;
+		Stats->xhdr_cache_bytes += len;
+	}
 	return len;
 }
 
[ Nigel.Metheringham@theplanet.net   -  Systems Software Engineer ]
[ Tel : +44 113 251 6012                   Fax : +44 113 224 0003 ]
[            Friends don't let friends use sendmail!              ]

[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux