[or-cvs] more general cleanup

Roger Dingledine arma at seul.org
Sun Dec 14 00:12:04 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	dns.c onion.c 
Log Message:
more general cleanup


Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- dns.c	18 Nov 2003 08:20:19 -0000	1.40
+++ dns.c	14 Dec 2003 00:12:02 -0000	1.41
@@ -116,7 +116,6 @@
         resolve->pending_connections = pending_connection;
         log_fn(LOG_DEBUG,"Connection (fd %d) waiting for pending DNS resolve of '%s'",
                exitconn->s, exitconn->address);
-               
         return 0;
       case CACHE_STATE_VALID:
         exitconn->addr = resolve->answer;
@@ -126,32 +125,30 @@
       case CACHE_STATE_FAILED:
         return -1;
     }
-  } else { /* need to add it */
-    resolve = tor_malloc_zero(sizeof(struct cached_resolve));
-    resolve->state = CACHE_STATE_PENDING;
-    resolve->expire = now + 15*60; /* 15 minutes */
-    strncpy(resolve->question, exitconn->address, MAX_ADDRESSLEN);
-
-    /* add us to the pending list */
-    pending_connection = tor_malloc(sizeof(struct pending_connection_t));
-    pending_connection->conn = exitconn;
-    pending_connection->next = resolve->pending_connections;
-    resolve->pending_connections = pending_connection;
+    assert(0);
+  }
+  /* not there, need to add it */
+  resolve = tor_malloc_zero(sizeof(struct cached_resolve));
+  resolve->state = CACHE_STATE_PENDING;
+  resolve->expire = now + 15*60; /* 15 minutes */
+  strncpy(resolve->question, exitconn->address, MAX_ADDRESSLEN);
 
-    /* add us to the linked list of resolves */
-    if (!oldest_cached_resolve) {
-      oldest_cached_resolve = resolve;
-    } else {
-      newest_cached_resolve->next = resolve;
-    }
-    newest_cached_resolve = resolve;
+  /* add us to the pending list */
+  pending_connection = tor_malloc(sizeof(struct pending_connection_t));
+  pending_connection->conn = exitconn;
+  pending_connection->next = resolve->pending_connections;
+  resolve->pending_connections = pending_connection;
 
-    SPLAY_INSERT(cache_tree, &cache_root, resolve);
-    return assign_to_dnsworker(exitconn);
+  /* add us to the linked list of resolves */
+  if (!oldest_cached_resolve) {
+    oldest_cached_resolve = resolve;
+  } else {
+    newest_cached_resolve->next = resolve;
   }
+  newest_cached_resolve = resolve;
 
-  assert(0);
-  return 0; /* not reached; keep gcc happy */
+  SPLAY_INSERT(cache_tree, &cache_root, resolve);
+  return assign_to_dnsworker(exitconn);
 }
 
 static int assign_to_dnsworker(connection_t *exitconn) {

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- onion.c	13 Dec 2003 23:32:57 -0000	1.108
+++ onion.c	14 Dec 2003 00:12:02 -0000	1.109
@@ -152,38 +152,6 @@
   return 0;
 }
 
-#if 0
-static char **parse_nickname_list(char *list, int *num) {
-  char **out;
-  char *start,*end;
-  int i;
-
-  while(isspace(*list)) list++;
-
-  i=0, start = list;
-  while(*start) {
-    while(*start && !isspace(*start)) start++;
-    i++;
-    while(isspace(*start)) start++;
-  }
-
-  out = tor_malloc(i * sizeof(char *));
-
-  i=0, start=list;
-  while(*start) {
-    end=start; while(*end && !isspace(*end)) end++;
-    out[i] = tor_malloc(MAX_NICKNAME_LEN);
-    strncpy(out[i],start,end-start);
-    out[i][end-start] = 0; /* null terminate it */
-    i++;
-    while(isspace(*end)) end++;
-    start = end;
-  }
-  *num = i;
-  return out;
-}
-#endif
-
 static void add_nickname_list_to_smartlist(smartlist_t *sl, char *list) {
   char *start,*end;
   char nick[MAX_NICKNAME_LEN];



More information about the tor-commits mailing list