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

(boottime_info): New static variable.

(init_cache): Initialize boottime_info.  Update STAT_CONFS and
	STAT_PERSONS.
(get_boottime_info): New request.
parent dbf5d3f0
/*
* $Id: simple-cache.c,v 0.108 2003/08/11 10:55:36 ceder Exp $
* $Id: simple-cache.c,v 0.109 2003/08/11 22:16:28 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -232,6 +232,10 @@ static void log_access(enum log_type t,
#define LOGACC(a,b)
#endif
static Static_server_info boottime_info = {
0, 0, EMPTY_STRING_i, 0, 0, 0, 0, 0
};
/* Local functions */
......@@ -2584,6 +2588,8 @@ init_cache(void)
struct timeval saved_time;
long record;
boottime_info.boot_time = current_time.tv_sec;
small_conf_arr = smalloc(sizeof(*small_conf_arr) * param.max_conf);
pers_mcb = create_cache_node_mcb(100, param.max_conf);
conf_mcb = create_cache_node_mcb(100, param.max_conf);
......@@ -2641,6 +2647,7 @@ init_cache(void)
}
kom_log("MSG: init_cache: using datafile.\n");
datafile_version = get_version(param.datafile_name);
boottime_info.db_status = s_fcrea_str("clean");
}
else if (is_clean(param.backupfile_name))
{
......@@ -2653,6 +2660,7 @@ init_cache(void)
}
kom_log("MSG: init_cache: using backup file.\n");
datafile_version = get_version(param.backupfile_name);
boottime_info.db_status = s_fcrea_str("backup");
}
else
{
......@@ -2688,6 +2696,7 @@ init_cache(void)
}
kom_log("Database saved on %s", /* ctime returns a trailing newline. */
ctime(&saved_time.tv_sec));
boottime_info.save_time = saved_time.tv_sec;
break;
default:
restart_kom("Can't read database version %ld. Giving up.\n",
......@@ -2736,8 +2745,12 @@ init_cache(void)
node = get_conf_node(num);
if (node)
{
node->s.exists = 0;
node->pos = -1;
if (node->s.exists)
{
update_stat(STAT_CONFS, -1);
node->s.exists = 0;
node->pos = -1;
}
}
break;
......@@ -2746,8 +2759,12 @@ init_cache(void)
node = get_pers_node(num);
if (node)
{
node->s.exists = 0;
node->pos = -1;
if (node->s.exists)
{
update_stat(STAT_PERSONS, -1);
node->s.exists = 0;
node->pos = -1;
}
}
break;
......@@ -2792,6 +2809,7 @@ init_cache(void)
{
create_cache_node(conf_mcb, num);
node = get_conf_node(num);
update_stat(STAT_CONFS, 1);
}
node->s.exists = 1;
......@@ -2817,6 +2835,7 @@ init_cache(void)
{
create_cache_node(pers_mcb, num);
node = get_pers_node(num);
update_stat(STAT_PERSONS, 1);
}
node->s.exists = 1;
......@@ -2875,10 +2894,16 @@ init_cache(void)
kom_log("Read %d confs/persons and %ld texts\n",
next_free_num, next_text_num);
next_free_num, next_text_num);
read_number_file();
boottime_info.highest_text_no = next_text_num - 1;
boottime_info.highest_conf_no = next_free_num - 1;
boottime_info.existing_texts = read_stat_value(STAT_TEXTS);
boottime_info.existing_confs = read_stat_value(STAT_CONFS);
boottime_info.existing_persons = read_stat_value(STAT_PERSONS);
return OK;
}
......@@ -3190,3 +3215,10 @@ tell_cache_garb_text(int running)
#endif
}
Success
get_boottime_info(Static_server_info *result)
{
CHK_CONNECTION(FAILURE);
*result = boottime_info;
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