]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanqueue.c
3 * Handle the scan queues
7 #include "../irc/irc.h"
9 pendingscan
*ps_normalqueue
=NULL
;
10 pendingscan
*ps_prioqueue
=NULL
;
11 pendingscan
*ps_normalqueueend
=NULL
;
13 unsigned int normalqueuedscans
=0;
14 unsigned int prioqueuedscans
=0;
16 unsigned long countpendingscan
=0;
18 void queuescan(unsigned int IP
, short scantype
, unsigned short port
, char class, time_t when
) {
19 pendingscan
*psp
, *psp2
;
21 /* check if the IP/port combo is already queued - don't queue up
22 * multiple identical scans
27 if (psp
->IP
== IP
&& psp
->type
== scantype
&&
28 psp
->port
== port
&& psp
->class == class)
30 /* found it, ignore */
39 if (psp
->IP
== IP
&& psp
->type
== scantype
&&
40 psp
->port
== port
&& psp
->class == class)
42 /* found it, ignore */
48 /* If there are scans spare, just start it immediately..
49 * provided we're not supposed to wait */
50 if (activescans
< maxscans
&& when
<=time(NULL
) && (ps_start_ts
+120 <= time(NULL
))) {
51 startscan(IP
, scantype
, port
, class);
55 /* We have to queue it */
56 psp
= (struct pendingscan
*) malloc(sizeof(pendingscan
));
59 /* shutdown due to no memory */
60 irc_send("%s SQ %s 0 :Out of memory - exiting.",mynumeric
->content
,myserver
->content
);
76 if (ps_normalqueueend
) {
77 ps_normalqueueend
->next
=psp
;
78 ps_normalqueueend
=psp
;
80 ps_normalqueueend
=ps_normalqueue
=psp
;
84 if (!ps_prioqueue
|| ps_prioqueue
->when
> when
) {
85 psp
->next
=ps_prioqueue
;
88 for (psp2
=ps_prioqueue
; ;psp2
=psp2
->next
) {
89 if (!psp2
->next
|| psp2
->next
->when
> when
) {
90 psp
->next
= psp2
->next
;
99 void startqueuedscans() {
100 pendingscan
*psp
=NULL
;
102 if (ps_start_ts
+120 > time(NULL
))
105 while (activescans
< maxscans
) {
106 if (ps_prioqueue
&& (ps_prioqueue
->when
<= time(NULL
))) {
108 ps_prioqueue
=psp
->next
;
110 } else if (ps_normalqueue
) {
112 ps_normalqueue
=psp
->next
;
114 ps_normalqueueend
=NULL
;
119 startscan(psp
->IP
, psp
->type
, psp
->port
, psp
->class);