]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanqueue.c
3 * Handle the scan queues
8 pendingscan
*ps_normalqueue
=NULL
;
9 pendingscan
*ps_prioqueue
=NULL
;
10 pendingscan
*ps_normalqueueend
=NULL
;
12 unsigned int normalqueuedscans
=0;
13 unsigned int prioqueuedscans
=0;
15 void queuescan(unsigned int IP
, short scantype
, unsigned short port
, char class, time_t when
) {
16 pendingscan
*psp
, *psp2
;
18 /* If there are scans spare, just start it immediately..
19 * provided we're not supposed to wait */
20 if (activescans
< maxscans
&& when
<=time(NULL
)) {
21 startscan(IP
, scantype
, port
, class);
25 /* We have to queue it */
37 if (ps_normalqueueend
) {
38 ps_normalqueueend
->next
=psp
;
39 ps_normalqueueend
=psp
;
41 ps_normalqueueend
=ps_normalqueue
=psp
;
45 if (!ps_prioqueue
|| ps_prioqueue
->when
> when
) {
46 psp
->next
=ps_prioqueue
;
49 for (psp2
=ps_prioqueue
; ;psp2
=psp2
->next
) {
50 if (!psp2
->next
|| psp2
->next
->when
> when
) {
51 psp
->next
= psp2
->next
;
60 void startqueuedscans() {
61 pendingscan
*psp
=NULL
;
63 while (activescans
< maxscans
) {
64 if (ps_prioqueue
&& ps_prioqueue
->when
<= time(NULL
)) {
66 ps_prioqueue
=psp
->next
;
68 } else if (ps_normalqueue
) {
70 ps_normalqueue
=psp
->next
;
72 ps_normalqueueend
=NULL
;
77 startscan(psp
->IP
, psp
->type
, psp
->port
, psp
->class);