]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanqueue.c
3 * Handle the scan queues
7 #include "../irc/irc.h"
8 #include "../core/error.h"
10 pendingscan
*ps_normalqueue
=NULL
;
11 pendingscan
*ps_prioqueue
=NULL
;
12 pendingscan
*ps_normalqueueend
=NULL
;
14 unsigned int normalqueuedscans
=0;
15 unsigned int prioqueuedscans
=0;
17 unsigned long countpendingscan
=0;
19 void queuescan(patricia_node_t
*node
, short scantype
, unsigned short port
, char class, time_t when
) {
20 pendingscan
*psp
, *psp2
;
22 /* we can just blindly queue the scans as node extension cleanhost cache blocks duplicate scans normally.
23 * Scans may come from:
24 * a) scan <node> (from an oper)
25 * b) newnick handler - which ignores clean hosts, only scans new hosts or dirty hosts
26 * c) adding a new scan type (rare)
29 /* If there are scans spare, just start it immediately..
30 * provided we're not supposed to wait */
31 if (activescans
< maxscans
&& when
<=time(NULL
) && ps_ready
) {
32 startscan(node
, scantype
, port
, class);
36 /* We have to queue it */
37 if (!(psp
=getpendingscan()))
38 Error("proxyscan",ERR_STOP
,"Unable to allocate memory");
52 if (ps_normalqueueend
) {
53 ps_normalqueueend
->next
=psp
;
54 ps_normalqueueend
=psp
;
56 ps_normalqueueend
=ps_normalqueue
=psp
;
60 if (!ps_prioqueue
|| ps_prioqueue
->when
> when
) {
61 psp
->next
=ps_prioqueue
;
64 for (psp2
=ps_prioqueue
; ;psp2
=psp2
->next
) {
65 if (!psp2
->next
|| psp2
->next
->when
> when
) {
66 psp
->next
= psp2
->next
;
75 void startqueuedscans() {
76 pendingscan
*psp
=NULL
;
78 while (activescans
< maxscans
) {
79 if (ps_prioqueue
&& (ps_prioqueue
->when
<= time(NULL
))) {
81 ps_prioqueue
=psp
->next
;
83 } else if (ps_normalqueue
) {
85 ps_normalqueue
=psp
->next
;
87 ps_normalqueueend
=NULL
;
92 startscan(psp
->node
, psp
->type
, psp
->port
, psp
->class);