From 0f33c2d11806fb258b88cf5cb651484a4a9d0291 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 30 Aug 2004 15:21:05 +0000 Subject: [PATCH] timeout on ssl handshake; band-aid on assertion failure --- panda/src/downloader/httpChannel.cxx | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 3ab0a701c5..7dda82c113 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -785,6 +785,12 @@ reached_done_state() { } else { // Oops, we have to download the body now. + // We shouldn't already be in the middle of reading some other + // body when we come here. + if (_body_stream != NULL) { + delete _body_stream; + _body_stream = (ISocketStream *)NULL; + } _body_stream = read_body(); if (_body_stream == (ISocketStream *)NULL) { if (downloader_cat.is_debug()) { @@ -1375,6 +1381,12 @@ run_setup_ssl() { << "performing SSL handshake\n"; } _state = S_ssl_handshake; + + // We start the connect timer over again when we reach the SSL + // handshake. + _started_connecting_time = + ClockObject::get_global_clock()->get_real_time(); + return false; } @@ -1389,8 +1401,16 @@ bool HTTPChannel:: run_ssl_handshake() { if (BIO_do_handshake(_sbio) <= 0) { if (BIO_should_retry(_sbio)) { - return true; + double elapsed = + ClockObject::get_global_clock()->get_real_time() - + _started_connecting_time; + if (elapsed <= get_connect_timeout()) { + // Keep trying. + return true; + } + // Time to give up on the handshake. } + downloader_cat.info() << "Could not establish SSL handshake with " << _request.get_url().get_server_and_port() << "\n"; @@ -1852,9 +1872,9 @@ run_begin_body() { } else { // We shouldn't already be in the middle of reading some other // body when we come here. - nassertd(_body_stream == NULL) { - reset_to_new(); - return false; + if (_body_stream != NULL) { + delete _body_stream; + _body_stream = (ISocketStream *)NULL; } _body_stream = read_body(); if (_body_stream == (ISocketStream *)NULL) {