Commit 1453ac80 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Undid changes between 0.25 and 0.26.

parent 24921523
#define LOGFILE "/users/ceder/log-from-lyskom"
/*
* $Id: simple-cache.c,v 0.26 1992/10/27 04:42:51 ceder Exp $
* $Id: simple-cache.c,v 0.27 1992/11/02 18:46:31 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -34,7 +33,7 @@
* New save algorithm by ceder.
*/
static char *rcsid = "$Id: simple-cache.c,v 0.26 1992/10/27 04:42:51 ceder Exp $";
static char *rcsid = "$Id: simple-cache.c,v 0.27 1992/11/02 18:46:31 ceder Exp $";
......@@ -125,9 +124,6 @@ static Text_no highest_text_no;
BUGDECL;
#ifdef LOGFILE
static FILE *logfile=NULL;
#endif
/* Macros */
......@@ -214,24 +210,10 @@ conf_set_mru(Conf_no conf_no)
static Cache_node *
get_pers_node(Pers_no pers_no)
{
#ifdef LOGFILE
Cache_node *res;
#endif
if ( pers_no >= next_free_num )
return NULL;
#ifndef LOGFILE
return get_cache_node(pers_mcb, pers_no);
#else
res = get_cache_node(pers_mcb, pers_no);
if (logfile)
{
putc(0, logfile);
putw(pers_no, logfile);
}
return res;
#endif
}
static void
......@@ -255,49 +237,19 @@ unlink_pers_lru (Cache_node *node)
static Cache_node *
get_conf_node(Conf_no conf_no)
{
#ifdef LOGFILE
Cache_node *res;
#endif
if ( conf_no >= next_free_num )
return NULL;
#ifndef LOGFILE
return get_cache_node(conf_mcb, conf_no);
#else
res = get_cache_node(conf_mcb, conf_no);
if (logfile)
{
putc(1, logfile);
putw(conf_no, logfile);
}
return res;
#endif
}
static Cache_node *
get_text_node(Text_no text_no)
{
#ifdef LOGFILE
Cache_node *res;
#endif
if ( text_no >= next_text_num )
return NULL;
#ifndef LOGFILE
return get_cache_node(text_mcb, text_no);
#else
res = get_cache_node(text_mcb, text_no);
if(logfile)
{
putc(2, logfile);
putw(text_no, logfile);
}
return res;
#endif
}
......@@ -770,13 +722,6 @@ cached_get_text( Text_no text )
return EMPTY_STRING;
else
{
#ifdef LOGFILE
if(logfile)
{
putc(5, logfile);
putw(text, logfile);
}
#endif
the_string.string = tmp_alloc( t_stat->no_of_chars );
the_string.len = t_stat->no_of_chars;
fseek(text_file, t_stat->file_pos, SEEK_SET);
......@@ -999,13 +944,6 @@ cached_lock_person(Pers_no pers_no)
}
node->lock_cnt++;
#ifdef LOGFILE
if(logfile)
{
putc(6, logfile);
putw(pers_no, logfile);
}
#endif
}
/* Decrease reference count. If zero, unlock person. */
......@@ -1028,13 +966,6 @@ cached_unlock_person(Pers_no pers_no)
}
else
node->lock_cnt--;
#ifdef LOGFILE
if(logfile)
{
putc(7, logfile);
putw(pers_no, logfile);
}
#endif
}
......@@ -1069,13 +1000,6 @@ cached_lock_conf(Conf_no conf_no)
}
node->lock_cnt++;
#ifdef LOGFILE
if(logfile)
{
putc(8, logfile);
putw(conf_no, logfile);
}
#endif
}
/* Decrease reference count. If zero, unlock conf. */
......@@ -1097,14 +1021,6 @@ cached_unlock_conf(Conf_no conf_no)
}
else
node->lock_cnt--;
#ifdef LOGFILE
if(logfile)
{
putc(9, logfile);
putw(conf_no, logfile);
}
#endif
}
......@@ -1745,11 +1661,6 @@ Bool
sync_part(void)
{
static time_t last_sync_start = NO_TIME;
#ifdef LOGFILE
FILE *lfsave = logfile;
logfile = NULL;
#endif
if ( last_sync_start == NO_TIME )
{
......@@ -1773,34 +1684,16 @@ sync_part(void)
case sync_ready:
if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_INTERVAL )
{
#ifdef LOGFILE
logfile = lfsave;
#endif
return TRUE;
}
last_sync_start = time(NULL);
#ifdef LOGFILE
if(lfsave)
{
putc(255, lfsave);
putw(-1, lfsave);
putc(10, lfsave);
putw(time(NULL), lfsave);
}
#endif
pre_sync();
break;
case sync_wait:
if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_RETRY_INTERVAL )
{
#ifdef LOGFILE
logfile = lfsave;
#endif
return TRUE;
}
last_sync_start = time(NULL);
......@@ -1823,9 +1716,6 @@ sync_part(void)
if ( file_b != NULL && ferror(file_b) != 0)
sync_state = sync_error;
#ifdef LOGFILE
logfile = lfsave;
#endif
return FALSE;
}
......@@ -1854,20 +1744,6 @@ init_cache(void)
Person tmp_pers = EMPTY_PERSON;
Text_stat tmp_text = EMPTY_TEXT_STAT;
#ifdef LOGFILE
logfile = fopen(LOGFILE, "a");
if (logfile == NULL)
{
log("MSG: can not open cache-status logfile.\n");
}
else
{
putc(255, logfile);
putw(-1, logfile);
putc(3, logfile);
putw(time(NULL), logfile);
}
#endif
pers_mcb = create_cache_node_mcb(100, MAX_CONF);
conf_mcb = create_cache_node_mcb(100, MAX_CONF);
text_mcb = create_cache_node_mcb(100, MAX_TEXT);
......@@ -1995,14 +1871,6 @@ init_cache(void)
log("Read %d confs/persons and %d texts\n",
next_free_num, next_text_num);
#ifdef LOGFILE
if(logfile)
{
putc(4, logfile);
putw(time(NULL), logfile);
}
#endif
return OK;
}
......@@ -2026,12 +1894,6 @@ free_all_cache (void)
int i;
Cache_node *node;
#ifdef LOGFILE
if(logfile)
fclose(logfile); /* Stop gathering data. */
logfile = NULL;
#endif
for ( i = 0; i < next_free_num; i++ )
{
node = get_conf_node(i);
......
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