mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
bugfix: decrement OR connections from global_bucket too
bugfix: don't return immediately for has_pending_tls_data unless the conn is allowed to read svn:r1270
This commit is contained in:
parent
703b2d3cf8
commit
74ef3a63ae
@ -494,7 +494,7 @@ void connection_bucket_decrement(connection_t *conn, int num_read) {
|
||||
/* keep a timeval to know when time has passed enough to refill buckets */
|
||||
static struct timeval current_time;
|
||||
|
||||
void connection_bucket_init() {
|
||||
void connection_bucket_init(void) {
|
||||
tor_gettimeofday(¤t_time);
|
||||
global_read_bucket = options.BandwidthBurst; /* start it at max traffic */
|
||||
}
|
||||
@ -533,6 +533,7 @@ void connection_bucket_refill(struct timeval *now) {
|
||||
conn->state != OR_CONN_STATE_OPEN ||
|
||||
conn->receiver_bucket > 0)) {
|
||||
/* and either a non-cell conn or a cell conn with non-empty bucket */
|
||||
log_fn(LOG_DEBUG,"waking up conn (fd %d)",conn->s);
|
||||
conn->wants_to_read = 0;
|
||||
connection_start_reading(conn);
|
||||
if(conn->wants_to_write == 1) {
|
||||
@ -600,8 +601,10 @@ int connection_read_to_buf(connection_t *conn) {
|
||||
at_most = connection_bucket_read_limit(conn);
|
||||
|
||||
if(connection_speaks_cells(conn) && conn->state != OR_CONN_STATE_CONNECTING) {
|
||||
if(conn->state == OR_CONN_STATE_HANDSHAKING)
|
||||
if(conn->state == OR_CONN_STATE_HANDSHAKING) {
|
||||
/* continue handshaking even if global token bucket is empty */
|
||||
return connection_tls_continue_handshake(conn);
|
||||
}
|
||||
|
||||
/* else open, or closing */
|
||||
result = read_to_buf_tls(conn->tls, at_most, conn->inbuf);
|
||||
@ -616,7 +619,8 @@ int connection_read_to_buf(connection_t *conn) {
|
||||
return 0;
|
||||
case TOR_TLS_WANTREAD: /* we're already reading */
|
||||
case TOR_TLS_DONE: /* no data read, so nothing to process */
|
||||
return 0;
|
||||
result = 0;
|
||||
break; /* so we call bucket_decrement below */
|
||||
}
|
||||
} else {
|
||||
result = read_to_buf(conn->s, at_most, conn->inbuf,
|
||||
|
@ -421,7 +421,8 @@ static int prepare_for_poll(void) {
|
||||
|
||||
for(i=0;i<nfds;i++) {
|
||||
conn = connection_array[i];
|
||||
if(connection_has_pending_tls_data(conn)) {
|
||||
if(connection_has_pending_tls_data(conn) &&
|
||||
connection_is_reading(conn)) {
|
||||
log_fn(LOG_DEBUG,"sock %d has pending bytes.",conn->s);
|
||||
return 0; /* has pending bytes to read; don't let poll wait. */
|
||||
}
|
||||
|
@ -693,6 +693,9 @@ int connection_create_listener(char *bindaddress, uint16_t bindport, int type);
|
||||
int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port);
|
||||
int retry_all_connections(void);
|
||||
|
||||
void connection_bucket_init(void);
|
||||
void connection_bucket_refill(struct timeval *now);
|
||||
|
||||
int connection_handle_read(connection_t *conn);
|
||||
int connection_read_to_buf(connection_t *conn);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user