Commit 0f131c35 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(garb_timer): New static variable.

(garb_timer_running): Ditto.
(garb_text): Added static qualifier.
(garb_callback): Moved here from connections.c.  Some minor
	modifications made to make it compiler in its new
	environment.
(start_garb_thread): New function.
(stop_garb_thread): New function.
(start_garb): Restart the garb "thread".
parent c3ce9d04
/*
* $Id: text-garb.c,v 0.45 2003/07/12 22:26:35 ceder Exp $
* $Id: text-garb.c,v 0.46 2003/07/13 11:07:07 ceder Exp $
* Copyright (C) 1991-1995, 1997-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -38,6 +38,8 @@
#include <sys/types.h>
#include <setjmp.h>
#include "oop.h"
#include "ldifftime.h"
#include "s-string.h"
#include "kom-types.h"
......@@ -55,6 +57,8 @@
#include "connections.h"
#include "manipulate.h"
#include "text.h"
#include "unused.h"
#include "isc-interface.h"
#ifdef DEBUG_CALLS
# include "send-async.h"
# include "services.h"
......@@ -97,6 +101,9 @@ BUGDECL;
static Text_no last_checked = 0;
static struct timeval garb_timer;
static Bool garb_timer_running = FALSE;
/*
* Delete old texts.
*
......@@ -105,7 +112,7 @@ static Text_no last_checked = 0;
* server has some time over.
*/
Bool
static Bool
garb_text(void)
{
static long deleted_texts = 0;
......@@ -218,7 +225,47 @@ garb_text(void)
tell_cache_garb_text(0);
return FALSE;
}
static void *
garb_callback(oop_source *source,
struct timeval UNUSED(tv),
void *UNUSED(user))
{
if (server_idle())
{
set_time();
if (garb_text() == FALSE)
setup_timer(&garb_timer, param.garbtimeout);
else
setup_timer(&garb_timer, param.garb_interval);
}
else
setup_timer(&garb_timer, param.garb_busy_postponement);
source->on_time(source, garb_timer, garb_callback, NULL);
return OOP_CONTINUE;
}
void
start_garb_thread(oop_source *src)
{
stop_garb_thread(src);
garb_timer = OOP_TIME_NOW;
src->on_time(src, garb_timer, garb_callback, NULL);
garb_timer_running = TRUE;
}
void
stop_garb_thread(oop_source *src)
{
if (garb_timer_running)
{
src->cancel_time(src, garb_timer, garb_callback, NULL);
garb_timer_running = FALSE;
}
}
#ifdef DEBUG_CALLS
Success
start_garb(void)
......@@ -226,6 +273,7 @@ start_garb(void)
CHK_CONNECTION(FAILURE);
kom_log("MSG: garb restarted.\n");
last_checked = 0;
start_garb_thread(oop_sys_source(kom_server_oop_src));
return OK;
}
#endif
Supports Markdown
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