|
@@ -2650,14 +2650,6 @@ record_num_bytes_transferred(connection_t *conn,
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-#ifndef USE_BUFFEREVENTS
|
|
|
-
|
|
|
- * since midnight. */
|
|
|
-static uint32_t global_relayed_read_emptied = 0,
|
|
|
- global_relayed_write_emptied = 0,
|
|
|
- global_read_emptied = 0,
|
|
|
- global_write_emptied = 0;
|
|
|
-
|
|
|
|
|
|
* midnight. */
|
|
|
static uint32_t
|
|
@@ -2667,6 +2659,28 @@ msec_since_midnight(const struct timeval *tvnow)
|
|
|
((uint32_t)tvnow->tv_usec / (uint32_t)1000L));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 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;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
* <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
|
|
@@ -2680,6 +2694,14 @@ connection_buckets_note_empty_ts(uint32_t *timestamp_var,
|
|
|
*timestamp_var = msec_since_midnight(tvnow);
|
|
|
}
|
|
|
|
|
|
+#ifndef USE_BUFFEREVENTS
|
|
|
+
|
|
|
+ * since midnight. */
|
|
|
+static uint32_t global_relayed_read_emptied = 0,
|
|
|
+ global_relayed_write_emptied = 0,
|
|
|
+ global_read_emptied = 0,
|
|
|
+ global_write_emptied = 0;
|
|
|
+
|
|
|
|
|
|
* onto <b>conn</b>. Decrement buckets appropriately. */
|
|
|
static void
|
|
@@ -2838,28 +2860,6 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * 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;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
void
|
|
|
connection_bucket_refill(int milliseconds_elapsed, time_t now)
|