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

Re: [leafnode-list] Local newsgroups possible with leafnode-2.0b7 ?



[unnecessary quote levels deleted]

Stefan Wiens wrote:
> krasel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx (Cornelius Krasel) writes:
> 
> >         if ( !stat( ".", &st ) ) {
> >             mtime_dir = st.st_mtime;
> >             if ( !stat(".overview", &st) && (st.st_atime > mtime_dir) ) {
> >                 return 1;
> >             }
> >         }

[...]

> User A: GROUP foo.bar
>         211 2 5 6 foo.bar group selected
>         XOVER 6
>         224 ...
> 
> (A new article is added to the group, and .overview updated.)
> 
> User B: GROUP foo.bar
>         211 3 5 7 foo.bar group selected
>         XOVER 7
>         224 ...
> 
> Now atime of .overview is again newer than mtime of group directory.
> Your above code will return 1, keeping outdated overview data.

This could be fixed by also storing the mtime of the .overview file
in a static variable and comparing it with the mtime of the .overview
file when getxover() is called the next time. It costs no additional
time since .overview is stat()ed anyway.

My (so far untested) code now looks like this:

    static char * lastgroup = NULL;

    ...

    if ( lastgroup && strcmp( groupname, lastgroup ) == 0 ) {
        /* repeated XOVER requests for the same group */
        time_t mtime_dir;

        /* if the last access time of the .overview file is newer than
         * that of the directory, the .overview file is up to date with
         * respect to the contents of the directory. To check whether
         * we are already aware of the new contents, we have stored the
         * mtime of the .overview file last time we read it
         */
        if ( !stat( ".", &st ) ) {
            mtime_dir = st.st_mtime;
            if ( !stat(".overview", &st) && (st.st_atime > mtime_dir) &&
                 (st.st_mtime <= lastchange) ) {
                return 1;
            }
        }
    }

Later in the code, "lastchange" is set to the mtime if ".overview"
exists and to 0 otherwise.

--Cornelius.

-- 
/* Cornelius Krasel, U Wuerzburg, Dept. of Pharmacology, Versbacher Str. 9 */
/* D-97078 Wuerzburg, Germany   email: krasel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx */
/* "Science is the game we play with God to find out what His rules are."  */

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list