[NeoStats-Devel] [Commits] r21 - DNSBL_Proc

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Fish
Date: Thu Aug  4 22:37:29 2005
New Revision: 21

Modified:
   DNSBL_Proc/DNS_Proc.c
Log:
fix a few things so it restarts nicely

Modified: DNSBL_Proc/DNS_Proc.c
==============================================================================
--- DNSBL_Proc/DNS_Proc.c	(original)
+++ DNSBL_Proc/DNS_Proc.c	Thu Aug  4 22:37:29 2005
@@ -220,7 +220,7 @@
     dbi_result result;
     unsigned long lastidx, maxidx, testidx;
     unsigned long lastblidx, curblidx;
-    int i;
+    int i, j;
     dnsentry *entry;
     
     /* setup the db connection */
@@ -298,7 +298,11 @@
     stats.entries = dbi_result_get_numrows(result);
     fprintf(stdout, "Processing %ld Entries\n", stats.entries);
     currentadns = 0;
-    while (dbi_result_next_row(result) != 0) {
+    j = 0;
+    maxidx = lastidx;
+    while (j <= stats.entries) {
+        j++;
+        dbi_result_next_row(result);
         entry = malloc(sizeof(dnsentry));
         entry->inp = malloc(sizeof(struct in_addr));
         entry->hostname = strdup(dbi_result_get_string(result, "hostname"));
@@ -342,9 +346,9 @@
     printf("Processed %ld Entries, %ld straight inserts, %ld DNS lookups started, %ld DNS lookups failed\n", stats.processed, stats.straightinserts, stats.dnslookups, stats.dnsfailures);
 
 
-    result = dbi_conn_query(conn, "update settings, blacklist set settings.value=max(blacklist.idxNum) where settings.name='DNSBL_BLIDX_Processed'");
+    result = dbi_conn_query(conn, "update settings set value=(select max(idxNum) from blacklist) where name='DNSBL_BLIDX_Processed'");
     dbi_result_free(result);    
-    result = dbi_conn_queryf(conn, "update settings, blacklist set settings.value='%ld' where settings.name='DNSBL_LastIDX_Processed'", maxidx);
+    result = dbi_conn_queryf(conn, "update settings set value='%ld' where name='DNSBL_LastIDX_Processed'", maxidx);
     dbi_result_free(result);    
 
     dbi_conn_close(conn);
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.