optimize disk/inode space by removing unneeded _head files

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

 



The attached patch optimizes disk/inode space used by nntpcache (diff
is tested against 2.3.3, but applies cleanly to 2.4.0b5) by removing
_head files after body is also retrieved and cached. 

It seems that there are some clients that first request HEAD, and
then BODY (or ARTICLE), and NNTPCache by default leaves both the 1234
and 1234_head files, thus wasting disk/inode space.

Also, since 2.4.0b5 didn't actually work for me (for fresh install it
doesn't manage to create news directories and cache anything ?), I've
installed 2.3.3, and created nicer SRPM/i386 RPM package for it (it
include fix above, and backports Y2K fix from 2.4.x, and also real
redhat-alike /etc/rc.d/init.d/nntpcache statup script)

If you (and/or NNTPCache users) are interested, you may want to link to
http://linux.voyager.hr/nntpcache/ (or copy/incorporate on
nntpcache.org, whatever)

Regards,
Matija

-- 
Opinions above are GNU-copylefted.
--- nntpcache-2.3.3/src/article.c	Wed Aug 19 14:33:07 1998
+++ nntpcache-2.3.3.my/src/article.c	Fri Jul 14 21:56:48 2000
@@ -196,6 +196,20 @@
 		return FALSE;
 	}
 	artfile = links->head->data;
+	
+	if (!strstr (artfile, "_head")) {
+		char *newart = malloc (strlen (artfile)+6);
+		if (!newart) {
+			logw (("Oops. No mem. Remove _head for %s skipped.", artfile));
+		} else {
+			strcpy (newart, artfile);
+			strcat (newart, "_head");
+			unlink (newart);
+			logd (("Removed obsolete _head: %s", newart));
+			free (newart);
+		}
+	}
+	
 	fd = open (artfile, O_WRONLY | O_EXCL | O_CREAT, 0664);
 	if (fd == -1)
 	{

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

Powered by Linux