Commit 0704aede authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(milli_timevaldiff): Removed.

(dump_statistics): Use current_time instead of calling time().
(toploop): Call time once per select loop instead of calling
	gettimeofday twice.  Simplify the computation of the timeout.
parent 5da16998
/*
* $Id: connections.c,v 0.58 1999/05/12 13:25:04 byers Exp $
* $Id: connections.c,v 0.59 1999/05/16 21:45:47 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -36,7 +36,7 @@
#endif
static const char *
rcsid = "$Id: connections.c,v 0.58 1999/05/12 13:25:04 byers Exp $";
rcsid = "$Id: connections.c,v 0.59 1999/05/16 21:45:47 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -91,6 +91,7 @@ USE(rcsid);
#include "kom-config.h"
#include "kom-errno.h"
#include "sigflags.h"
#include "server-time.h"
IscMaster * kom_server_mcb = NULL;
Connection * active_connection = NULL;
......@@ -459,7 +460,6 @@ dump_statistics(void)
{
static time_t last_dump = NO_TIME;
int i;
time_t now;
FILE *fp;
if ((fp = fopen(param.statistic_name, "a")) == NULL)
......@@ -470,16 +470,14 @@ dump_statistics(void)
return;
}
time(&now);
if (last_dump == NO_TIME)
{
fprintf(fp, "RESTART\n");
last_dump = now;
last_dump = current_time;
}
fprintf(fp, "TIME: %s", ctime(&now));
fprintf(fp, "SECONDS: %d\n", (int)ldifftime(now, last_dump));
fprintf(fp, "TIME: %s", ctime(&current_time));
fprintf(fp, "SECONDS: %d\n", (int)ldifftime(current_time, last_dump));
fprintf(fp, "STATISTICS:");
for ( i = 0; (size_t)i < sizeof(service_statistics) / sizeof(unsigned long); i++)
{
......@@ -493,7 +491,7 @@ dump_statistics(void)
fprintf(fp, "\n");
fclose(fp);
last_dump = now;
last_dump = current_time;
}
/* List of connections to kill. */
......@@ -653,13 +651,6 @@ message_request(IscEvent *event)
parse_message(cp, tmp_str);
}
static long
milli_timevaldiff(struct timeval a,
struct timeval b)
{
return 1000 * (a.tv_sec - b.tv_sec) + (a.tv_usec - b.tv_usec) / 1000;
}
void
toploop(void)
{
......@@ -671,8 +662,6 @@ toploop(void)
long timeout = 0; /* In milliseconds. Start with a
small value since we should
start garbing right away. */
struct timeval before, after;
while ( !go_and_die )
{
if (do_statistics)
......@@ -681,16 +670,12 @@ toploop(void)
do_statistics = 0;
}
gettimeofday(&before, NULL);
event = isc_getnextevent(kom_server_mcb,
pending_input ? 0 : timeout );
gettimeofday(&after, NULL);
timeout -= milli_timevaldiff(after, before);
current_time = time(NULL);
timeout = 0;
if ( timeout < 0 )
timeout = 0;
if ( event == NULL )
restart_kom("toploop(): Got NULL event - shouldn't happen...\n");
......@@ -714,12 +699,7 @@ toploop(void)
if ( pending_input == FALSE )
timeout = end_of_atomic(TRUE); /* Idle. Do some cleaning up. */
else
{
if ( timeout == 0 )
end_of_atomic(FALSE);
pending_input = (parse_forgotten() ? FALSE : TRUE);
}
break;
......
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