[tor-commits] [tor/master] sched: reorder code to fit comment bodies; comment typos

nickm at torproject.org nickm at torproject.org
Wed Sep 20 00:22:40 UTC 2017


commit 4a3b61a5b32d4df7d627f993deec97f1db451910
Author: Matt Traudt <sirmatt at ksu.edu>
Date:   Tue Sep 19 20:03:17 2017 -0400

    sched: reorder code to fit comment bodies; comment typos
    
    Closes 23560
---
 src/or/scheduler.c         |  2 +-
 src/or/scheduler.h         |  4 ++--
 src/or/scheduler_kist.c    | 45 ++++++++++++++++++++++-----------------------
 src/or/scheduler_vanilla.c |  2 +-
 4 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/src/or/scheduler.c b/src/or/scheduler.c
index 6ce7cb1e0..e75e30605 100644
--- a/src/or/scheduler.c
+++ b/src/or/scheduler.c
@@ -25,7 +25,7 @@
  * - "Scheduler implementation": a scheduler_t. The scheduling system has one
  *   active scheduling implementation at a time.
  *
- * In this file you will find state that any scheduler implmentation can have
+ * In this file you will find state that any scheduler implementation can have
  * access to as well as the functions the rest of Tor uses to interact with the
  * scheduling system.
  *
diff --git a/src/or/scheduler.h b/src/or/scheduler.h
index 3c0748fa6..93da1c904 100644
--- a/src/or/scheduler.h
+++ b/src/or/scheduler.h
@@ -53,7 +53,7 @@ typedef struct scheduler_s {
    * we should do whatever we need to do in order to move some cells from
    * their circuit queues to output buffers in an intelligent manner. We
    * should do this quickly. When we are done, we'll try to schedule() ourself
-   * if more work needs to be done to setup the next scehduling run. */
+   * if more work needs to be done to setup the next scheduling run. */
   void (*run)(void);
 
   /*
@@ -157,7 +157,7 @@ void scheduler_touch_channel(channel_t *chan);
 
 #ifdef SCHEDULER_KIST_PRIVATE
 
-/* Socke table entry which holds information of a channel's socket and kernel
+/* Socket table entry which holds information of a channel's socket and kernel
  * TCP information. Only used by KIST. */
 typedef struct socket_table_ent_s {
   HT_ENTRY(socket_table_ent_s) node;
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c
index 4713ffdff..8b0c81c4c 100644
--- a/src/or/scheduler_kist.c
+++ b/src/or/scheduler_kist.c
@@ -28,18 +28,6 @@
  * Data structures and supporting functions
  *****************************************************************************/
 
-#ifdef HAVE_KIST_SUPPORT
-/* Indicate if KIST lite mode is on or off. We can disable it at runtime.
- * Important to have because of the KISTLite -> KIST possible transition. */
-static unsigned int kist_lite_mode = 0;
-/* Indicate if we don't have the kernel support. This can happen if the kernel
- * changed and it doesn't recognized the values passed to the syscalls needed
- * by KIST. In that case, fallback to the naive approach. */
-static unsigned int kist_no_kernel_support = 0;
-#else /* !(defined(HAVE_KIST_SUPPORT)) */
-static unsigned int kist_lite_mode = 1;
-#endif /* defined(HAVE_KIST_SUPPORT) */
-
 /* Socket_table hash table stuff. The socket_table keeps track of per-socket
  * limit information imposed by kist and used by kist. */
 
@@ -105,6 +93,18 @@ static double sock_buf_size_factor = 1.0;
 /* How often the scheduler runs. */
 STATIC int32_t sched_run_interval = 10;
 
+#ifdef HAVE_KIST_SUPPORT
+/* Indicate if KIST lite mode is on or off. We can disable it at runtime.
+ * Important to have because of the KISTLite -> KIST possible transition. */
+static unsigned int kist_lite_mode = 0;
+/* Indicate if we don't have the kernel support. This can happen if the kernel
+ * changed and it doesn't recognized the values passed to the syscalls needed
+ * by KIST. In that case, fallback to the naive approach. */
+static unsigned int kist_no_kernel_support = 0;
+#else /* !(defined(HAVE_KIST_SUPPORT)) */
+static unsigned int kist_lite_mode = 1;
+#endif /* defined(HAVE_KIST_SUPPORT) */
+
 /*****************************************************************************
  * Internally called function implementations
  *****************************************************************************/
@@ -256,8 +256,8 @@ update_socket_info_impl, (socket_table_ent_t *ent))
    *
    * <----------------kernel-outbound-socket-queue----------------|
    * <*********---------------------------------------------------|
-   * <----TCP-space-----|----extra-space-----|
-   * <------------------|
+   * |----TCP-space-----|----extra-space-----|
+   * |------------------|
    *                    ^ ((cwnd - unacked) * mss) bytes
    *                    |--------------------|
    *                                         ^ ((cwnd * mss) * factor) bytes
@@ -304,7 +304,7 @@ update_socket_info_impl, (socket_table_ent_t *ent))
 }
 
 /* Given a socket that isn't in the table, add it.
- * Given a socket that is in the table, reinit values that need init-ing
+ * Given a socket that is in the table, re-init values that need init-ing
  * every scheduling run
  */
 static void
@@ -364,8 +364,7 @@ set_scheduler_run_interval(const networkstatus_t *ns)
   }
 }
 
-/* Return true iff the channel associated socket can write to the kernel that
- * is hasn't reach the limit. */
+/* Return true iff the channel hasn’t hit its kist-imposed write limit yet */
 static int
 socket_can_write(socket_table_t *table, const channel_t *chan)
 {
@@ -375,7 +374,7 @@ socket_can_write(socket_table_t *table, const channel_t *chan)
     return 1; // Just return true, saying that kist wouldn't limit the socket
   }
 
-  /* We previously caclulated a write limit for this socket. In the below
+  /* We previously calculated a write limit for this socket. In the below
    * calculation, first determine how much room is left in bytes. Then divide
    * that by the amount of space a cell takes. If there's room for at least 1
    * cell, then KIST will allow the socket to write. */
@@ -397,7 +396,7 @@ update_socket_info(socket_table_t *table, const channel_t *chan)
   update_socket_info_impl(ent);
 }
 
-/* Increament the channel's socket written value by the number of bytes. */
+/* Increment the channel's socket written value by the number of bytes. */
 static void
 update_socket_written(socket_table_t *table, channel_t *chan, size_t bytes)
 {
@@ -523,11 +522,11 @@ kist_scheduler_schedule(void)
   if (diff < sched_run_interval) {
     next_run.tv_sec = 0;
     /* Takes 1000 ms -> us. This will always be valid because diff can NOT be
-     * negative and can NOT be smaller than sched_run_interval so values can
+     * negative and can NOT be bigger than sched_run_interval so values can
      * only go from 1000 usec (diff set to interval - 1) to 100000 usec (diff
      * set to 0) for the maximum allowed run interval (100ms). */
     next_run.tv_usec = (int) ((sched_run_interval - diff) * 1000);
-    /* Readding an event reschedules it. It does not duplicate it. */
+    /* Re-adding an event reschedules it. It does not duplicate it. */
     scheduler_ev_add(&next_run);
   } else {
     scheduler_ev_active(EV_TIMEOUT);
@@ -543,7 +542,7 @@ kist_scheduler_run(void)
   /* The last distinct chan served in a sched loop. */
   channel_t *prev_chan = NULL;
   int flush_result; // temporarily store results from flush calls
-  /* Channels to be readding to pending at the end */
+  /* Channels to be re-adding to pending at the end */
   smartlist_t *to_readd = NULL;
   smartlist_t *cp = get_channels_pending();
 
@@ -667,7 +666,7 @@ kist_scheduler_run(void)
             smartlist_len(cp),
             (to_readd ? smartlist_len(to_readd) : -1));
 
-  /* Readd any channels we need to */
+  /* Re-add any channels we need to */
   if (to_readd) {
     SMARTLIST_FOREACH_BEGIN(to_readd, channel_t *, readd_chan) {
       readd_chan->scheduler_state = SCHED_CHAN_PENDING;
diff --git a/src/or/scheduler_vanilla.c b/src/or/scheduler_vanilla.c
index 09653f445..a49f7a1cb 100644
--- a/src/or/scheduler_vanilla.c
+++ b/src/or/scheduler_vanilla.c
@@ -32,7 +32,7 @@ have_work(void)
   return smartlist_len(cp) > 0;
 }
 
-/** Retrigger the scheduler in a way safe to use from the callback */
+/** Re-trigger the scheduler in a way safe to use from the callback */
 
 static void
 vanilla_scheduler_schedule(void)



More information about the tor-commits mailing list