[NeoStats-Devel] [Commits] r2590 - trunk/src

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Fish
Date: Mon May  9 12:55:57 2005
New Revision: 2590

Modified:
   trunk/src/dns.c
   trunk/src/sock.c
Log:
fix a DNS error

Modified: trunk/src/dns.c
==============================================================================
--- trunk/src/dns.c	(original)
+++ trunk/src/dns.c	Mon May  9 12:55:57 2005
@@ -107,6 +107,7 @@
 	dnsdata->data = data;
 	dnsdata->callback = callback;
 	dnsdata->type = type;
+	strlcpy(dnsdata->lookupdata, str, 254);
 	if (list_isfull (dnslist)) {
 		dlog(DEBUG1, "DNS: Lookup list is full, adding to queue");
 		strlcpy(dnsdata->lookupdata, str, 254);
@@ -310,8 +311,8 @@
 
 
 	/* process timeouts for ADNS */
-    gettimeofday(&tv,NULL);
-    adns_processtimeouts(ads, &tv);
+	gettimeofday(&tv,NULL);
+	adns_processtimeouts(ads, &tv);
     
 	/* if the list is empty, no use doing anything */
 	if (list_isempty (dnslist)) {
@@ -325,12 +326,9 @@
 		status = adns_check (ads, &dnsdata->q, &dnsdata->a, NULL);
 		/* if status == eagain, the lookup hasn't completed yet */
 		if (status == EAGAIN) {
-			dlog(DEBUG2, "DNS: Lookup hasn't completed for %s",(char *) &dnsdata->data);
+			dlog(DEBUG2, "DNS: Lookup hasn't completed for %s",(char *) &dnsdata->lookupdata);
 			dnsnode = list_next (dnslist, dnsnode);
-			break;
-		}
-		/* there was an error */
-		if (status) {
+		} else if (status) {
 			nlog (LOG_CRITICAL, "DNS: Bad error on adns_check: %s. Please report to NeoStats", strerror (status));
 			irc_chanalert (ns_botptr, "Bad Error on DNS lookup. Please check logfile");
 			DNSStats.failure++;
@@ -339,25 +337,27 @@
 			dnsdata->callback (dnsdata->data, NULL);
 			RESET_RUN_LEVEL();
 			/* delete from list */
-			dnsnode1 = list_delete (dnslist, dnsnode);
-			dnsnode = list_next (dnslist, dnsnode1);
+			dnsnode1 = dnsnode;
+			dnsnode = list_next (dnslist, dnsnode);
 			ns_free (dnsdata->a);
 			ns_free (dnsdata);
+			list_delete(dnslist, dnsnode1);
+			lnode_destroy (dnsnode1);
+		} else {
+			dlog(DEBUG1, "DNS: Calling callback function for lookup %s", dnsdata->lookupdata);
+			DNSStats.success++;
+			/* call the callback function */
+			SET_RUN_LEVEL(dnsdata->modptr);
+			dnsdata->callback (dnsdata->data, dnsdata->a);
+			RESET_RUN_LEVEL();
+			/* delete from list */
+			dnsnode1 = dnsnode;
+			dnsnode = list_next (dnslist, dnsnode);
+			ns_free (dnsdata->a);
+			ns_free (dnsdata);
+			list_delete(dnslist, dnsnode1);
 			lnode_destroy (dnsnode1);
-			break;
 		}
-		dlog(DEBUG1, "DNS: Calling callback function with for module %s", dnsdata->modptr->info->name);
-		DNSStats.success++;
-		/* call the callback function */
-		SET_RUN_LEVEL(dnsdata->modptr);
-		dnsdata->callback (dnsdata->data, dnsdata->a);
-		RESET_RUN_LEVEL();
-		/* delete from list */
-		dnsnode1 = list_delete (dnslist, dnsnode);
-		dnsnode = list_next (dnslist, dnsnode1);
-		ns_free (dnsdata->a);
-		ns_free (dnsdata);
-		lnode_destroy (dnsnode1);
 	}
 	dns_check_queue();
 }

Modified: trunk/src/sock.c
==============================================================================
--- trunk/src/sock.c	(original)
+++ trunk/src/sock.c	Mon May  9 12:55:57 2005
@@ -977,7 +977,7 @@
 	hscan_t ss;
 	hnode_t *sn;
 	int size;
-    struct sockaddr_in add;
+	struct sockaddr_in add;
 	
 	SET_SEGV_LOCATION();
 	irc_prefmsg (ns_botptr, cmdparams->source, __("Sockets List: (%d)", cmdparams->source), (int)hash_count (sockethash));
@@ -986,15 +986,15 @@
 		sock = hnode_get (sn);
 		irc_prefmsg (ns_botptr, cmdparams->source, "%s:--------------------------------", sock->moduleptr->info->name);
 		irc_prefmsg (ns_botptr, cmdparams->source, __("Socket Name: %s", cmdparams->source), sock->name);
-        size = sizeof(struct sockaddr_in);
+		size = sizeof(struct sockaddr_in);
 		if(getsockname(sock->sock_no, (struct sockaddr *) &add, (socklen_t *)&size) > -1) {
-            irc_prefmsg (ns_botptr, cmdparams->source, "Local Socket: %s:%d", inet_ntoa(add.sin_addr), ntohs(add.sin_port));
-        }
-        size = sizeof(struct sockaddr_in);
-        /* this will not print anything if the socket is not connected */
-        if (getpeername(sock->sock_no,(struct sockaddr *)&add, (socklen_t *)&size) > -1) {
-            irc_prefmsg (ns_botptr, cmdparams->source, "Remote Socket: %s:%hu", inet_ntoa(add.sin_addr), ntohs(add.sin_port));
-        }
+			irc_prefmsg (ns_botptr, cmdparams->source, "Local Socket: %s:%d", inet_ntoa(add.sin_addr), ntohs(add.sin_port));
+		}
+		size = sizeof(struct sockaddr_in);
+		/* this will not print anything if the socket is not connected */
+		if (getpeername(sock->sock_no,(struct sockaddr *)&add, (socklen_t *)&size) > -1) {
+			irc_prefmsg (ns_botptr, cmdparams->source, "Remote Socket: %s:%hu", inet_ntoa(add.sin_addr), ntohs(add.sin_port));
+		}
 
 		switch (sock->socktype) {
 			case SOCK_STANDARD:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.