[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp |
Date: |
Wed, 28 May 2008 17:51:09 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/05/28 17:51:08
Modified files:
. : ChangeLog
libbase : curl_adapter.cpp
Log message:
* libbase/curl_adapter.cpp: keep select() timeout low (1/100 of
second), to allow thread switching while waiting for input.
Re-intruduce the WallClock to implement user-requested
streams timeout.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6746&r2=1.6747
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/curl_adapter.cpp?cvsroot=gnash&r1=1.55&r2=1.56
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6746
retrieving revision 1.6747
diff -u -b -r1.6746 -r1.6747
--- ChangeLog 28 May 2008 16:35:01 -0000 1.6746
+++ ChangeLog 28 May 2008 17:51:07 -0000 1.6747
@@ -1,5 +1,12 @@
2008-05-28 Sandro Santilli <address@hidden>
+ * libbase/curl_adapter.cpp: keep select() timeout low (1/100 of
+ second), to allow thread switching while waiting for input.
+ Re-intruduce the WallClock to implement user-requested
+ streams timeout.
+
+2008-05-28 Sandro Santilli <address@hidden>
+
* libbase/curl_adapter.cpp (fillCache): spaces to tabs, comments
about timeout constraints.
Index: libbase/curl_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/curl_adapter.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- libbase/curl_adapter.cpp 28 May 2008 16:35:02 -0000 1.55
+++ libbase/curl_adapter.cpp 28 May 2008 17:51:08 -0000 1.56
@@ -26,6 +26,7 @@
#include "tu_file.h"
#include "curl_adapter.h"
#include "log.h"
+#include "WallClockTimer.h"
#ifndef USE_CURL
// Stub for warning about access when no libcurl is defined.
@@ -277,9 +278,19 @@
CURLMcode mcode;
timeval tv;
- const unsigned int timeout = static_cast<unsigned int>(
-
gnash::RcInitFile::getDefaultInstance().getStreamsTimeout());
+ // Hard-coded slect timeout.
+ // This number is kept low to give more thread switch
+ // opportunities while waiting for a load.
+ const long maxSleepUsec = 10000; // 1/100 of a second
+ const unsigned int userTimeout = static_cast<unsigned int>(
+
gnash::RcInitFile::getDefaultInstance().getStreamsTimeout()*1000);
+
+#ifdef GNASH_CURL_VERBOSE
+ gnash::log_debug("User timeout is %u milliseconds", userTimeout);
+#endif
+
+ gnash::WallClockTimer lastProgress; // timer since last progress
while (_running)
{
@@ -293,9 +304,10 @@
throw gnash::GnashException(curl_multi_strerror(mcode));
}
- // Do this here to avoid calling select() when we have enough
- // bytes anyway.
- if (_cached >= size) break;
+ // Do this here to avoid calling select()
+ // when we have enough bytes anyway, or
+ // we reached EOF
+ if (_cached >= size || !_running) break;
#if GNASH_CURL_VERBOSE
//gnash::log_debug("cached: %d, size: %d", _cached, size);
@@ -324,16 +336,51 @@
FD_ZERO(&writefd);
FD_ZERO(&exceptfd);
- // TODO: don't wait more then curl_multi_timeout()
- // [ or an fixed max is that's not supported
- // by current curl version ]
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
+ tv.tv_sec = 0;
+ tv.tv_usec = maxSleepUsec;
+#ifdef GNASH_CURL_VERBOSE
+ gnash::log_debug("select() with %d milliseconds timeout",
maxSleepUsec*1000);
+#endif
// Wait for data on the filedescriptors until a timeout set
// in gnashrc.
- select(maxfd + 1, &readfd, &writefd, &exceptfd, &tv);
+ int ret = select(maxfd + 1, &readfd, &writefd, &exceptfd, &tv);
+ if ( ret == -1 )
+ {
+ // something unexpected happened
+ boost::format fmt = boost::format(
+ "error polling data from connection to %s: %s ")
+ % _url % strerror(errno);
+ throw gnash::GnashException(fmt.str());
+ }
+ if ( ! ret )
+ {
+ // timeout
+#ifdef GNASH_CURL_VERBOSE
+ gnash::log_debug("select() timed out, elapsed is %u",
lastProgress.elapsed() );
+#endif
+ if ( userTimeout && lastProgress.elapsed() >
userTimeout )
+ {
+ gnash::log_error(_("Timeout (%u milliseconds)
while loading from url %s"),
+ userTimeout, _url);
+ // TODO: should we set _error here ?
+ return;
+ }
+ }
+ else
+ {
+#ifdef GNASH_CURL_VERBOSE
+ gnash::log_debug("FD activity, resetting progress
timer");
+#endif
+ lastProgress.restart();
+ }
+
+
+ // TODO: check if we timedout or got some data
+ // if we did timeout, check the clock to see
+ // if we expired the user Timeout, otherwise
+ // reset the timer...
}
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/27
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Benjamin Wolsey, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Benjamin Wolsey, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Benjamin Wolsey, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Benjamin Wolsey, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/28
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/29
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp, Sandro Santilli, 2008/05/29