| 
														
															@@ -3019,57 +3019,6 @@ record_num_bytes_transferred_impl(connection_t *conn, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     rep_hist_note_exit_bytes(conn->port, num_written, num_read); 
														 | 
														
														 | 
														
															     rep_hist_note_exit_bytes(conn->port, num_written, num_read); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-/** Helper: convert given <b>tvnow</b> time value to milliseconds since 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * midnight. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-static uint32_t 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-msec_since_midnight(const struct timeval *tvnow) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  return (uint32_t)(((tvnow->tv_sec % 86400L) * 1000L) + 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-         ((uint32_t)tvnow->tv_usec / (uint32_t)1000L)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-/** Helper: return the time in milliseconds since <b>last_empty_time</b> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * when a bucket ran empty that previously had <b>tokens_before</b> tokens 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * now has <b>tokens_after</b> tokens after refilling at timestamp 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * <b>tvnow</b>, capped at <b>milliseconds_elapsed</b> milliseconds since 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * last refilling that bucket.  Return 0 if the bucket has not been empty 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * since the last refill or has not been refilled. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-uint32_t 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-bucket_millis_empty(int tokens_before, uint32_t last_empty_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    int tokens_after, int milliseconds_elapsed, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    const struct timeval *tvnow) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  uint32_t result = 0, refilled; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if (tokens_before <= 0 && tokens_after > tokens_before) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    refilled = msec_since_midnight(tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    result = (uint32_t)((refilled + 86400L * 1000L - last_empty_time) % 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-             (86400L * 1000L)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    if (result > (uint32_t)milliseconds_elapsed) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      result = (uint32_t)milliseconds_elapsed; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  return result; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-/** Check if a bucket which had <b>tokens_before</b> tokens and which got 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * <b>tokens_removed</b> tokens removed at timestamp <b>tvnow</b> has run 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * out of tokens, and if so, note the milliseconds since midnight in 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * <b>timestamp_var</b> for the next TB_EMPTY event. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-void 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-connection_buckets_note_empty_ts(uint32_t *timestamp_var, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                                 int tokens_before, size_t tokens_removed, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                                 const struct timeval *tvnow) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if (tokens_before > 0 && (uint32_t)tokens_before <= tokens_removed) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    *timestamp_var = msec_since_midnight(tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-/** Last time at which the global or relay buckets were emptied in msec 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * since midnight. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-static uint32_t global_relayed_read_emptied = 0, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                global_relayed_write_emptied = 0, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                global_read_emptied = 0, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                global_write_emptied = 0; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 /** We just read <b>num_read</b> and wrote <b>num_written</b> bytes 
														 | 
														
														 | 
														
															 /** We just read <b>num_read</b> and wrote <b>num_written</b> bytes 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * onto <b>conn</b>. Decrement buckets appropriately. */ 
														 | 
														
														 | 
														
															  * onto <b>conn</b>. Decrement buckets appropriately. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 static void 
														 | 
														
														 | 
														
															 static void 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -3094,30 +3043,6 @@ connection_buckets_decrement(connection_t *conn, time_t now, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if (!connection_is_rate_limited(conn)) 
														 | 
														
														 | 
														
															   if (!connection_is_rate_limited(conn)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     return; /* local IPs are free */ 
														 | 
														
														 | 
														
															     return; /* local IPs are free */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  /* If one or more of our token buckets ran dry just now, note the 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   * timestamp for TB_EMPTY events. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if (get_options()->TestingEnableTbEmptyEvent) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    struct timeval tvnow; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    tor_gettimeofday_cached(&tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    if (connection_counts_as_relayed_traffic(conn, now)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      connection_buckets_note_empty_ts(&global_relayed_read_emptied, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                         global_relayed_read_bucket, num_read, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      connection_buckets_note_empty_ts(&global_relayed_write_emptied, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                         global_relayed_write_bucket, num_written, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    connection_buckets_note_empty_ts(&global_read_emptied, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                       global_read_bucket, num_read, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    connection_buckets_note_empty_ts(&global_write_emptied, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                       global_write_bucket, num_written, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    if (connection_speaks_cells(conn) && conn->state == OR_CONN_STATE_OPEN) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      or_connection_t *or_conn = TO_OR_CONN(conn); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      connection_buckets_note_empty_ts(&or_conn->read_emptied_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                         or_conn->read_bucket, num_read, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      connection_buckets_note_empty_ts(&or_conn->write_emptied_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                         or_conn->write_bucket, num_written, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if (connection_counts_as_relayed_traffic(conn, now)) { 
														 | 
														
														 | 
														
															   if (connection_counts_as_relayed_traffic(conn, now)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     global_relayed_read_bucket -= (int)num_read; 
														 | 
														
														 | 
														
															     global_relayed_read_bucket -= (int)num_read; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     global_relayed_write_bucket -= (int)num_written; 
														 | 
														
														 | 
														
															     global_relayed_write_bucket -= (int)num_written; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -3238,12 +3163,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   smartlist_t *conns = get_connection_array(); 
														 | 
														
														 | 
														
															   smartlist_t *conns = get_connection_array(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   int bandwidthrate, bandwidthburst, relayrate, relayburst; 
														 | 
														
														 | 
														
															   int bandwidthrate, bandwidthburst, relayrate, relayburst; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int prev_global_read = global_read_bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int prev_global_write = global_write_bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int prev_relay_read = global_relayed_read_bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int prev_relay_write = global_relayed_write_bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  struct timeval tvnow; /*< Only used if TB_EMPTY events are enabled. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   bandwidthrate = (int)options->BandwidthRate; 
														 | 
														
														 | 
														
															   bandwidthrate = (int)options->BandwidthRate; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   bandwidthburst = (int)options->BandwidthBurst; 
														 | 
														
														 | 
														
															   bandwidthburst = (int)options->BandwidthBurst; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -3278,32 +3197,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                                   milliseconds_elapsed, 
														 | 
														
														 | 
														
															                                   milliseconds_elapsed, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                                   "global_relayed_write_bucket"); 
														 | 
														
														 | 
														
															                                   "global_relayed_write_bucket"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  /* If buckets were empty before and have now been refilled, tell any 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   * interested controllers. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if (get_options()->TestingEnableTbEmptyEvent) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    uint32_t global_read_empty_time, global_write_empty_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-             relay_read_empty_time, relay_write_empty_time; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    tor_gettimeofday_cached(&tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    global_read_empty_time = bucket_millis_empty(prev_global_read, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                             global_read_emptied, global_read_bucket, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                             milliseconds_elapsed, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    global_write_empty_time = bucket_millis_empty(prev_global_write, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                              global_write_emptied, global_write_bucket, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                              milliseconds_elapsed, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    control_event_tb_empty("GLOBAL", global_read_empty_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                           global_write_empty_time, milliseconds_elapsed); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    relay_read_empty_time = bucket_millis_empty(prev_relay_read, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                            global_relayed_read_emptied, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                            global_relayed_read_bucket, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                            milliseconds_elapsed, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    relay_write_empty_time = bucket_millis_empty(prev_relay_write, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                             global_relayed_write_emptied, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                             global_relayed_write_bucket, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                             milliseconds_elapsed, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    control_event_tb_empty("RELAY", relay_read_empty_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                           relay_write_empty_time, milliseconds_elapsed); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /* refill the per-connection buckets */ 
														 | 
														
														 | 
														
															   /* refill the per-connection buckets */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) { 
														 | 
														
														 | 
														
															   SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     if (connection_speaks_cells(conn)) { 
														 | 
														
														 | 
														
															     if (connection_speaks_cells(conn)) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -3311,9 +3204,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       int orbandwidthrate = or_conn->bandwidthrate; 
														 | 
														
														 | 
														
															       int orbandwidthrate = or_conn->bandwidthrate; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       int orbandwidthburst = or_conn->bandwidthburst; 
														 | 
														
														 | 
														
															       int orbandwidthburst = or_conn->bandwidthburst; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      int prev_conn_read = or_conn->read_bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      int prev_conn_write = or_conn->write_bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       if (connection_bucket_should_increase(or_conn->read_bucket, or_conn)) { 
														 | 
														
														 | 
														
															       if (connection_bucket_should_increase(or_conn->read_bucket, or_conn)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         connection_bucket_refill_helper(&or_conn->read_bucket, 
														 | 
														
														 | 
														
															         connection_bucket_refill_helper(&or_conn->read_bucket, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                                         orbandwidthrate, 
														 | 
														
														 | 
														
															                                         orbandwidthrate, 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -3328,27 +3218,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                                         milliseconds_elapsed, 
														 | 
														
														 | 
														
															                                         milliseconds_elapsed, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                                         "or_conn->write_bucket"); 
														 | 
														
														 | 
														
															                                         "or_conn->write_bucket"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      /* If buckets were empty before and have now been refilled, tell any 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-       * interested controllers. */ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      if (get_options()->TestingEnableTbEmptyEvent) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        char *bucket; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        uint32_t conn_read_empty_time, conn_write_empty_time; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        tor_asprintf(&bucket, "ORCONN ID="U64_FORMAT, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                     U64_PRINTF_ARG(or_conn->base_.global_identifier)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        conn_read_empty_time = bucket_millis_empty(prev_conn_read, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                               or_conn->read_emptied_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                               or_conn->read_bucket, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                               milliseconds_elapsed, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        conn_write_empty_time = bucket_millis_empty(prev_conn_write, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                                or_conn->write_emptied_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                                or_conn->write_bucket, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                                milliseconds_elapsed, &tvnow); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        control_event_tb_empty(bucket, conn_read_empty_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                               conn_write_empty_time, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                               milliseconds_elapsed); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        tor_free(bucket); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     if (conn->read_blocked_on_bw == 1 /* marked to turn reading back on now */ 
														 | 
														
														 | 
														
															     if (conn->read_blocked_on_bw == 1 /* marked to turn reading back on now */ 
														 |