Commit 5358f3e5 authored by Per Cederqvist's avatar Per Cederqvist

throwable_p(): New function.

limit_pers(), limit_conf(), limit_text_stat(): Use it, and get the
test right.
parent 67dd25e8
/*
* $Id: simple-cache.c,v 0.21 1992/03/24 17:41:05 ceder Exp $
* $Id: simple-cache.c,v 0.22 1992/04/09 09:21:11 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -33,7 +33,7 @@
* New save algorithm by ceder.
*/
static char *rcsid = "$Id: simple-cache.c,v 0.21 1992/03/24 17:41:05 ceder Exp $";
static char *rcsid = "$Id: simple-cache.c,v 0.22 1992/04/09 09:21:11 ceder Exp $";
......@@ -1963,6 +1963,17 @@ free_all_cache (void)
}
/* Is it allowed to delete this node from the cache? It is, unless
the node is locked, dirty, or contains a snap-shot. */
static Bool
throwable_p(Cache_node *node)
{
return (node->s.dirty == 0
&& node->snap_shot == NULL
&& node->lock_cnt == 0);
}
static void
limit_pers(void)
{
......@@ -1974,11 +1985,8 @@ limit_pers(void)
/* Skip first CACHE_PERSONS clean persons. */
for ( i = 0; node != NULL && i < CACHE_PERSONS; i++ )
{
while ( node != NULL && node->s.dirty == 0
&& node->snap_shot == NULL && node->lock_cnt == 0 )
{
while (node != NULL && !throwable_p(node))
node = node->next;
}
if ( node != NULL )
node = node->next;
......@@ -1987,8 +1995,7 @@ limit_pers(void)
/* Delete any remaining clean persons */
while ( node != NULL )
{
if ( node->s.dirty == 0 && node->snap_shot == NULL
&& node->lock_cnt == 0 )
if (throwable_p(node))
{
unlink_pers_lru(node);
free_person (node->ptr);
......@@ -2011,11 +2018,8 @@ limit_conf(void)
/* Skip first CACHE_CONFERENCES clean confs. */
for ( i = 0; node != NULL && i < CACHE_CONFERENCES; i++ )
{
while ( node != NULL && node->s.dirty == 0
&& node->snap_shot == NULL && node->lock_cnt == 0 )
{
while (node != NULL && !throwable_p(node))
node = node->next;
}
if ( node != NULL )
node = node->next;
......@@ -2024,8 +2028,7 @@ limit_conf(void)
/* Delete any remaining clean confs. */
while ( node != NULL )
{
if ( node->s.dirty == 0 && node->snap_shot == NULL
&& node->lock_cnt == 0 )
if (throwable_p(node))
{
unlink_conf_lru(node);
free_conference (node->ptr);
......@@ -2049,21 +2052,17 @@ limit_text_stat(void)
/* Skip first CACHE_TEXT_STATS clean text_stats. */
for ( i = 0; node != NULL && i < CACHE_TEXT_STATS; i++ )
{
while ( node != NULL && node->s.dirty == 0
&& node->snap_shot == NULL && node->lock_cnt == 0 )
{
while (node != NULL && !throwable_p(node))
node = node->next;
}
if ( node != NULL )
if (node != NULL)
node = node->next;
}
/* Delete any remaining clean text_stats. */
while ( node != NULL )
{
if ( node->s.dirty == 0 && node->snap_shot == NULL
&& node->lock_cnt == 0 )
if (throwable_p(node))
{
unlink_text_lru(node);
free_text_stat (node->ptr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment