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

[or-cvs] r6902@Kushana: nickm | 2006-07-25 17:30:27 -0400 Move rend_ (r6903 in tor/trunk: . src/or)



Author: nickm
Date: 2006-07-26 15:05:34 -0400 (Wed, 26 Jul 2006)
New Revision: 6903

Modified:
   tor/trunk/
   tor/trunk/src/or/circuitlist.c
   tor/trunk/src/or/circuituse.c
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/rendclient.c
   tor/trunk/src/or/rendservice.c
Log:
 r6902@Kushana:  nickm | 2006-07-25 17:30:27 -0400
 Move rend_query to origin_circuit_t where it belongs; save another 17 bytes per OR circuit.



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   + c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6902

Modified: tor/trunk/src/or/circuitlist.c
===================================================================
--- tor/trunk/src/or/circuitlist.c	2006-07-25 22:51:51 UTC (rev 6902)
+++ tor/trunk/src/or/circuitlist.c	2006-07-26 19:05:34 UTC (rev 6903)
@@ -632,16 +632,18 @@
  *
  * Return NULL if no such circuit exists.
  */
-circuit_t *
+origin_circuit_t *
 circuit_get_by_rend_query_and_purpose(const char *rend_query, uint8_t purpose)
 {
   circuit_t *circ;
 
+  tor_assert(CIRCUIT_PURPOSE_IS_ORIGIN(purpose));
+
   for (circ = global_circuitlist; circ; circ = circ->next) {
     if (!circ->marked_for_close &&
         circ->purpose == purpose &&
-        !rend_cmp_service_ids(rend_query, circ->rend_query))
-      return circ;
+        !rend_cmp_service_ids(rend_query, TO_ORIGIN_CIRCUIT(circ)->rend_query))
+      return TO_ORIGIN_CIRCUIT(circ);
   }
   return NULL;
 }
@@ -854,10 +856,10 @@
     /* treat this like getting a nack from it */
     log_info(LD_REND, "Failed intro circ %s to %s (awaiting ack). "
              "Removing from descriptor.",
-             safe_str(circ->rend_query),
+             safe_str(ocirc->rend_query),
              safe_str(build_state_get_exit_nickname(ocirc->build_state)));
     rend_client_remove_intro_point(ocirc->build_state->chosen_exit,
-                                   circ->rend_query);
+                                   ocirc->rend_query);
   }
   if (circ->n_conn)
     connection_or_send_destroy(circ->n_circ_id, circ->n_conn, reason);

Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2006-07-25 22:51:51 UTC (rev 6902)
+++ tor/trunk/src/or/circuituse.c	2006-07-26 19:05:34 UTC (rev 6903)
@@ -91,7 +91,8 @@
       return 0;
     }
   } else { /* not general */
-    if (rend_cmp_service_ids(conn->rend_query, circ->rend_query)) {
+    if (rend_cmp_service_ids(conn->rend_query,
+                             TO_ORIGIN_CIRCUIT(circ)->rend_query)) {
       /* this circ is not for this conn */
       return 0;
     }
@@ -236,7 +237,8 @@
           /* c_rend_ready circs measure age since timestamp_dirty,
            * because that's set when they switch purposes
            */
-          if (!victim->rend_query[0] || victim->timestamp_dirty > cutoff)
+          if (TO_ORIGIN_CIRCUIT(victim)->rend_query[0] ||
+              victim->timestamp_dirty > cutoff)
             continue;
           break;
         case CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED:
@@ -1010,8 +1012,7 @@
       rep_hist_note_used_internal(time(NULL), need_uptime, 1);
       if (circ) {
         /* write the service_id into circ */
-        strlcpy(circ->_base.rend_query, conn->rend_query,
-                sizeof(circ->_base.rend_query));
+        strlcpy(circ->rend_query, conn->rend_query, sizeof(circ->rend_query));
         if (circ->_base.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND &&
             circ->_base.state == CIRCUIT_STATE_OPEN)
           rend_client_rendcirc_has_opened(circ);

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2006-07-25 22:51:51 UTC (rev 6902)
+++ tor/trunk/src/or/connection_edge.c	2006-07-26 19:05:34 UTC (rev 6903)
@@ -1637,7 +1637,7 @@
     log_debug(LD_REND,"begin is for rendezvous. configuring stream.");
     n_stream->address = tor_strdup("(rendezvous)");
     n_stream->state = EXIT_CONN_STATE_CONNECTING;
-    strlcpy(n_stream->rend_query, circ->rend_query,
+    strlcpy(n_stream->rend_query, origin_circ->rend_query,
             sizeof(n_stream->rend_query));
     tor_assert(connection_edge_is_rendezvous_stream(n_stream));
     assert_circuit_ok(circ);

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-07-25 22:51:51 UTC (rev 6902)
+++ tor/trunk/src/or/or.h	2006-07-26 19:05:34 UTC (rev 6903)
@@ -1110,13 +1110,6 @@
   const char *marked_for_close_file; /**< For debugging: in which file was this
                                       * circuit marked for close? */
 
-  /**
-   * The rend_query field holds the y portion of y.onion (nul-terminated)
-   * if purpose is C_INTRODUCING or C_ESTABLISH_REND, or is a C_GENERAL
-   * for a hidden service, or is S_*.
-   */
-  char rend_query[REND_SERVICE_ID_LEN+1];
-
   /** The rend_pk_digest field holds a hash of location-hidden service's
    * PK if purpose is INTRO_POINT or S_ESTABLISH_INTRO or S_RENDEZVOUSING.
    */
@@ -1155,6 +1148,13 @@
    */
   crypt_path_t *cpath;
 
+  /**
+   * The rend_query field holds the y portion of y.onion (nul-terminated)
+   * if purpose is C_INTRODUCING or C_ESTABLISH_REND, or is a C_GENERAL
+   * for a hidden service, or is S_*.
+   */
+  char rend_query[REND_SERVICE_ID_LEN+1];
+
 } origin_circuit_t;
 
 typedef struct or_circuit_t {
@@ -1592,8 +1592,8 @@
 circuit_t *circuit_get_by_edge_conn(connection_t *conn);
 void circuit_unlink_all_from_or_conn(connection_t *conn, int reason);
 circuit_t *circuit_get_by_global_id(uint32_t id);
-circuit_t *circuit_get_by_rend_query_and_purpose(const char *rend_query,
-                                                 uint8_t purpose);
+origin_circuit_t *circuit_get_by_rend_query_and_purpose(const char *rend_query,
+                                                        uint8_t purpose);
 circuit_t *circuit_get_next_by_pk_and_purpose(circuit_t *start,
                                          const char *digest, uint8_t purpose);
 or_circuit_t *circuit_get_rendezvous(const char *cookie);

Modified: tor/trunk/src/or/rendclient.c
===================================================================
--- tor/trunk/src/or/rendclient.c	2006-07-25 22:51:51 UTC (rev 6902)
+++ tor/trunk/src/or/rendclient.c	2006-07-26 19:05:34 UTC (rev 6903)
@@ -66,13 +66,13 @@
 
   tor_assert(introcirc->_base.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
   tor_assert(rendcirc->_base.purpose == CIRCUIT_PURPOSE_C_REND_READY);
-  tor_assert(!rend_cmp_service_ids(introcirc->_base.rend_query,
-                                   rendcirc->_base.rend_query));
+  tor_assert(!rend_cmp_service_ids(introcirc->rend_query,
+                                   rendcirc->rend_query));
 
-  if (rend_cache_lookup_entry(introcirc->_base.rend_query, -1, &entry) < 1) {
+  if (rend_cache_lookup_entry(introcirc->rend_query, -1, &entry) < 1) {
     log_warn(LD_REND,
              "query %s didn't have valid rend desc in cache. Failing.",
-             escaped_safe_str(introcirc->_base.rend_query));
+             escaped_safe_str(introcirc->rend_query));
     goto err;
   }
 
@@ -183,7 +183,7 @@
 rend_client_introduction_acked(origin_circuit_t *circ,
                                const char *request, size_t request_len)
 {
-  circuit_t *rendcirc;
+  origin_circuit_t *rendcirc;
   (void) request; // XXXX Use this.
 
   if (circ->_base.purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
@@ -204,9 +204,9 @@
      */
     log_info(LD_REND,"Received ack. Telling rend circ...");
     rendcirc = circuit_get_by_rend_query_and_purpose(
-               circ->_base.rend_query, CIRCUIT_PURPOSE_C_REND_READY);
+               circ->rend_query, CIRCUIT_PURPOSE_C_REND_READY);
     if (rendcirc) { /* remember the ack */
-      rendcirc->purpose = CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED;
+      rendcirc->_base.purpose = CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED;
     } else {
       log_info(LD_REND,"...Found no rend circ. Dropping on the floor.");
     }
@@ -221,22 +221,22 @@
      * If none remain, refetch the service descriptor.
      */
     if (rend_client_remove_intro_point(circ->build_state->chosen_exit,
-                                       circ->_base.rend_query) > 0) {
+                                       circ->rend_query) > 0) {
       /* There are introduction points left. Re-extend the circuit to
        * another intro point and try again. */
       extend_info_t *extend_info;
       int result;
-      extend_info = rend_client_get_random_intro(circ->_base.rend_query);
+      extend_info = rend_client_get_random_intro(circ->rend_query);
       if (!extend_info) {
         log_warn(LD_REND, "No introduction points left for %s. Closing.",
-                 escaped_safe_str(circ->_base.rend_query));
+                 escaped_safe_str(circ->rend_query));
         circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_AT_ORIGIN);
         return -1;
       }
       log_info(LD_REND,
                "Got nack for %s from %s. Re-extending circ %d, "
                "this time to %s.",
-               escaped_safe_str(circ->_base.rend_query),
+               escaped_safe_str(circ->rend_query),
                circ->build_state->chosen_exit->nickname, circ->_base.n_circ_id,
                extend_info->nickname);
       result = circuit_extend_to_new_exit(circ, extend_info);

Modified: tor/trunk/src/or/rendservice.c
===================================================================
--- tor/trunk/src/or/rendservice.c	2006-07-25 22:51:51 UTC (rev 6902)
+++ tor/trunk/src/or/rendservice.c	2006-07-26 19:05:34 UTC (rev 6903)
@@ -592,8 +592,8 @@
   memcpy(launched->_base.rend_pk_digest, circuit->_base.rend_pk_digest,
          DIGEST_LEN);
   memcpy(launched->_base.rend_cookie, r_cookie, REND_COOKIE_LEN);
-  strlcpy(launched->_base.rend_query, service->service_id,
-          sizeof(launched->_base.rend_query));
+  strlcpy(launched->rend_query, service->service_id,
+          sizeof(launched->rend_query));
   launched->build_state->pending_final_cpath = cpath =
     tor_malloc_zero(sizeof(crypt_path_t));
   cpath->magic = CRYPT_PATH_MAGIC;
@@ -663,8 +663,7 @@
   newstate->pending_final_cpath = oldstate->pending_final_cpath;
   oldstate->pending_final_cpath = NULL;
 
-  memcpy(newcirc->_base.rend_query, oldcirc->_base.rend_query,
-         REND_SERVICE_ID_LEN+1);
+  memcpy(newcirc->rend_query, oldcirc->rend_query, REND_SERVICE_ID_LEN+1);
   memcpy(newcirc->_base.rend_pk_digest, oldcirc->_base.rend_pk_digest,
          DIGEST_LEN);
   memcpy(newcirc->_base.rend_cookie, oldcirc->_base.rend_cookie,
@@ -695,8 +694,8 @@
              nickname);
     return -1;
   }
-  strlcpy(launched->_base.rend_query, service->service_id,
-          sizeof(launched->_base.rend_query));
+  strlcpy(launched->rend_query, service->service_id,
+          sizeof(launched->rend_query));
   memcpy(launched->_base.rend_pk_digest, service->pk_digest, DIGEST_LEN);
 
   if (launched->_base.state == CIRCUIT_STATE_OPEN)