Commit d04212ac authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(init_cache): Don't print false error messages when the -L option is not given.

(sync_part): Prevent lyskomd from looping endlessly when the server is
shut down, by always returning TRUE when a save cycle is finished
(even if a new cycle should be initiated immediately).
Include tmp-difftime.h.
parent 7bdfdd09
/*
* $Id: simple-cache.c,v 0.31 1993/01/16 23:18:24 ceder Exp $
* $Id: simple-cache.c,v 0.32 1993/08/05 01:06:12 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.31 1993/01/16 23:18:24 ceder Exp $";
static char *rcsid = "$Id: simple-cache.c,v 0.32 1993/08/05 01:06:12 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -77,6 +77,8 @@ USE(rcsid);
#include "memory.h"
#include "exp.h"
#include "tmp-difftime.h"
#include "tmp-limits.h"
#include "cache-node.h"
#include "disk-cache.h"
......@@ -886,7 +888,7 @@ cached_get_text_stat( Text_no text )
*/
extern Text_no
cached_create_text( String message)
cached_create_text(const String message)
{
Text_no tno;
Cache_node *node;
......@@ -1793,6 +1795,14 @@ sync_part(void)
break;
case sync_ready:
#if 0
/* This doesn't work. It causes the server to enter an
infinite loop when it is exiting if it takes more than
SYNC_INTERVAL minutes to save the text. The fix below is
not perfect; if it takes more than SYNC_INTERVAL minutes to
save the data base the server will pause for TIMEOUT ms
instead of SYNCTIMEOUT ms once. A real event queue should
be implemented to fix this. +++ */
if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_INTERVAL )
{
#ifdef LOGACCESSES
......@@ -1804,6 +1814,12 @@ sync_part(void)
last_sync_start = time(NULL);
pre_sync();
#else /* This works, but it might take too long a pause. */
#ifdef LOGACCESSES
syncing_or_saving = 0;
#endif
return TRUE;
#endif /* 1 */
break;
case sync_wait:
......@@ -1874,12 +1890,14 @@ init_cache(void)
#ifdef LOGACCESSES
if (logaccess_file)
{
logfile = fopen(logaccess_file, "a");
if (logfile)
log("Logging db accesses to %s.\n", logaccess_file);
else
log("Failed to open db log file %s. Ignoring -L option.\n",
logaccess_file);
if (logfile)
log("Logging db accesses to %s.\n", logaccess_file);
else
log("Failed to open db log file %s. Ignoring -L option.\n",
logaccess_file);
}
#endif
LOGACC(lt_restart, time(NULL));
......
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