]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/event.cc
3 * $Id: event.cc,v 1.9 1997/11/05 05:29:23 wessels Exp $
5 * DEBUG: section 41 Event Processing
6 * AUTHOR: Henrik Nordstrom
8 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
9 * --------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from the
12 * Internet community. Development is led by Duane Wessels of the
13 * National Laboratory for Applied Network Research and funded by
14 * the National Science Foundation.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34 /* The list of event processes */
40 struct ev_entry
*next
;
43 static struct ev_entry
*tasks
= NULL
;
46 eventAdd(const char *name
, EVH
* func
, void *arg
, time_t when
)
48 struct ev_entry
*event
= xcalloc(1, sizeof(struct ev_entry
));
53 event
->when
= squid_curtime
+ when
;
54 debug(41, 7) ("eventAdd: Adding '%s', in %d seconds\n", name
, when
);
55 /* Insert after the last event with the same or earlier time */
56 for (E
= &tasks
; *E
; E
= &(*E
)->next
) {
57 if ((*E
)->when
> event
->when
)
65 eventDelete(EVH
* func
, void *arg
)
68 struct ev_entry
*event
;
69 for (E
= &tasks
; (event
= *E
) != NULL
; E
= &(*E
)->next
) {
70 if (event
->func
!= func
)
72 if (event
->arg
!= arg
)
78 debug_trap("eventDelete: event not found");
84 struct ev_entry
*event
= NULL
;
87 if ((event
= tasks
) == NULL
)
89 if (event
->when
> squid_curtime
)
91 debug(41, 7) ("eventRun: Running '%s'\n", event
->name
);
106 return tasks
->when
- squid_curtime
;