[or-cvs] r11416: remove more pointless differences between our eventdns.c and (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Mon Sep 10 14:23:26 UTC 2007


Author: nickm
Date: 2007-09-10 10:23:26 -0400 (Mon, 10 Sep 2007)
New Revision: 11416

Modified:
   tor/trunk/
   tor/trunk/src/or/eventdns.c
Log:
 r15020 at catbus:  nickm | 2007-09-10 10:22:31 -0400
 remove more pointless differences between our eventdns.c and the evdns.c in libevent.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15020] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c	2007-09-10 14:05:12 UTC (rev 11415)
+++ tor/trunk/src/or/eventdns.c	2007-09-10 14:23:26 UTC (rev 11416)
@@ -314,8 +314,6 @@
 static const struct timeval global_nameserver_timeouts[] = {{10, 0}, {60, 0}, {300, 0}, {900, 0}, {3600, 0}};
 static const int global_nameserver_timeouts_length = sizeof(global_nameserver_timeouts)/sizeof(struct timeval);
 
-static const char *const evdns_error_strings[] = {"no error", "The name server was unable to interpret the query", "The name server suffered an internal error", "The requested domain name does not exist", "The name server refused to reply to the request"};
-
 static struct nameserver *nameserver_pick(void);
 static void evdns_request_insert(struct request *req, struct request **head);
 static void nameserver_ready_callback(int fd, short events, void *arg);
@@ -723,7 +721,8 @@
 		case DNS_ERR_SERVERFAILED:
 			/* rcode 2 (servfailed) sometimes means "we are broken" and
 			 * sometimes (with some binds) means "that request was very
-			 * confusing."  Treat this as a timeout, not a failure. */
+			 * confusing."  Treat this as a timeout, not a failure.
+			 */
 			/*XXXX refactor the parts of */
 			log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver %s; "
 				"will allow the request to time out.",
@@ -756,14 +755,14 @@
 	}
 }
 
-static inline int
+static int
 name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) {
 	int name_end = -1;
 	int j = *idx;
 	int ptr_count = 0;
-#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&_t32, packet + j, 4); j += 4; x = ntohl(_t32); } while(0);
-#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&_t, packet + j, 2); j += 2; x = ntohs(_t); } while(0);
-#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while(0);
+#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&_t32, packet + j, 4); j += 4; x = ntohl(_t32); } while(0)
+#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&_t, packet + j, 2); j += 2; x = ntohs(_t); } while(0)
+#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while(0)
 
 	char *cp = name_out;
 	const char *const end = name_out + name_out_len;
@@ -776,7 +775,7 @@
 
 	for(;;) {
 		u8 label_len;
-		if (j >= length) return -1;
+		//if (j >= length) return -1;
 		GET8(label_len);
 		if (!label_len) break;
 		if (label_len & 0xc0) {
@@ -842,7 +841,7 @@
 
 	memset(&reply, 0, sizeof(reply));
 
-	/* if not an answer, it doesn't go with any of our requests. */
+	/* If it's not an answer, it doesn't go with any of our requests. */
 	if (!(flags & 0x8000)) return -1;  /* must be an answer */
 	if (flags & 0x020f) {
 		/* there was an error */
@@ -1254,7 +1253,7 @@
  * functions, so that is can be safely replaced with something smarter later. */
 #define MAX_LABELS 128
 /* Structures used to implement name compression */
-struct dnslabel_entry { char *v; int pos; };
+struct dnslabel_entry { char *v; off_t pos; };
 struct dnslabel_table {
 	int n_labels; /* number of current entries */
 	/* map from name to position in message */
@@ -1293,7 +1292,7 @@
 
 /* remember that we've used the label at position pos */
 static int
-dnslabel_table_add(struct dnslabel_table *table, const char *label, int pos)
+dnslabel_table_add(struct dnslabel_table *table, const char *label, off_t pos)
 {
 	char *v;
 	int p;
@@ -1514,7 +1513,7 @@
 				free(item);
 				return -1;
 			}
-			item->datalen = -1;
+			item->datalen = (u16)-1;
 		} else {
 			if (!(item->data = malloc(datalen))) {
 				free(item->name);
@@ -1878,9 +1877,9 @@
 evdns_request_transmit_to(struct request *req, struct nameserver *server) {
 	const int r = send(server->socket, req->request, req->request_len, 0);
 	if (r < 0) {
-		int err = last_error(server->socket);
-		if (error_is_eagain(err)) return 1;
-		nameserver_failed(req->ns, strerror(err));
+		int e = last_error(server->socket);
+		if (error_is_eagain(e)) return 1;
+		nameserver_failed(req->ns, strerror(e));
 		return 2;
 	} else if (r != (int)req->request_len) {
 		return 1;  /* short write */
@@ -2240,7 +2239,7 @@
 	req->next = req->prev = NULL;
 
 	return req;
- err1:
+err1:
 	CLEAR(req);
 	_free(req);
 	return NULL;
@@ -2542,7 +2541,7 @@
 			/* this name without a postfix */
 			if (string_num_dots(req->search_origname) < req->search_state->ndots) {
 				/* yep, we need to try it raw */
-				newreq = request_new(req->request_type, req->search_origname, req->search_flags, req->user_callback, req->user_pointer);
+				struct request *const newreq = request_new(req->request_type, req->search_origname, req->search_flags, req->user_callback, req->user_pointer);
 				log(EVDNS_LOG_DEBUG, "Search: trying raw query %s", req->search_origname);
 				if (newreq) {
 					request_submit(newreq);



More information about the tor-commits mailing list