Commit 81473aac authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(init_cache): Use a new local variable, "record", to count the records

	in the database file.  Don't reuse the "ic" variable for that
	purpose.  Call update_stat with STAT_TEXTS to updated the
	number of existing texts.
parent 7ce7ede6
/*
* $Id: simple-cache.c,v 0.106 2003/07/13 07:01:44 ceder Exp $
* $Id: simple-cache.c,v 0.107 2003/07/27 15:02:55 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -89,6 +89,7 @@
#include "server-time.h"
#include "eintr.h"
#include "timeval-util.h"
#include "stats.h"
#ifdef DEBUG_CALLS
# include "services.h"
......@@ -2572,6 +2573,7 @@ init_cache(void)
Bool read_conf_no = FALSE;
int c = 0;
struct timeval saved_time;
long record;
small_conf_arr = smalloc(sizeof(*small_conf_arr) * param.max_conf);
pers_mcb = create_cache_node_mcb(100, param.max_conf);
......@@ -2685,11 +2687,7 @@ init_cache(void)
set_input_format(datafile_version);
/*
* Read conferences
*/
for (ic = 1; !done ; ic++) /* CONFS */
for (record = 1; !done ; record++)
{
fskipwhite(file_a);
switch(c = getc(file_a))
......@@ -2749,8 +2747,12 @@ init_cache(void)
node = get_text_node(num);
if (node)
{
node->s.exists = 0;
node->pos = -1;
if (node->s.exists)
{
update_stat(STAT_TEXTS, -1);
node->s.exists = 0;
node->pos = -1;
}
}
break;
......@@ -2773,7 +2775,7 @@ init_cache(void)
{
restart_kom("ERROR: init_cache(), bad conf_no %ld"
" at record %ld\n",
num, (long)ic);
num, record);
}
node = get_conf_node(num);
......@@ -2787,8 +2789,9 @@ init_cache(void)
node->pos = pos;
if ( fparse_conference(file_a, &tmp_conf) != OK )
restart_kom("init_cache(): fparse_conference(%ld) failed.\n",
(long)ic);
restart_kom("init_cache(): fparse_conference() failed"
" at record %ld.\n",
record);
node->size = ftell(file_a) - node->pos;
setup_small_conf(num, &tmp_conf);
......@@ -2811,8 +2814,9 @@ init_cache(void)
node->pos = pos;
if ( fparse_person(file_a, &tmp_pers) != OK )
restart_kom("init_cache: fparse_person failed. ic==%ld\n",
(long)ic);
restart_kom("init_cache: fparse_person failed at"
" record %ld.\n",
record);
node->size = ftell(file_a) - node->pos;
clear_person(&tmp_pers);
......@@ -2829,6 +2833,7 @@ init_cache(void)
{
create_cache_node(text_mcb, num);
node = get_text_node(num);
update_stat(STAT_TEXTS, 1);
}
node->s.exists = 1;
......@@ -2836,8 +2841,9 @@ init_cache(void)
node->pos = pos;
if ( fparse_text_stat(file_a, &tmp_text) != OK )
restart_kom("init_cache(): fparse_text_stat failed. ic==%ld\n",
(long)ic);
restart_kom("init_cache(): fparse_text_stat failed at"
" record %ld.\n",
record);
node->size = ftell(file_a) - node->pos;
clear_text_stat(&tmp_text);
......
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