Commit 252885fa authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(sync_part): Return the number of seconds to wait instead of a Bool.

	All callers updated.
parent b01c1648
/*
* $Id: simple-cache.c,v 0.101 2003/01/10 01:08:15 ceder Exp $
* $Id: simple-cache.c,v 0.102 2003/07/12 00:19:20 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -2427,16 +2427,15 @@ save_one_text(void)
}
/*
* Sync_part() should be called often as long as it returns FALSE.
* Sync_part() returns TRUE when everything is written to a file.
* Sync_part() should be called once in a while even when it returns
* TRUE (because sync() checks to see if it is time to start yet
* another save.)
* Sync_part() should be called often as long as it returns 0. If it
* returns anything else, there is no need to call it again for that
* many seconds, but it is harmless to call it more often than that.
*/
Bool
long
sync_part(void)
{
static time_t last_sync_start = NO_TIME;
long timeleft;
if ( last_sync_start == NO_TIME )
{
......@@ -2466,21 +2465,21 @@ sync_part(void)
case sync_ready:
sync_state = sync_idle;
return TRUE;
return 1;
case sync_idle:
if (param.never_save)
{
return TRUE;
return 60;
}
if (ldifftime(current_time,
last_sync_start) < 60 * param.sync_interval)
if ((timeleft = (60 * param.sync_interval
- ldifftime(current_time, last_sync_start))) > 0)
{
#ifdef LOGACCESSES
syncing_or_saving = 0;
#endif
return TRUE;
return timeleft < 0 ? 0 : timeleft;
}
last_sync_start = current_time;
......@@ -2489,13 +2488,13 @@ sync_part(void)
break;
case sync_wait:
if (ldifftime(current_time, last_sync_start)
< 60*param.sync_retry_interval)
if ((timeleft = (60 * param.sync_retry_interval
- ldifftime(current_time, last_sync_start))) > 0)
{
#ifdef LOGACCESSES
syncing_or_saving = 0;
#endif
return TRUE;
return timeleft < 0 ? 0 : timeleft;
}
last_sync_start = current_time;
......@@ -2539,7 +2538,7 @@ sync_part(void)
syncing_or_saving = 0;
#endif
return FALSE;
return 0;
}
......@@ -2880,7 +2879,7 @@ cache_sync_all(void)
#endif
pre_sync();
while ( sync_part() != TRUE )
while (sync_part() == 0)
;
}
......@@ -2910,7 +2909,7 @@ cache_sync_finish(void)
CHK_CONNECTION(FAILURE);
block_after_pre_sync = 0;
while (sync_part() != TRUE)
while (sync_part() == 0)
;
return OK;
......
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