diff options
author | Roger Dingledine <arma@torproject.org> | 2003-09-30 20:36:20 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-09-30 20:36:20 +0000 |
commit | dc8f40e4cb6ab40f42bd5557aeea1e2b4d97f6b5 (patch) | |
tree | 5d2eb0805f6631df0957379b1da7ad01fb9f5062 /src | |
parent | 9f0c608b7e3367fd11cab062c176a80231873a04 (diff) | |
download | tor-dc8f40e4cb6ab40f42bd5557aeea1e2b4d97f6b5.tar tor-dc8f40e4cb6ab40f42bd5557aeea1e2b4d97f6b5.tar.gz |
fix the SSL_read() bug again. this time for sure!
svn:r518
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection_or.c | 3 | ||||
-rw-r--r-- | src/or/main.c | 42 | ||||
-rw-r--r-- | src/or/routers.c | 2 |
3 files changed, 25 insertions, 22 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index da5e61b5b..eda322d7a 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -263,7 +263,8 @@ int connection_process_cell_from_inbuf(connection_t *conn) { char buf[CELL_NETWORK_SIZE]; cell_t cell; - log_fn(LOG_DEBUG,"%d: starting, inbuf_datalen %d.",conn->s,buf_datalen(conn->inbuf)); + log_fn(LOG_DEBUG,"%d: starting, inbuf_datalen %d (%d pending in tls object).", + conn->s,buf_datalen(conn->inbuf),tor_tls_get_pending_bytes(conn->tls)); if(buf_datalen(conn->inbuf) < CELL_NETWORK_SIZE) /* entire response available? */ return 0; /* not yet */ diff --git a/src/or/main.c b/src/or/main.c index 1d1d42bb1..1c4fa09a2 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -261,18 +261,15 @@ static void check_conn_marked(int i) { static int prepare_for_poll(void) { int i; - int timeout; connection_t *conn; struct timeval now; static long current_second = 0; /* from previous calls to gettimeofday */ static long time_to_fetch_directory = 0; static long time_to_new_circuit = 0; -// int ms_until_conn; cell_t cell; circuit_t *circ; my_gettimeofday(&now); - timeout = (1000 - (now.tv_usec / 1000)); /* how many milliseconds til the next second? */ if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */ @@ -327,8 +324,6 @@ static int prepare_for_poll(void) { /* check connections to see whether we should send a keepalive, expire, or wait */ if(!connection_speaks_cells(conn)) continue; /* this conn type doesn't send cells */ - if(connection_state_is_open(conn) && tor_tls_get_pending_bytes(conn->tls)) - timeout = 0; /* has pending bytes to read; don't let poll wait. */ if(now.tv_sec >= conn->timestamp_lastwritten + options.KeepalivePeriod) { if((!options.OnionRouter && !circuit_get_by_conn(conn)) || (!connection_state_is_open(conn))) { @@ -338,8 +333,8 @@ static int prepare_for_poll(void) { conn->marked_for_close = 1; } else { /* either a full router, or we've got a circuit. send a padding cell. */ -// log_fn(LOG_DEBUG,"Sending keepalive to (%s:%d)", -// conn->address, conn->port); + log_fn(LOG_DEBUG,"Sending keepalive to (%s:%d)", + conn->address, conn->port); memset(&cell,0,sizeof(cell_t)); cell.command = CELL_PADDING; if(connection_write_cell_to_buf(&cell, conn) < 0) @@ -357,7 +352,17 @@ static int prepare_for_poll(void) { current_second = now.tv_sec; /* remember which second it is, for next time */ } - return timeout; + for(i=0;i<nfds;i++) { + conn = connection_array[i]; + if(connection_speaks_cells(conn) && + connection_state_is_open(conn) && + tor_tls_get_pending_bytes(conn->tls)) { + log_fn(LOG_DEBUG,"sock %d has pending bytes.",conn->s); + return 0; /* has pending bytes to read; don't let poll wait. */ + } + } + + return (1000 - (now.tv_usec / 1000)); /* how many milliseconds til the next second? */ } static crypto_pk_env_t *init_key_from_file(const char *fname) @@ -599,19 +604,18 @@ static int do_main_loop(void) { } #endif - if(poll_result > 0) { /* we have at least one connection to deal with */ - /* do all the reads and errors first, so we can detect closed sockets */ - for(i=0;i<nfds;i++) - conn_read(i); /* this also blows away broken connections */ + /* do all the reads and errors first, so we can detect closed sockets */ + for(i=0;i<nfds;i++) + conn_read(i); /* this also blows away broken connections */ - /* then do the writes */ - for(i=0;i<nfds;i++) - conn_write(i); + /* then do the writes */ + for(i=0;i<nfds;i++) + conn_write(i); + + /* any of the conns need to be closed now? */ + for(i=0;i<nfds;i++) + check_conn_marked(i); - /* any of the conns need to be closed now? */ - for(i=0;i<nfds;i++) - check_conn_marked(i); - } /* refilling buckets and sending cells happens at the beginning of the * next iteration of the loop, inside prepare_for_poll() */ diff --git a/src/or/routers.c b/src/or/routers.c index 5628d30d9..e1f01df6e 100644 --- a/src/or/routers.c +++ b/src/or/routers.c @@ -711,10 +711,8 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest, ((int)signed_digest[2])&0xff,((int)signed_digest[3])&0xff); if (memcmp(digest, signed_digest, 20)) { log_fn(LOG_WARNING, "Error reading directory: signature does not match."); -#if 0 /* XXX, fix me */ free(tok.val.signature); goto err; -#endif } } free(tok.val.signature); |