Mercurial > noffle
changeset 191:28488e0e3630 noffle
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
only ever called with last param as time(NULL), so remove it and call
time() inside the implementation of Grp_setLastAccess.
* src/client.c,src/group.h,src/group.c,src/noffle.c,src/post.c: Groups are
automatically unsubscribed when the last access to the group is older
than a particular threshold. However, for very low traffic groups, the
last access may exceed the threshold simply because there has been no new
article posted. In this case, rather than unsubscribe, update the group
last access time. This means that groups are now only unsubscribed if
the last access exceeds the threshold AND articles have arrived in the
group since. Add Grp_setLastPostTime() to track the last time an article
arrived in the group.
author | bears |
---|---|
date | Sat, 20 Oct 2001 14:23:46 +0100 |
parents | 47569cf4ad4a |
children | b9ef99708d1c |
files | ChangeLog src/client.c src/group.c src/group.h src/noffle.c src/post.c src/server.c |
diffstat | 7 files changed, 105 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Oct 05 16:44:22 2001 +0100 +++ b/ChangeLog Sat Oct 20 14:23:46 2001 +0100 @@ -1,3 +1,18 @@ +Sat Oct 20 2001 Jim Hague <jim.hague@acm.org> + +* src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is + only ever called with last param as time(NULL), so remove it and call + time() inside the implementation of Grp_setLastAccess. +* src/client.c,src/group.h,src/group.c,src/noffle.c,src/post.c: Groups are + automatically unsubscribed when the last access to the group is older + than a particular threshold. However, for very low traffic groups, the + last access may exceed the threshold simply because there has been no new + article posted. In this case, rather than unsubscribe, update the group + last access time. This means that groups are now only unsubscribed if + the last access exceeds the threshold AND articles have arrived in the + group since. Add Grp_setLastPostTime() to track the last time an article + arrived in the group. + Fri Oct 05 2001 Markus Enzenberger <me@markus-enzenberger.de> * src/configfile.c: fix bug with missing initialization of user name and passwd
--- a/src/client.c Fri Oct 05 16:44:22 2001 +0100 +++ b/src/client.c Sat Oct 20 14:23:46 2001 +0100 @@ -1,7 +1,7 @@ /* client.c - $Id: client.c 307 2001-09-12 20:33:44Z bears $ + $Id: client.c 310 2001-10-20 13:23:46Z bears $ */ #if HAVE_CONFIG_H @@ -1029,10 +1029,14 @@ Grp_setRmtNext( client.grp, rmtNumb + 1 ); } if ( oldLast != Cont_last() ) + { Log_inf( "Added %s %lu-%lu", client.grp, oldLast + 1, Cont_last() ); - Log_inf( "%u articles marked for download in %s", cntMarked, client.grp ); - Cont_write(); - Grp_setFirstLast( grp, Cont_first(), Cont_last() ); + Log_inf( "%u articles marked for download in %s", + cntMarked, client.grp ); + Cont_write(); + Grp_setFirstLast( grp, Cont_first(), Cont_last() ); + Grp_setLastPostTime( grp ); + } Lock_closeDatabases(); del_DynStr( response ); del_DynStr( newsgroups );
--- a/src/group.c Fri Oct 05 16:44:22 2001 +0100 +++ b/src/group.c Sat Oct 20 14:23:46 2001 +0100 @@ -7,7 +7,7 @@ loadGrp() and saveGrp(). This is done transparently. Access to the groups database is done by group name, by the functions defined in group.h. - $Id: group.c 300 2001-08-05 08:24:22Z bears $ + $Id: group.c 310 2001-10-20 13:23:46Z bears $ */ #if HAVE_CONFIG_H @@ -42,14 +42,15 @@ Str serv; /* server the group resides on */ Str dsc; /* description of the group */ char postAllow; /* Posting status */ + time_t lastPost; /* Time last article arrived */ GDBM_FILE dbf; -} grp = { "(no grp)", { 0, 0, 0, 0, 0 }, "", "", ' ', NULL }; +} grp = { "(no grp)", { 0, 0, 0, 0, 0 }, "", "", ' ', (time_t) 0, NULL }; /* - Note: postAllow should really go in Entry. But changing Entry would - make backwards group file format capability tricky, so it goes - where it is, and we test the length of the retrieved record to - determine if it exists. + Note: postAllow and lastPost should really go in Entry. But + changing Entry would make backwards group file format capability + tricky, so they go where they are, and we test the length of the + retrieved record to determine if they exist. Someday if we really change the record format this should be tidied up. */ @@ -111,10 +112,24 @@ p += strlen( p ) + 1; Utl_cpyStr( grp.dsc, p ); p += strlen( p) + 1; + + /* + * Extension items. Initialise to default first. + * We default to allowing posting, and the time + * of the last post being a second before the last + * access. + */ + grp.postAllow = 'y'; + grp.lastPost = grp.entry.lastAccess - 1; + if ( p - val.dptr < val.dsize ) + { grp.postAllow = p[ 0 ]; - else - grp.postAllow = 'y'; + p++; + if ( p - val.dptr < val.dsize ) + grp.lastPost = *((time_t *)p); + } + Utl_cpyStr( grp.name, name ); free( val.dptr ); return TRUE; @@ -132,7 +147,9 @@ ASSERT( grp.dbf ); lenServ = strlen( grp.serv ); lenDsc = strlen( grp.dsc ); - bufLen = sizeof( grp.entry ) + lenServ + lenDsc + 2 + sizeof( char ); + bufLen = + sizeof( grp.entry ) + lenServ + lenDsc + 2 + + sizeof( char ) + sizeof( time_t ); buf = malloc( bufLen ); memcpy( buf, (void *)&grp.entry, sizeof( grp.entry ) ); p = (char *)buf + sizeof( grp.entry ); @@ -141,6 +158,8 @@ strcpy( p, grp.dsc ); p += lenDsc + 1; p[ 0 ] = grp.postAllow; + p++; + *((time_t *) p) = grp.lastPost; key.dptr = (void *)grp.name; key.dsize = strlen( grp.name ) + 1; val.dptr = buf; @@ -267,6 +286,14 @@ } +time_t +Grp_lastPostTime( const char *name ) +{ + if ( ! loadGrp( name ) ) + return 0; + return grp.lastPost; +} + /* Replace group's description (only if value != ""). */ void Grp_setDsc( const char *name, const char *value ) @@ -305,11 +332,11 @@ } void -Grp_setLastAccess( const char *name, int value ) +Grp_setLastAccess( const char *name ) { if ( loadGrp( name ) ) { - grp.entry.lastAccess = value; + grp.entry.lastAccess = time( NULL ); saveGrp(); } } @@ -335,6 +362,16 @@ } } +void +Grp_setLastPostTime( const char *name ) +{ + if ( loadGrp( name ) ) + { + grp.lastPost = time( NULL ); + saveGrp(); + } +} + static datum cursor = { NULL, 0 }; Bool
--- a/src/group.h Fri Oct 05 16:44:22 2001 +0100 +++ b/src/group.h Sat Oct 20 14:23:46 2001 +0100 @@ -3,7 +3,7 @@ Groups database - $Id: group.h 183 2000-07-25 12:14:54Z bears $ + $Id: group.h 310 2001-10-20 13:23:46Z bears $ */ #ifndef GRP_H @@ -89,6 +89,9 @@ char Grp_postAllow( const char *name ); +time_t +Grp_lastPostTime( const char *name ); + /* Replace group's description (only if value != ""). */ void Grp_setDsc( const char *name, const char *value ); @@ -103,7 +106,7 @@ Grp_setRmtNext( const char *name, int value ); void -Grp_setLastAccess( const char *name, int value ); +Grp_setLastAccess( const char *name ); void Grp_setFirstLast( const char *name, int first, int last ); @@ -111,6 +114,9 @@ void Grp_setPostAllow( const char *name, char postAllow ); +void +Grp_setLastPostTime( const char *name ); + /* Begin iterating trough the names of all groups. Store name of first group (or NULL if there aren't any) in name. Returns whether there are any groups. */
--- a/src/noffle.c Fri Oct 05 16:44:22 2001 +0100 +++ b/src/noffle.c Sat Oct 20 14:23:46 2001 +0100 @@ -10,7 +10,7 @@ received for some seconds (to allow multiple clients connect at the same time). - $Id: noffle.c 307 2001-09-12 20:33:44Z bears $ + $Id: noffle.c 310 2001-10-20 13:23:46Z bears $ */ #if HAVE_CONFIG_H @@ -272,12 +272,25 @@ && autoUnsubscribe && difftime( now, Grp_lastAccess( grp ) ) > maxAge ) { - Log_ntc( "Auto-unsubscribing from %s after %d " - "days without access", - grp, autoUnsubscribeDays ); - Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays ); - Fetchlist_remove( grp ); - Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED ); + /* If there have been recent posts, unsubscribe. */ + if ( difftime( now, Grp_lastPostTime( grp ) ) <= maxAge ) + { + Log_ntc( "Auto-unsubscribing from %s after %d " + "days without access", + grp, autoUnsubscribeDays ); + Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays ); + Fetchlist_remove( grp ); + Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED ); + } + else + { + /* + * Otherwise if no recent posts touch the access. + * This way we don't unsubscribe to low volume groups + * unread only because there are no recent posts. + */ + Grp_setLastAccess( grp ); + } } Cont_write(); Grp_setFirstLast( grp, Cont_first(), Cont_last() ); @@ -504,7 +517,7 @@ "thread" : "overview" ); if ( ! Fetchlist_write() ) fprintf( stderr, "Could not save fetchlist.\n" ); - Grp_setLastAccess( name, time( NULL ) ); + Grp_setLastAccess( name ); return TRUE; }
--- a/src/post.c Fri Oct 05 16:44:22 2001 +0100 +++ b/src/post.c Sat Oct 20 14:23:46 2001 +0100 @@ -1,7 +1,7 @@ /* post.c - $Id: post.c 300 2001-08-05 08:24:22Z bears $ + $Id: post.c 310 2001-10-20 13:23:46Z bears $ */ #if HAVE_CONFIG_H @@ -99,6 +99,7 @@ Cont_write(); Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() ); + Grp_setLastPostTime( Cont_grp() ); return TRUE; }
--- a/src/server.c Fri Oct 05 16:44:22 2001 +0100 +++ b/src/server.c Sat Oct 20 14:23:46 2001 +0100 @@ -1,7 +1,7 @@ /* server.c - $Id: server.c 307 2001-09-12 20:33:44Z bears $ + $Id: server.c 310 2001-10-20 13:23:46Z bears $ */ #if HAVE_CONFIG_H @@ -128,7 +128,7 @@ { FetchMode mode; - Grp_setLastAccess( server.grp, time( NULL ) ); + Grp_setLastAccess( server.grp ); if ( ! Grp_local ( server.grp ) && ! Online_true() ) { Fetchlist_read(); @@ -1336,7 +1336,7 @@ Ov_date( ov ), Ov_msgId( ov ), Ov_ref( ov ), Ov_bytes( ov ), Ov_lines( ov ) ); putEndOfTxt(); - Grp_setLastAccess( server.grp, time( NULL ) ); + Grp_setLastAccess( server.grp ); return TRUE; }