[tor-commits] [tor/master] Actually call channel_flush_some_cells() from the scheduler

nickm at torproject.org nickm at torproject.org
Fri Nov 28 03:58:31 UTC 2014


commit b09f41424c7e0da63733c2fdda5332d63a7f4e0f
Author: Andrea Shepard <andrea at torproject.org>
Date:   Thu Oct 31 19:37:57 2013 -0700

    Actually call channel_flush_some_cells() from the scheduler
---
 src/or/connection_or.c |   29 +----------------------------
 src/or/scheduler.c     |   16 ++++++++++------
 2 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index a8f9d41..6b276cc 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -581,9 +581,7 @@ connection_or_process_inbuf(or_connection_t *conn)
 int
 connection_or_flushed_some(or_connection_t *conn)
 {
-  size_t datalen, temp;
-  ssize_t n, flushed;
-  size_t cell_network_size = get_cell_network_size(conn->wide_circ_ids);
+  size_t datalen;
 
   /* If we're under the low water mark, add cells until we're just over the
    * high water mark. */
@@ -591,31 +589,6 @@ connection_or_flushed_some(or_connection_t *conn)
   if (datalen < OR_CONN_LOWWATER) {
     /* Let the scheduler know */
     scheduler_channel_wants_writes(TLS_CHAN_TO_BASE(conn->chan));
-
-    /*
-     * TODO this will be done from the scheduler, so it will
-     * need a generic way to ask how many cells a channel can
-     * accept and if it still wants writes or not to know how
-     * to account for it in the case that it runs out of cells
-     * to send first.
-     */
-
-    while ((conn->chan) && channel_tls_more_to_flush(conn->chan)) {
-      /* Compute how many more cells we want at most */
-      n = CEIL_DIV(OR_CONN_HIGHWATER - datalen, cell_network_size);
-      /* Bail out if we don't want any more */
-      if (n <= 0) break;
-      /* We're still here; try to flush some more cells */
-      flushed = channel_tls_flush_some_cells(conn->chan, n);
-      /* Bail out if it says it didn't flush anything */
-      if (flushed <= 0) break;
-      /* How much in the outbuf now? */
-      temp = connection_get_outbuf_len(TO_CONN(conn));
-      /* Bail out if we didn't actually increase the outbuf size */
-      if (temp <= datalen) break;
-      /* Update datalen for the next iteration */
-      datalen = temp;
-    }
   }
 
   return 0;
diff --git a/src/or/scheduler.c b/src/or/scheduler.c
index 7023eaa..1c6a2fd 100644
--- a/src/or/scheduler.c
+++ b/src/or/scheduler.c
@@ -325,18 +325,15 @@ scheduler_run(void)
 {
   smartlist_t *tmp = NULL;
   int n_cells;
+  ssize_t flushed, flushed_this_time;
 
   log_debug(LD_SCHED, "We have a chance to run the scheduler");
 
-  /*
-   * TODO make this work properly
-   *
-   * For now, just empty the pending list and log that we saw stuff in it
-   */
-
   tmp = channels_pending;
   channels_pending = smartlist_new();
 
+  /* For now, just run the old scheduler on all the chans in the list */
+
   SMARTLIST_FOREACH_BEGIN(tmp, channel_t *, chan) {
     n_cells = channel_num_cells_writeable(chan);
     if (n_cells > 0) {
@@ -344,6 +341,13 @@ scheduler_run(void)
                 "Scheduler saw pending channel " U64_FORMAT " at %p with "
                 "%d cells writeable",
                 U64_PRINTF_ARG(chan->global_identifier), chan, n_cells);
+
+      flushed = 0;
+      while (flushed < n_cells) {
+        flushed_this_time = channel_flush_some_cells(chan, n_cells - flushed);
+        if (flushed_this_time <= 0) break;
+        flushed += flushed_this_time;
+      }
     } else {
       log_info(LD_SCHED,
                "Scheduler saw pending channel " U64_FORMAT " at %p with "





More information about the tor-commits mailing list