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

[tor-commits] [tor/master] Eliminate unnecessary channel_set_cell_handler(), channel_set_var_cell_handler() in channel.c



commit e877d02fdde73934e727346a9da11018681a4c14
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
Date:   Mon Oct 8 20:06:40 2012 -0700

    Eliminate unnecessary channel_set_cell_handler(), channel_set_var_cell_handler() in channel.c
---
 src/or/channel.c |   89 +-----------------------------------------------------
 src/or/channel.h |    5 ---
 2 files changed, 1 insertions(+), 93 deletions(-)

diff --git a/src/or/channel.c b/src/or/channel.c
index b3ab2f0..f987cae 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -916,50 +916,7 @@ void
 }
 
 /**
- * Set the fixed-length cell handler for a channel
- *
- * This function sets the fixed-length cell handler for a channel and
- * processes any incoming cells that had been blocked in the queue because
- * none was available.
- *
- * @param chan Channel to set the fixed-length cell handler for
- * @param cell_handler Function pointer to new fixed-length cell handler
- */
-
-void
-channel_set_cell_handler(channel_t *chan,
-                         void (*cell_handler)(channel_t *, cell_t *))
-{
-  int changed = 0;
-
-  tor_assert(chan);
-  tor_assert(!(chan->is_listener));
-  tor_assert(chan->state == CHANNEL_STATE_OPENING ||
-             chan->state == CHANNEL_STATE_OPEN ||
-             chan->state == CHANNEL_STATE_MAINT);
-
-  log_debug(LD_CHANNEL,
-           "Setting cell_handler callback for channel %p to %p",
-           chan, cell_handler);
-
-  /*
-   * Keep track whether we've changed it so we know if there's any point in
-   * re-running the queue.
-   */
-  if (cell_handler != chan->u.cell_chan.cell_handler) changed = 1;
-
-  /* Change it */
-  chan->u.cell_chan.cell_handler = cell_handler;
-
-  /* Re-run the queue if we have one and there's any reason to */
-  if (chan->u.cell_chan.cell_queue &&
-      (smartlist_len(chan->u.cell_chan.cell_queue) > 0) &&
-      changed &&
-      chan->u.cell_chan.cell_handler) channel_process_cells(chan);
-}
-
-/**
- * Set the both cell handlers for a channel
+ * Set both cell handlers for a channel
  *
  * This function sets both the fixed-length and variable length cell handlers
  * for a channel and processes any incoming cells that had been blocked in the
@@ -1011,50 +968,6 @@ channel_set_cell_handlers(channel_t *chan,
 }
 
 /**
- * Set the variable-length cell handler for a channel
- *
- * This function sets the variable-length cell handler for a channel and
- * processes any incoming cells that had been blocked in the queue because
- * none was available.
- *
- * @param chan Channel to set the variable-length cell handler for
- * @param cell_handler Function pointer to new variable-length cell handler
- */
-
-void
-channel_set_var_cell_handler(channel_t *chan,
-                             void (*var_cell_handler)(channel_t *,
-                                                      var_cell_t *))
-{
-  int changed = 0;
-
-  tor_assert(chan);
-  tor_assert(!(chan->is_listener));
-  tor_assert(chan->state == CHANNEL_STATE_OPENING ||
-             chan->state == CHANNEL_STATE_OPEN ||
-             chan->state == CHANNEL_STATE_MAINT);
-
-  log_debug(LD_CHANNEL,
-           "Setting var_cell_handler callback for channel %p to %p",
-           chan, var_cell_handler);
-
-  /*
-   * Keep track whether we've changed it so we know if there's any point in
-   * re-running the queue.
-   */
-  if (var_cell_handler != chan->u.cell_chan.var_cell_handler) changed = 1;
-
-  /* Change it */
-  chan->u.cell_chan.var_cell_handler = var_cell_handler;
-
-  /* Re-run the queue if we have one and there's any reason to */
-  if (chan->u.cell_chan.cell_queue &&
-      (smartlist_len(chan->u.cell_chan.cell_queue) > 0) &&
-      changed && chan->u.cell_chan.var_cell_handler)
-    channel_process_cells(chan);
-}
-
-/**
  * Request a channel be closed
  *
  * This function tries to close a channel_t; it will go into the CLOSING
diff --git a/src/or/channel.h b/src/or/channel.h
index 7075981..fbcd38d 100644
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@ -247,15 +247,10 @@ void (* channel_get_cell_handler(channel_t *chan))
   (channel_t *, cell_t *);
 void (* channel_get_var_cell_handler(channel_t *chan))
   (channel_t *, var_cell_t *);
-void channel_set_cell_handler(channel_t *chan,
-                              void (*cell_handler)(channel_t *, cell_t *));
 void channel_set_cell_handlers(channel_t *chan,
                                void (*cell_handler)(channel_t *, cell_t *),
                                void (*var_cell_handler)(channel_t *,
                                                         var_cell_t *));
-void channel_set_var_cell_handler(channel_t *chan,
-                                  void (*var_cell_handler)(channel_t *,
-                                                           var_cell_t *));
 
 /* Clean up closed channels periodically; called from run_scheduled_events()
  * in main.c



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