]> jfr.im git - irc/quakenet/newserv.git/blobdiff - proxyscan/proxyscanqueue.c
merge
[irc/quakenet/newserv.git] / proxyscan / proxyscanqueue.c
index 2ea410af6360349a298717e77a42b102a56fe66b..e37ae751bc72e99653a07c3f94a203942a0b755a 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "proxyscan.h"
 #include "../irc/irc.h"
+#include "../core/error.h"
 
 pendingscan *ps_normalqueue=NULL;
 pendingscan *ps_prioqueue=NULL;
@@ -15,7 +16,7 @@ unsigned int prioqueuedscans=0;
 
 unsigned long countpendingscan=0;
 
-void queuescan(unsigned int IP, short scantype, unsigned short port, char class, time_t when) {
+void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when) {
   pendingscan *psp, *psp2;
 
   /* check if the IP/port combo is already queued - don't queue up
@@ -24,7 +25,7 @@ void queuescan(unsigned int IP, short scantype, unsigned short port, char class,
   psp = ps_prioqueue;
   while (psp != NULL)
   {
-    if (psp->IP == IP && psp->type == scantype &&
+    if (psp->node == node && psp->type == scantype &&
       psp->port == port && psp->class == class)
     {
       /* found it, ignore */
@@ -36,7 +37,7 @@ void queuescan(unsigned int IP, short scantype, unsigned short port, char class,
   psp = ps_normalqueue;
   while (psp != NULL)
   {
-    if (psp->IP == IP && psp->type == scantype &&
+    if (psp->node == node && psp->type == scantype &&
       psp->port == port && psp->class == class)
     {
       /* found it, ignore */
@@ -48,22 +49,17 @@ void queuescan(unsigned int IP, short scantype, unsigned short port, char class,
   /* If there are scans spare, just start it immediately.. 
    * provided we're not supposed to wait */
   if (activescans < maxscans && when<=time(NULL) && (ps_start_ts+120 <= time(NULL))) {
-    startscan(IP, scantype, port, class);
+    startscan(node, scantype, port, class);
     return;
   }
 
   /* We have to queue it */
-  psp = (struct pendingscan *) malloc(sizeof(pendingscan));
-  if (!psp)
-  {
-    /* shutdown due to no memory */
-    irc_send("%s SQ %s 0 :Out of memory - exiting.",mynumeric->content,myserver->content);
-    irc_disconnected();
-    exit(0);
-  } else {
-    countpendingscan++;
-  }
-  psp->IP=IP;
+  if (!(psp=(struct pendingscan *)malloc(sizeof(pendingscan))))
+    Error("proxyscan",ERR_STOP,"Unable to allocate memory");
+
+  countpendingscan++;
+
+  psp->node=node;
   psp->type=scantype;
   psp->port=port;
   psp->class=class;
@@ -116,7 +112,7 @@ void startqueuedscans() {
     }
     
     if (psp) {
-      startscan(psp->IP, psp->type, psp->port, psp->class);
+      startscan(psp->node, psp->type, psp->port, psp->class);
       free(psp);
       countpendingscan--;
       psp=NULL;