[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/Makefile.am libbase/cur...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/Makefile.am libbase/cur... |
Date: |
Tue, 25 Sep 2007 14:17:22 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/09/25 14:17:22
Modified files:
. : ChangeLog
libbase : Makefile.am curl_adapter.cpp rc.cpp rc.h
testsuite/libbase: TCXXRc.cpp gnashrc.in
Added files:
libbase : WallClockTimer.cpp WallClockTimer.h
Log message:
* libbase/: Makefile.am, WallClockTimer.{h,cpp}:
New class for wall-clock timing. Interface borrowed
by boost::timer, but this one uses wall-clock and
talks milliseconds instead of seconds.
* libbase/rc.{cpp,h}: add support for streamsTimeout
setting.
* testsuite/libbase/: TCXXRc.cpp, gnashrc.in: test
streamsTimeout setting.
* libbase/curl_adapter.cpp (fill_cache): implement
stream timeout.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4403&r2=1.4404
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Makefile.am?cvsroot=gnash&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/curl_adapter.cpp?cvsroot=gnash&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/WallClockTimer.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/WallClockTimer.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libbase/TCXXRc.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libbase/gnashrc.in?cvsroot=gnash&r1=1.7&r2=1.8
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4403
retrieving revision 1.4404
diff -u -b -r1.4403 -r1.4404
--- ChangeLog 25 Sep 2007 13:17:57 -0000 1.4403
+++ ChangeLog 25 Sep 2007 14:17:18 -0000 1.4404
@@ -1,3 +1,16 @@
+2007-09-25 Sandro Santilli <address@hidden>
+
+ * libbase/: Makefile.am, WallClockTimer.{h,cpp}:
+ New class for wall-clock timing. Interface borrowed
+ by boost::timer, but this one uses wall-clock and
+ talks milliseconds instead of seconds.
+ * libbase/rc.{cpp,h}: add support for streamsTimeout
+ setting.
+ * testsuite/libbase/: TCXXRc.cpp, gnashrc.in: test
+ streamsTimeout setting.
+ * libbase/curl_adapter.cpp (fill_cache): implement
+ stream timeout.
+
2007-09-25 Benjamin Wolsey <address@hidden>
* server/gnash.h: fix typo in key::codeMap.
Index: libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libbase/Makefile.am,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- libbase/Makefile.am 16 Sep 2007 16:48:12 -0000 1.84
+++ libbase/Makefile.am 25 Sep 2007 14:17:19 -0000 1.85
@@ -97,6 +97,7 @@
$(SDL_FILE) \
tu_random.cpp \
tu_timer.cpp \
+ WallClockTimer.cpp \
tu_types.cpp \
utf8.cpp \
utility.cpp \
@@ -143,6 +144,7 @@
tu_random.h \
tu_swap.h \
tu_timer.h \
+ WallClockTimer.h \
tu_types.h \
utf8.h \
utility.h \
Index: libbase/curl_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/curl_adapter.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- libbase/curl_adapter.cpp 9 Jul 2007 07:31:05 -0000 1.38
+++ libbase/curl_adapter.cpp 25 Sep 2007 14:17:20 -0000 1.39
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: curl_adapter.cpp,v 1.38 2007/07/09 07:31:05 martinwguy Exp $ */
+/* $Id: curl_adapter.cpp,v 1.39 2007/09/25 14:17:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -28,6 +28,9 @@
#include "utility.h"
#include "GnashException.h"
#include "log.h"
+#include "rc.h"
+//#include "tu_timer.h"
+#include "WallClockTimer.h"
#include <map>
#include <iostream>
@@ -299,9 +302,15 @@
CurlStreamFile::fill_cache(long unsigned size)
{
#ifdef GNASH_CURL_VERBOSE
- fprintf(stderr, "fill_cache(%d) called\n", size);
+ fprintf(stderr, "fill_cache(%lu) called\n", size);
#endif
+ // I don't think we can rely on this, unless we
+ // can trust the result (the interface isn't documented
+ // about trust of it)
+ //
+ // if ( size > get_stream_size() ) return;
+
// Disable this when you're convinced the sleeping mechanism is satisfactory
//#define VERBOSE_POLLING_LOOP 1
@@ -314,13 +323,19 @@
// of data requested haven't arrived yet.
//
const long unsigned minSleep = 10000; // 1/100 second
- const long unsigned maxSleep = 100000; // 1/10 second
+ const long unsigned maxSleep = 1000000; // 1/10 second
CURLMcode mcode;
-#if VERBOSE_POLLING_LOOP
long unsigned lastCached = _cached;
-#endif
long unsigned sleepTime = minSleep;
+
+ // Timeout in milliseconds (TODO: have getStreamsTimeout return
milliseconds)
+ static const unsigned int timeout =
int(gnash::RcInitFile::getDefaultInstance().getStreamsTimeout()*1000.0);
+#if VERBOSE_POLLING_LOOP
+ printf("Timeout is %u\n", timeout);
+#endif
+
+ gnash::WallClockTimer lastProgress; // timer since last progress
while (_cached < size && _running)
{
do
@@ -339,13 +354,35 @@
// In order to avoid overusing the CPU we take a nap if we
didn't
// reach the requested position.
-#if VERBOSE_POLLING_LOOP
long unsigned fetched = _cached - lastCached;
+ if ( fetched )
+ {
+#if VERBOSE_POLLING_LOOP
+ fprintf(stderr, "Fetched %lu bytes, resetting progress
timer\n", fetched);
+#endif
+ lastProgress.restart();
+ }
+ else
+ {
+#if VERBOSE_POLLING_LOOP
+ fprintf(stderr, "Nothing fetched, elapsed is %u\n",
lastProgress.elapsed() );
+#endif
+ if ( timeout && lastProgress.elapsed() > timeout )
+ {
+ gnash::log_error(_("Timeout (%u milliseconds)
while loading from url %s"), timeout, _url.c_str());
+ return;
+ }
+ }
- fprintf(stderr, "CurlStreamFile %p: Fetched: %lu (%lu/%lu
total) - requested %lu (%lu total) - sleeping %lu milliseconds\n",
- this, fetched, _cached, get_stream_size(),
fetchRequested, size, sleepTime/1000);
- lastCached = _cached;
+#if VERBOSE_POLLING_LOOP
+ fprintf(stderr, "CurlStreamFile %p: Fetched: %lu (%lu/%lu
total) from url %s"
+ " - requested %lu (%lu total) - sleeping %lu
milliseconds "
+ " - %u millisecond since last progress (timeout
is %u)\n",
+ this, fetched, _cached, get_stream_size(),
_url.c_str(),
+ fetchRequested, size, sleepTime/1000,
lastProgress.elapsed(),
+ timeout);
#endif
+ lastCached = _cached;
usleep(sleepTime);
Index: libbase/rc.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- libbase/rc.cpp 13 Sep 2007 18:33:20 -0000 1.34
+++ libbase/rc.cpp 25 Sep 2007 14:17:20 -0000 1.35
@@ -41,6 +41,11 @@
#include "log.h"
#include "rc.h"
+#ifndef DEFAULT_STREAMS_TIMEOUT
+// TODO: add a ./configure switch to set this
+# define DEFAULT_STREAMS_TIMEOUT 10
+#endif
+
using namespace std;
namespace gnash {
@@ -74,7 +79,9 @@
_sound(true),
_plugin_sound(true),
_extensionsEnabled(false),
- _startStopped(false)
+ _startStopped(false),
+ _streamsTimeout(DEFAULT_STREAMS_TIMEOUT)
+
{
// GNASH_REPORT_FUNCTION;
loadFiles();
@@ -145,13 +152,32 @@
string &value)
{
// GNASH_REPORT_FUNCTION;
+
+ StringNoCaseEqual noCaseCompare;
+
// log_msg ("%s: %s", variable.c_str(), value.c_str());
- if (variable == pattern) {
+ if ( noCaseCompare(variable, pattern) ) {
*num = strtol(value.c_str(), NULL, 0);
}
return *num;
}
+void
+RcInitFile::extractDouble(double& out, const char *pattern, string &variable,
+ string &value)
+{
+// GNASH_REPORT_FUNCTION;
+
+ StringNoCaseEqual noCaseCompare;
+
+ // printf("%s: %s\n", variable.c_str(), value.c_str());
+
+ if ( noCaseCompare(variable, pattern) ) {
+ out = strtod(value.c_str(), 0);
+ //printf("strtod returned %g\n", out);
+ }
+}
+
string
RcInitFile::expandPath (std::string _path)
@@ -283,6 +309,8 @@
variable, value);
extractSetting(&_startStopped, "StartStopped", variable,
value);
+ extractDouble(_streamsTimeout, "StreamsTimeout", variable,
value);
+
extractNumber(&_delay, "delay", variable, value);
extractNumber(&_verbosity, "verbosity", variable, value);
Index: libbase/rc.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- libbase/rc.h 23 Aug 2007 09:37:22 -0000 1.25
+++ libbase/rc.h 25 Sep 2007 14:17:21 -0000 1.26
@@ -104,6 +104,12 @@
int getRetries() const { return _retries; }
void setRetries(int x) { _retries = x; }
+ /// Return the number of seconds of inactivity before timing out streams
downloads
+ double getStreamsTimeout() const { return _streamsTimeout; }
+
+ /// Set the number of seconds of inactivity before timing out streams
downloads
+ void setStreamsTimeout(double x) { _streamsTimeout = x; }
+
void dump();
private:
@@ -149,6 +155,9 @@
bool _startStopped; // whether to start the gui in "stop"
mode
+ /// The number of seconds of inactivity triggering download timeout
+ double _streamsTimeout;
+
static std::string expandPath(std::string _path); //path string operations
static bool extractSetting(bool *var, const char *pattern,
@@ -157,6 +166,9 @@
static int extractNumber(int *num, const char *pattern,
std::string &variable, std::string &value);
+ static void extractDouble(double& out, const char *pattern,
+ std::string &variable, std::string &value);
+
};
//extern DSOEXPORT RcInitFile rcfile;
Index: testsuite/libbase/TCXXRc.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libbase/TCXXRc.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- testsuite/libbase/TCXXRc.cpp 20 Aug 2007 10:39:23 -0000 1.16
+++ testsuite/libbase/TCXXRc.cpp 25 Sep 2007 14:17:21 -0000 1.17
@@ -176,6 +176,12 @@
runtest.fail ("startStopped");
}
+ if (rc.getStreamsTimeout() == 1.5) {
+ runtest.pass ("streamsTimeout");
+ } else {
+ runtest.fail ("streamsTimeout");
+ }
+
std::vector<std::string> whitelist = rc.getWhiteList();
if (whitelist.size()) {
if ((whitelist[0] == "www.doonesbury.com")
Index: testsuite/libbase/gnashrc.in
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libbase/gnashrc.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/libbase/gnashrc.in 20 Aug 2007 10:39:23 -0000 1.7
+++ testsuite/libbase/gnashrc.in 25 Sep 2007 14:17:21 -0000 1.8
@@ -48,3 +48,9 @@
# Start the gui in STOP mode
set startStopped on
+
+# Timeout in seconds for stream download
+# The download will timeout after the given seconds
+# of inactivity. Every activity resets the timer
+#
+set streamsTimeout 1.5
Index: libbase/WallClockTimer.cpp
===================================================================
RCS file: libbase/WallClockTimer.cpp
diff -N libbase/WallClockTimer.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/WallClockTimer.cpp 25 Sep 2007 14:17:20 -0000 1.1
@@ -0,0 +1,56 @@
+// WallClockTimer.cpp: Wall clock timer, for Gnash.
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+/* $Id: WallClockTimer.cpp,v 1.1 2007/09/25 14:17:20 strk Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "WallClockTimer.h"
+
+#include "tu_timer.h" // for "portable" get_ticks (contains implementation for
win32)
+
+namespace gnash {
+
+WallClockTimer::WallClockTimer()
+ :
+ startTimer(tu_timer::get_ticks())
+{
+}
+
+void
+WallClockTimer::restart()
+{
+ startTimer = tu_timer::get_ticks();
+}
+
+uint32_t
+WallClockTimer::elapsed() const
+{
+ uint64_t currTime = tu_timer::get_ticks();
+
+ // be aware of time glitches
+ if ( currTime <= startTimer ) return 0;
+
+ return currTime-startTimer;
+
+}
+
+} // namespace gnash
Index: libbase/WallClockTimer.h
===================================================================
RCS file: libbase/WallClockTimer.h
diff -N libbase/WallClockTimer.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/WallClockTimer.h 25 Sep 2007 14:17:20 -0000 1.1
@@ -0,0 +1,55 @@
+// WallClockTimer.h: Wall clock timer, for Gnash.
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef WALLCLOCKTIMER_H
+#define WALLCLOCKTIMER_H 1
+
+#include "tu_config.h" // for DSOEXPORT
+
+#include <boost/cstdint.hpp>
+
+namespace gnash {
+
+/// General-purpose wall-clock timer.
+class WallClockTimer
+{
+
+public:
+
+ /// Construct a wall-clock timer.
+ WallClockTimer();
+
+ /// \brief
+ /// Return time elapsed in milliseconds since construction
+ /// or last call to ::restart()
+ DSOEXPORT uint32_t elapsed() const;
+
+ /// Restart the timer
+ DSOEXPORT void restart();
+
+private:
+
+ uint64_t startTimer;
+
+};
+
+} // namespace gnash
+
+
+#endif // WALLCLOCKTIMER_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/Makefile.am libbase/cur...,
Sandro Santilli <=