[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8252: divide eventdns log messages into warn and info messages. (in tor/trunk: . src/or)



Author: nickm
Date: 2006-08-27 23:15:38 -0400 (Sun, 27 Aug 2006)
New Revision: 8252

Modified:
   tor/trunk/
   tor/trunk/src/or/dns.c
   tor/trunk/src/or/eventdns.c
   tor/trunk/src/or/eventdns.h
Log:
 r8605@Kushana:  nickm | 2006-08-27 14:01:11 -0400
 divide eventdns log messages into warn and info messages.



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   - 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:8557
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:8576
   + 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:8605
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:8576

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-08-28 03:01:07 UTC (rev 8251)
+++ tor/trunk/src/or/dns.c	2006-08-28 03:15:38 UTC (rev 8252)
@@ -148,14 +148,14 @@
 
 #ifdef USE_EVENTDNS
 static void
-eventdns_log_cb(const char *msg)
+eventdns_log_cb(int warn, const char *msg)
 {
   if (!strcmpstart(msg, "Resolve requested for") &&
       get_options()->SafeLogging) {
     log(LOG_INFO, LD_EXIT, "eventdns: Resolve requested.");
     return;
   }
-  log(LOG_INFO, LD_EXIT, "eventdns: %s", msg);
+  log(warn?LOG_WARN:LOG_INFO, LD_EXIT, "eventdns: %s", msg);
 }
 #endif
 

Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c	2006-08-28 03:01:07 UTC (rev 8251)
+++ tor/trunk/src/or/eventdns.c	2006-08-28 03:15:38 UTC (rev 8252)
@@ -465,14 +465,14 @@
 }
 
 #ifdef __GNUC__
-#define EVENTDNS_LOG_CHECK  __attribute__ ((format(printf, 1, 2)))
+#define EVENTDNS_LOG_CHECK  __attribute__ ((format(printf, 2, 3)))
 #else
 #define EVENTDNS_LOG_CHECK
 #endif
 
-static void _eventdns_log(const char *fmt, ...) EVENTDNS_LOG_CHECK;
+static void _eventdns_log(int warn, const char *fmt, ...) EVENTDNS_LOG_CHECK;
 static void
-_eventdns_log(const char *fmt, ...)
+_eventdns_log(int warn, const char *fmt, ...)
 {
   va_list args;
   static char buf[512];
@@ -485,7 +485,7 @@
   vsnprintf(buf, sizeof(buf), fmt, args);
 #endif
   buf[sizeof(buf)-1] = '\0';
-  eventdns_log_fn(buf);
+  eventdns_log_fn(warn, buf);
   va_end(args);
 }
 
@@ -534,7 +534,7 @@
 
 	evtimer_set(&ns->timeout_event, nameserver_prod_callback, ns);
 	if (evtimer_add(&ns->timeout_event, (struct timeval *) timeout) < 0) {
-          log("Error from libevent when adding timer event for %s",
+          log(1,"Error from libevent when adding timer event for %s",
               debug_ntoa(ns->address));
           // ???? Do more?
         }
@@ -549,7 +549,7 @@
 	// then don't do anything
 	if (!ns->state) return;
 
-	log("Nameserver %s has failed: %s", debug_ntoa(ns->address), msg);
+	log(1,"Nameserver %s has failed: %s", debug_ntoa(ns->address), msg);
 	global_good_nameservers--;
 	assert(global_good_nameservers >= 0);
 	if (global_good_nameservers == 0) {
@@ -591,7 +591,7 @@
 static void
 nameserver_up(struct nameserver *const ns) {
 	if (ns->state) return;
-	log("Nameserver %s is back up", debug_ntoa(ns->address));
+	log(1,"Nameserver %s is back up", debug_ntoa(ns->address));
 	evtimer_del(&ns->timeout_event);
 	ns->state = 1;
 	ns->failed_times = 0;
@@ -620,7 +620,7 @@
 		}
 	}
 
-	log("Removing timeout for request %lx", (unsigned long) req);
+	log(0,"Removing timeout for request %lx", (unsigned long) req);
 	evtimer_del(&req->timeout_event);
 
 	search_request_finished(req);
@@ -857,7 +857,7 @@
 	req = request_find_from_trans_id(trans_id);
 	if (!req) return -1;
 	// XXXX should the other return points also call reply_handle? -NM
-        log("reqparse: trans was %d\n", (int)trans_id);
+        // log("reqparse: trans was %d\n", (int)trans_id);
 
 	memset(&reply, 0, sizeof(reply));
 
@@ -1058,7 +1058,7 @@
 	event_set(&ns->event, ns->socket, EV_READ | (waiting ? EV_WRITE : 0) | EV_PERSIST,
 			nameserver_ready_callback, ns);
 	if (event_add(&ns->event, NULL) < 0) {
-          log("Error from libevent when adding event for %s",
+          log(1, "Error from libevent when adding event for %s",
               debug_ntoa(ns->address));
           // ???? Do more?
         }
@@ -1187,7 +1187,7 @@
         (void) fd;
         (void) events;
 
-	log("Request %lx timed out", (unsigned long) arg);
+	log(0, "Request %lx timed out", (unsigned long) arg);
 
 	req->ns->timedout++;
 	if (req->ns->timedout > global_max_nameserver_timeout) {
@@ -1260,12 +1260,12 @@
 		// fall through
 	default:
 		// all ok
-		log("Setting timeout for request %lx", (unsigned long) req);
+		log(0, "Setting timeout for request %lx", (unsigned long) req);
 		evtimer_set(&req->timeout_event, eventdns_request_timeout_callback, req);
 		if (evtimer_add(&req->timeout_event, &global_timeout) < 0) {
-                  log("Error from libevent when adding timer for request %lx",
-                      (unsigned long) req);
-                  // ???? Do more?
+			log(1, "Error from libevent when adding timer for "
+			    "request %lx", (unsigned long) req);
+			// ???? Do more?
                 }
 		req->tx_count++;
 		req->transmit_me = 0;
@@ -1293,7 +1293,7 @@
 	// here we need to send a probe to a given nameserver
 	// in the hope that it is up now.
 
-  	log("Sending probe to %s", debug_ntoa(ns->address));
+  	log(0, "Sending probe to %s", debug_ntoa(ns->address));
 	req = request_new(TYPE_A, "www.google.com", DNS_QUERY_NO_SEARCH, nameserver_probe_callback, ns);
         if (!req) return;
 	// we force this into the inflight queue no matter what
@@ -1446,7 +1446,7 @@
           goto out2;
         }
 
-	log("Added nameserver %s", debug_ntoa(address));
+	log(0, "Added nameserver %s", debug_ntoa(address));
 
 	// insert this nameserver into the list of them
 	if (!server_head) {
@@ -1469,7 +1469,8 @@
 	CLOSE_SOCKET(ns->socket);
 out1:
 	free(ns);
-	log("Unable to add nameserver %s: error %d", debug_ntoa(address), err);
+	log(1, "Unable to add nameserver %s: error %d", debug_ntoa(address),
+	    err);
 	return err;
 }
 
@@ -1557,7 +1558,7 @@
 
 // exported function
 int eventdns_resolve_ipv4(const char *name, int flags, eventdns_callback_type callback, void *ptr) {
-	log("Resolve requested for %s", name);
+	log(0, "Resolve requested for %s", name);
 	if (flags & DNS_QUERY_NO_SEARCH) {
 		struct request *const req = request_new(TYPE_A, name, flags, callback, ptr);
 		if (!req) return 1;
@@ -1579,7 +1580,7 @@
 		(int)(u8)((a>>8 )&0xff),
                 (int)(u8)((a>>16)&0xff),
 		(int)(u8)((a>>24)&0xff));
-	log("reverse resolve requested for %s", buf);
+	log(0, "reverse resolve requested for %s", buf);
 	req = request_new(TYPE_PTR, buf, flags, callback, ptr);
 	if (!req) return 1;
 	request_submit(req);
@@ -1792,7 +1793,7 @@
 			if (string_num_dots(req->search_origname) < req->search_state->ndots) {
 				// yep, we need to try it raw
 				struct request *const newreq = request_new(req->request_type, req->search_origname, req->search_flags, req->user_callback, req->user_pointer);
-				log("Search: trying raw query %s", req->search_origname);
+				log(0, "Search: trying raw query %s", req->search_origname);
 				if (newreq) {
 					request_submit(newreq);
 					return 0;
@@ -1803,7 +1804,7 @@
 
 		new_name = search_make_new(req->search_state, req->search_index, req->search_origname);
                 if (!new_name) return 1;
-		log("Search: now trying %s (%d)", new_name, req->search_index);
+		log(0, "Search: now trying %s (%d)", new_name, req->search_index);
 		newreq = request_new(req->request_type, new_name, req->search_flags, req->user_callback, req->user_pointer);
 		free(new_name);
 		if (!newreq) return 1;
@@ -1896,7 +1897,7 @@
 				const int ndots = strtoint(&option[6]);
 				if (ndots == -1) continue;
 				if (!(flags & DNS_OPTION_SEARCH)) continue;
-				log("Setting ndots to %d", ndots);
+				log(0,"Setting ndots to %d", ndots);
 				if (!global_search_state) global_search_state = search_state_new();
                                 if (!global_search_state) return;
 				global_search_state->ndots = ndots;
@@ -1904,14 +1905,14 @@
 				const int timeout = strtoint(&option[8]);
 				if (timeout == -1) continue;
 				if (!(flags & DNS_OPTION_MISC)) continue;
-				log("Setting timeout to %d", timeout);
+				log(0,"Setting timeout to %d", timeout);
 				global_timeout.tv_sec = timeout;
 			} else if (!strncmp(option, "attempts:", 9)) {
 				int retries = strtoint(&option[9]);
 				if (retries == -1) continue;
 				if (retries > 255) retries = 255;
 				if (!(flags & DNS_OPTION_MISC)) continue;
-				log("Setting retries to %d", retries);
+				log(0,"Setting retries to %d", retries);
 				global_max_retransmits = retries;
 			}
 		}
@@ -1935,7 +1936,7 @@
 	char *start;
 	int err = 0;
 
-	log("Parsing resolve.conf file %s", filename);
+	log(0,"Parsing resolve.conf file %s", filename);
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0) {
@@ -2094,7 +2095,7 @@
 	int found = 0;
 #define TRY(k, name) \
 	if (!found && config_nameserver_from_reg_key(k,name) == 0) {	\
-		log("Found nameservers in %s/%s",#k,name);		\
+		log(0,"Found nameservers in %s/%s",#k,name);		\
 		found = 1;						\
 	}
 

Modified: tor/trunk/src/or/eventdns.h
===================================================================
--- tor/trunk/src/or/eventdns.h	2006-08-28 03:01:07 UTC (rev 8251)
+++ tor/trunk/src/or/eventdns.h	2006-08-28 03:15:38 UTC (rev 8252)
@@ -65,7 +65,7 @@
 void eventdns_search_add(const char *domain);
 void eventdns_search_ndots_set(const int ndots);
 
-typedef void (*eventdns_debug_log_fn_type)(const char *msg);
+typedef void (*eventdns_debug_log_fn_type)(int warn, const char *msg);
 void eventdns_set_log_fn(eventdns_debug_log_fn_type fn);
 
 #define DNS_NO_SEARCH 1