changeset 167:7ba337dafb2c noffle

[svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re: need to do a Cont_write on Lock_closeDatabases in case of unwritten content changes when releasing the lock. Update content to keep dirty flag and avoid unnecessary writes, and lock to signal server to re-read its group content info after the lock is released. Do NOT write content info on Lock_close if dirty, as the placeholder article in unsubscribed groups is currently done by adding it to the content when joining the group and deliberately not saving it unless another content modification takes place and thus causes the content to be saved.
author bears
date Sun, 25 Feb 2001 23:29:50 +0000
parents 1d92abe57427
children cf2274194d38
files ChangeLog TODO src/content.c src/lock.c src/server.c src/server.h
diffstat 6 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 27 09:57:13 2001 +0000
+++ b/ChangeLog	Sun Feb 25 23:29:50 2001 +0000
@@ -1,3 +1,15 @@
+Sun Feb 25 2001 Jim Hague <jim.hague@acm.org>
+
+ * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
+   need to do a Cont_write on Lock_closeDatabases in case of unwritten
+   content changes when releasing the lock. Update content to keep dirty
+   flag and avoid unnecessary writes, and lock to signal server to re-read
+   its group content info after the lock is released. Do NOT write content
+   info on Lock_close if dirty, as the placeholder article in unsubscribed
+   groups is currently done by adding it to the content when joining the
+   group and deliberately not saving it unless another content modification
+   takes place and thus causes the content to be saved.
+
 Thu Jan 25 2001 Jim Hague <jim.hague@acm.org>
 
  * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
--- a/TODO	Sat Jan 27 09:57:13 2001 +0000
+++ b/TODO	Sun Feb 25 23:29:50 2001 +0000
@@ -7,9 +7,6 @@
 
  * Has Client_connect resource leaks if it fails?
 
- * Bug: Lock_closeDatabases must do a Cont_write() if dirty and Lock_openDatabases()
-   should check if it is necessary to reread the group content using a timestamp.
-
  * Make debug logging an option in the config file instead of using
    a compile time option. This makes it more comfortable for users helping on
    bug searches to switch on debug logging temporarily.
--- a/src/content.c	Sat Jan 27 09:57:13 2001 +0000
+++ b/src/content.c	Sun Feb 25 23:29:50 2001 +0000
@@ -1,7 +1,7 @@
 /*
   content.c
 
-  $Id: content.c 115 2000-05-19 15:18:05Z bears $
+  $Id: content.c 260 2001-02-25 23:29:50Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -38,7 +38,8 @@
                            in group. */
     Str name;
     Str file;
-} cont = { NULL, 1, 1, 0, 0, 0, NULL, "", "" };
+    Bool dirty;		/* Needs writing? */
+} cont = { NULL, 1, 1, 0, 0, 0, NULL, "", "", FALSE };
 
 void
 Cont_app( Over *ov )
@@ -59,6 +60,7 @@
         Ov_setNumb( ov, cont.vecFirst + cont.size );
     cont.elem[ cont.size++ ] = ov;
     cont.last = cont.vecFirst + cont.size - 1;
+    cont.dirty = TRUE;
 }
 
 Bool
@@ -78,6 +80,7 @@
     ov = &cont.elem[ n - cont.vecFirst ];
     free( *ov );
     *ov = NULL;
+    cont.dirty = TRUE;
 }
 
 /* Remove all overviews from content. */
@@ -186,6 +189,10 @@
     FILE *f;
     const Over *ov, *ov_next;
 
+    /* If nowt has changed, do nowt. */
+    if ( ! cont.dirty )
+	return;
+    
     /* Save the overview */
     if ( ! ( f = fopen( cont.file, "w" ) ) )
     {
@@ -241,6 +248,8 @@
 	unlink( cont.file );
 	cont.first = cont.last + 1;
     }
+
+    cont.dirty = FALSE;
 }
 
 const Over *
--- a/src/lock.c	Sat Jan 27 09:57:13 2001 +0000
+++ b/src/lock.c	Sun Feb 25 23:29:50 2001 +0000
@@ -1,7 +1,7 @@
 /*
   lock.c
 
-  $Id: lock.c 249 2001-01-25 13:38:31Z bears $
+  $Id: lock.c 260 2001-02-25 23:29:50Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -30,11 +30,13 @@
 
 #include <unistd.h>
 #include "configfile.h"
+#include "content.h"
 #include "log.h"
 #include "database.h"
 #include "group.h"
 #include "request.h"
 #include "portable.h"
+#include "server.h"
 #include "util.h"
 
 struct Lock
@@ -47,8 +49,8 @@
     volatile Bool lazyLockBusy;
 };
 
-static struct Lock globalLock = { "global", -1, "", TRUE };
-static struct Lock fetchLock = { "fetch", -1, "", FALSE };
+static struct Lock globalLock = { "global", -1, "", TRUE, FALSE, FALSE };
+static struct Lock fetchLock = { "fetch", -1, "", FALSE, FALSE, FALSE };
 
 static sig_t oldHandler = NULL;
 
@@ -220,6 +222,7 @@
     Grp_close();
     Db_close();
     Req_close();
+    Server_flushCache();
     releaseLock( &globalLock );
     globalLock.lazyLockBusy = FALSE;
     globalLock.lazyClose = FALSE;
--- a/src/server.c	Sat Jan 27 09:57:13 2001 +0000
+++ b/src/server.c	Sun Feb 25 23:29:50 2001 +0000
@@ -1,7 +1,7 @@
 /*
   server.c
 
-  $Id: server.c 244 2000-12-29 15:05:10Z enz $
+  $Id: server.c 260 2001-02-25 23:29:50Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -1393,6 +1393,12 @@
 }
 
 void
+Server_flushCache( void )
+{
+    server.groupReady = FALSE;
+}
+
+void
 Server_run( void )
 {
     Bool done;
--- a/src/server.h	Sat Jan 27 09:57:13 2001 +0000
+++ b/src/server.h	Sun Feb 25 23:29:50 2001 +0000
@@ -3,7 +3,7 @@
 
   Be NNTP server on stdin/stdout.
 
-  $Id: server.h 67 2000-05-12 17:19:38Z enz $
+  $Id: server.h 260 2001-02-25 23:29:50Z bears $
 */
 
 #ifndef SERV_H
@@ -15,4 +15,6 @@
 
 void Server_run( void );
 
+void Server_flushCache( void );
+
 #endif