From: Roger Dingledine Date: Tue, 30 Sep 2003 20:36:20 +0000 (+0000) Subject: fix the SSL_read() bug again. this time for sure! X-Git-Tag: tor-0.0.2pre13~113 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc8f40e4cb6ab40f42bd5557aeea1e2b4d97f6b5;p=thirdparty%2Ftor.git fix the SSL_read() bug again. this time for sure! svn:r518 --- diff --git a/src/or/connection_or.c b/src/or/connection_or.c index da5e61b5b1..eda322d7ac 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 1d1d42bb16..1c4fa09a23 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;itls)) { + 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