[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] tolerate bandwidtch buckets going negative (i hope)
Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or
Modified Files:
connection.c main.c
Log Message:
tolerate bandwidtch buckets going negative (i hope)
Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.314
retrieving revision 1.315
diff -u -d -r1.314 -r1.315
--- connection.c 12 Jan 2005 06:42:31 -0000 1.314
+++ connection.c 12 Jan 2005 10:00:38 -0000 1.315
@@ -734,14 +734,14 @@
/** We just read num_read onto conn. Decrement buckets appropriately. */
static void connection_read_bucket_decrement(connection_t *conn, int num_read) {
- global_read_bucket -= num_read; tor_assert(global_read_bucket >= 0);
+ global_read_bucket -= num_read; //tor_assert(global_read_bucket >= 0);
if (connection_speaks_cells(conn) && conn->state == OR_CONN_STATE_OPEN) {
- conn->receiver_bucket -= num_read; tor_assert(conn->receiver_bucket >= 0);
+ conn->receiver_bucket -= num_read; //tor_assert(conn->receiver_bucket >= 0);
}
}
static void connection_consider_empty_buckets(connection_t *conn) {
- if (global_read_bucket == 0) {
+ if (global_read_bucket <= 0) {
log_fn(LOG_DEBUG,"global bucket exhausted. Pausing.");
conn->wants_to_read = 1;
connection_stop_reading(conn);
@@ -749,7 +749,7 @@
}
if (connection_speaks_cells(conn) &&
conn->state == OR_CONN_STATE_OPEN &&
- conn->receiver_bucket == 0) {
+ conn->receiver_bucket <= 0) {
log_fn(LOG_DEBUG,"receiver bucket exhausted. Pausing.");
conn->wants_to_read = 1;
connection_stop_reading(conn);
@@ -772,11 +772,11 @@
or_options_t *options = get_options();
/* refill the global buckets */
- if ((unsigned)global_read_bucket < options->BandwidthBurst) {
+ if (global_read_bucket < (int)options->BandwidthBurst) {
global_read_bucket += (int)options->BandwidthRate;
log_fn(LOG_DEBUG,"global_read_bucket now %d.", global_read_bucket);
}
- if ((unsigned)global_write_bucket < options->BandwidthBurst) {
+ if (global_write_bucket < (int)options->BandwidthBurst) {
global_write_bucket += (int)options->BandwidthRate;
log_fn(LOG_DEBUG,"global_write_bucket now %d.", global_write_bucket);
}
@@ -878,7 +878,8 @@
}
if (!conn->marked_for_close &&
connection_is_reading(conn) &&
- !conn->inbuf_reached_eof)
+ !conn->inbuf_reached_eof &&
+ max_to_read > 0)
goto loop_again; /* try reading again, in case more is here now */
}
/* one last try, packaging partial cells and all. */
@@ -952,6 +953,7 @@
int r2 = read_to_buf_tls(conn->tls, pending, conn->inbuf);
if (r2<0) {
log_fn(LOG_WARN, "Bug: apparently, reading pending bytes can fail.");
+ return -1;
} else {
result += r2;
}
@@ -1482,7 +1484,7 @@
* gave a bad cert/etc, then we won't have assigned bandwidth,
* yet it will be open. -RD
*/
- tor_assert(conn->receiver_bucket >= 0);
+// tor_assert(conn->receiver_bucket >= 0);
}
tor_assert(conn->addr && conn->port);
tor_assert(conn->address);
Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.421
retrieving revision 1.422
diff -u -d -r1.421 -r1.422
--- main.c 12 Jan 2005 06:42:32 -0000 1.421
+++ main.c 12 Jan 2005 10:00:38 -0000 1.422
@@ -12,7 +12,7 @@
#include "or.h"
-/* These signals are defined to help control_singal_act work. */
+/* These signals are defined to help control_signal_act work. */
#ifndef SIGHUP
#define SIGHUP 1
#endif