]>
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"
11 pendingscan
*ps_normalqueue
=NULL
;
12 pendingscan
*ps_prioqueue
=NULL
;
13 pendingscan
*ps_normalqueueend
=NULL
;
15 unsigned int normalqueuedscans
=0;
16 unsigned int prioqueuedscans
=0;
18 unsigned long countpendingscan
=0;
20 void queuescan(patricia_node_t
*node
, short scantype
, unsigned short port
, char class, time_t when
) {
21 pendingscan
*psp
, *psp2
;
23 /* we can just blindly queue the scans as node extension cleanhost cache blocks duplicate scans normally.
24 * Scans may come from:
25 * a) scan <node> (from an oper)
26 * b) newnick handler - which ignores clean hosts, only scans new hosts or dirty hosts
27 * c) adding a new scan type (rare)
30 /* we should never have an internal node */
32 /* reference the node - we either start a or queue a single scan */
33 patricia_ref_prefix(node
->prefix
);
35 /* If there are scans spare, just start it immediately..
36 * provided we're not supposed to wait */
37 if (activescans
< maxscans
&& when
<=time(NULL
) && ps_ready
) {
38 startscan(node
, scantype
, port
, class);
42 /* We have to queue it */
43 if (!(psp
=getpendingscan()))
44 Error("proxyscan",ERR_STOP
,"Unable to allocate memory");
58 if (ps_normalqueueend
) {
59 ps_normalqueueend
->next
=psp
;
60 ps_normalqueueend
=psp
;
62 ps_normalqueueend
=ps_normalqueue
=psp
;
66 if (!ps_prioqueue
|| ps_prioqueue
->when
> when
) {
67 psp
->next
=ps_prioqueue
;
70 for (psp2
=ps_prioqueue
; ;psp2
=psp2
->next
) {
71 if (!psp2
->next
|| psp2
->next
->when
> when
) {
72 psp
->next
= psp2
->next
;
81 void startqueuedscans() {
82 pendingscan
*psp
=NULL
;
84 while (activescans
< maxscans
) {
85 if (ps_prioqueue
&& (ps_prioqueue
->when
<= time(NULL
))) {
87 ps_prioqueue
=psp
->next
;
89 } else if (ps_normalqueue
) {
91 ps_normalqueue
=psp
->next
;
93 ps_normalqueueend
=NULL
;
98 startscan(psp
->node
, psp
->type
, psp
->port
, psp
->class);