From 6b837e55fd1cac9f9da21f8c015d20fcd9e70895 Mon Sep 17 00:00:00 2001 From: Redmond Urbino Date: Fri, 6 Aug 2010 21:36:18 +0000 Subject: [PATCH] more robust client when dealing with slow network connections --- panda/src/downloader/bioStreamBuf.cxx | 10 ++++++++++ panda/src/downloader/httpChannel.cxx | 7 ++++++- panda/src/downloader/httpChannel.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index b671e30753..588593f50c 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -194,6 +194,16 @@ underflow() { // the server. But BIO_should_retry() *appears* to be // reliable. _read_open = (BIO_should_retry(*_source) != 0); + +#ifdef IS_OSX + // occassionally we get -1 on read_open on the mac + // the os_error is 35 which means "Resource temporarily unavailable". + if ( (_read_open == -1) && (os_error == 35)) { + downloader_cat.warning() << "forcing retry to true again and _read_open to true\n"; + BIO_set_retry_read(*_source); + _read_open = true; + } +#endif if (!_read_open) { downloader_cat.info() << "Lost connection to " diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index fc77aaefba..036e52e70e 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -44,6 +44,11 @@ HTTPChannel:: HTTPChannel(HTTPClient *client) : _client(client) { + ConfigVariableDouble extra_ssl_handshake_time + ("extra-ssl-handshake-time", 0.0, + PRC_DESC("This specifies how much extra time to try to establish" + "the ssl handshake before we bail.")); + _extra_ssl_handshake_time = extra_ssl_handshake_time; _proxy_next_index = 0; _persistent_connection = false; _allow_proxy = true; @@ -1563,7 +1568,7 @@ run_ssl_handshake() { double elapsed = TrueClock::get_global_ptr()->get_short_time() - _started_connecting_time; - if (elapsed <= get_connect_timeout()) { + if (elapsed <= get_connect_timeout() + _extra_ssl_handshake_time) { // Keep trying. return true; } diff --git a/panda/src/downloader/httpChannel.h b/panda/src/downloader/httpChannel.h index 344b8b60f8..5b5abb66ba 100644 --- a/panda/src/downloader/httpChannel.h +++ b/panda/src/downloader/httpChannel.h @@ -429,6 +429,10 @@ private: int _last_status_code; double _last_run_time; + // RAU we find that we may need a little more time for the + // ssl handshake when the phase files are downloading + double _extra_ssl_handshake_time; + public: virtual TypeHandle get_type() const { return get_class_type();