# HG changeset patch # User bears # Date 983143790 0 # Node ID 7ba337dafb2c278946a6d7b725250c208474fc5c # Parent 1d92abe57427655b9f6aaf7c0a9fb619c70a6074 [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. diff -r 1d92abe57427 -r 7ba337dafb2c ChangeLog --- 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 + + * 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 * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up diff -r 1d92abe57427 -r 7ba337dafb2c TODO --- 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. diff -r 1d92abe57427 -r 7ba337dafb2c src/content.c --- 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 * diff -r 1d92abe57427 -r 7ba337dafb2c src/lock.c --- 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 #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; diff -r 1d92abe57427 -r 7ba337dafb2c src/server.c --- 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; diff -r 1d92abe57427 -r 7ba337dafb2c src/server.h --- 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