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

[tor-commits] [tor/master] Consistently allow policy alloc_cmux_data() and alloc_circ_data() functions to return NULL if the policy does not use this in circuitmux.c



commit debef8f0cd8fbe72fb40bd811c636bb66c7a9001
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
Date:   Thu Sep 27 13:51:04 2012 -0700

    Consistently allow policy alloc_cmux_data() and alloc_circ_data() functions to return NULL if the policy does not use this in circuitmux.c
---
 src/or/circuitmux.c |   35 ++++++++++++++---------------------
 1 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index 4e33569..b5dda9e 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -293,7 +293,6 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
              * free it
              */
             tor_assert(cmux->policy);
-            tor_assert(cmux->policy_data);
             tor_assert(cmux->policy->free_circ_data);
             /* Call free_circ_data() */
             cmux->policy->free_circ_data(cmux,
@@ -805,8 +804,10 @@ circuitmux_attach_circuit(circuitmux_t *cmux, circuit_t *circ,
     hashent->muxinfo.cell_count = cell_count;
     hashent->muxinfo.direction = direction;
     /* Allocate policy specific circuit data if we need it */
-    if (cmux->policy && cmux->policy_data &&
-        cmux->policy->alloc_circ_data) {
+    if (cmux->policy && cmux->policy->alloc_circ_data) {
+      /* Assert that we have the means to free policy-specific data */
+      tor_assert(cmux->policy->free_circ_data);
+      /* Allocate it */
       hashent->muxinfo.policy_data =
         cmux->policy->alloc_circ_data(cmux,
                                       cmux->policy_data,
@@ -898,7 +899,6 @@ circuitmux_detach_circuit(circuitmux_t *cmux, circuit_t *circ)
     if (hashent->muxinfo.policy_data) {
       /* If we have policy data, assert that we have the means to free it */
       tor_assert(cmux->policy);
-      tor_assert(cmux->policy_data);
       tor_assert(cmux->policy->free_circ_data);
       /* Call free_circ_data() */
       cmux->policy->free_circ_data(cmux,
@@ -997,16 +997,14 @@ circuitmux_make_circuit_active(circuitmux_t *cmux, circuit_t *circ,
 
   /* Policy-specific notification */
   if (cmux->policy &&
-      cmux->policy->notify_circ_active &&
-      cmux->policy_data) {
+      cmux->policy->notify_circ_active) {
     /* Okay, we need to check the circuit for policy data now */
     hashent = circuitmux_find_map_entry(cmux, circ);
     /* We should have found something */
     tor_assert(hashent);
-    /* Check for policy data for the circuit and notify */
-    if (hashent->muxinfo.policy_data)
-      cmux->policy->notify_circ_active(cmux, cmux->policy_data,
-                                       circ, hashent->muxinfo.policy_data);
+    /* Notify */
+    cmux->policy->notify_circ_active(cmux, cmux->policy_data,
+                                     circ, hashent->muxinfo.policy_data);
   }
 }
 
@@ -1106,16 +1104,14 @@ circuitmux_make_circuit_inactive(circuitmux_t *cmux, circuit_t *circ,
 
   /* Policy-specific notification */
   if (cmux->policy &&
-      cmux->policy->notify_circ_inactive &&
-      cmux->policy_data) {
+      cmux->policy->notify_circ_inactive) {
     /* Okay, we need to check the circuit for policy data now */
     hashent = circuitmux_find_map_entry(cmux, circ);
     /* We should have found something */
     tor_assert(hashent);
-    /* Check for policy data for the circuit and notify */
-    if (hashent->muxinfo.policy_data)
-      cmux->policy->notify_circ_inactive(cmux, cmux->policy_data,
-                                         circ, hashent->muxinfo.policy_data);
+    /* Notify */
+    cmux->policy->notify_circ_inactive(cmux, cmux->policy_data,
+                                       circ, hashent->muxinfo.policy_data);
   }
 }
 
@@ -1153,11 +1149,8 @@ circuitmux_set_num_cells(circuitmux_t *cmux, circuit_t *circ,
   cmux->n_cells += n_cells;
 
   /* Do we need to notify a cmux policy? */
-  if (cmux->policy && cmux->policy_data &&
-      cmux->policy->notify_set_n_cells) {
-    /* Yeah; assert that we have circuit policy data */
-    tor_assert(hashent->muxinfo.policy_data);
-    /* ... and call notify_set_n_cells */
+  if (cmux->policy && cmux->policy->notify_set_n_cells) {
+    /* Call notify_set_n_cells */
     cmux->policy->notify_set_n_cells(cmux,
                                      cmux->policy_data,
                                      circ,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits