Updated event.c thanks to a member of the hybrid team :)
This commit is contained in:
parent
3057920db9
commit
a2ed4e903b
2 changed files with 26 additions and 28 deletions
|
@ -6,6 +6,8 @@ Symbols are:
|
|||
(HP) - Hybrid Team Patches to Hybrid Source
|
||||
|
||||
* NeoIRCd Version 0.9.4 - 24th Sept, 2002 - Fish
|
||||
(S) - Fixed up event.c for a possible serious bug reported by Dianora from hybrid team
|
||||
Also thanks for the reference and event code in question.
|
||||
(F) - Changed HiddenHost System to Use Ultimates version instead...
|
||||
(F) - Changed NICK and Client Messages to include vhost, so we dont have to burst SETHOST
|
||||
(F) - Don't burst SETHOST when we remove -x
|
||||
|
|
36
src/event.c
36
src/event.c
|
@ -38,7 +38,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: event.c,v 1.3 2002/09/13 06:50:08 fishwaldo Exp $
|
||||
* $Id: event.c,v 1.4 2002/09/29 00:20:14 shmad Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -61,7 +61,6 @@
|
|||
|
||||
static const char *last_event_ran = NULL;
|
||||
struct ev_entry event_table[MAX_EVENTS];
|
||||
static int event_count = 0;
|
||||
static time_t event_time_min = -1;
|
||||
|
||||
|
||||
|
@ -80,13 +79,10 @@ eventAdd(const char *name, EVH *func, void *arg, time_t when)
|
|||
int i;
|
||||
|
||||
/* find first inactive index, or use next index */
|
||||
for (i = 0; i < event_count; i++)
|
||||
if (!event_table[i].active)
|
||||
break;
|
||||
|
||||
if (i >= event_count)
|
||||
event_count = i + 1;
|
||||
|
||||
for (i = 0; i < MAX_EVENTS; i++)
|
||||
{
|
||||
if (event_table[i].active == 0)
|
||||
{
|
||||
event_table[i].func = func;
|
||||
event_table[i].name = name;
|
||||
event_table[i].arg = arg;
|
||||
|
@ -96,6 +92,10 @@ eventAdd(const char *name, EVH *func, void *arg, time_t when)
|
|||
|
||||
if ((event_table[i].when < event_time_min) || (event_time_min == -1))
|
||||
event_time_min = event_table[i].when;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* XXX if reach here, its an error */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -160,10 +160,7 @@ eventRun(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (event_count == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < event_count; i++)
|
||||
for (i = 0; i < MAX_EVENTS; i++)
|
||||
{
|
||||
if (event_table[i].active && (event_table[i].when <= CurrentTime))
|
||||
{
|
||||
|
@ -189,11 +186,9 @@ eventNextTime(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (event_count == 0)
|
||||
return (CurrentTime+1);
|
||||
else if (event_time_min == -1)
|
||||
if (event_time_min == -1)
|
||||
{
|
||||
for (i = 0; i < event_count; i++)
|
||||
for (i = 0; i < MAX_EVENTS; i++)
|
||||
{
|
||||
if (event_table[i].active && ((event_table[i].when < event_time_min) || (event_time_min == -1)))
|
||||
event_time_min = event_table[i].when;
|
||||
|
@ -213,6 +208,7 @@ void
|
|||
eventInit(void)
|
||||
{
|
||||
last_event_ran = NULL;
|
||||
memset((void *)event_table, 0, sizeof(event_table));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -227,7 +223,7 @@ int
|
|||
eventFind(EVH *func, void *arg)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < event_count; i++)
|
||||
for (i = 0; i < MAX_EVENTS; i++)
|
||||
{
|
||||
if ((event_table[i].func == func) &&
|
||||
(event_table[i].arg == arg) &&
|
||||
|
@ -259,7 +255,7 @@ show_events(struct Client *source_p)
|
|||
":%s NOTICE %s :*** Operation Next Execution",
|
||||
me.name, source_p->name);
|
||||
|
||||
for (i = 0; i < event_count; i++)
|
||||
for (i = 0; i < MAX_EVENTS; i++)
|
||||
{
|
||||
if (event_table[i].active)
|
||||
{
|
||||
|
@ -282,7 +278,7 @@ void
|
|||
set_back_events(time_t by)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < event_count; i++)
|
||||
for (i = 0; i < MAX_EVENTS; i++)
|
||||
if (event_table[i].when > by)
|
||||
event_table[i].when -= by;
|
||||
else
|
||||
|
|
Reference in a new issue