CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 08/01/15 10:26:40
Modified files: . : ChangeLog server : LoadVariablesThread.cpp LoadVariablesThread.h Log message: implement download canceling and proper destructor (cancels&joins). Fixes segfault reported in bug #21675 (comment #6). CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5397&r2=1.5398 http://cvs.savannah.gnu.org/viewcvs/gnash/server/LoadVariablesThread.cpp?cvsroot=gnash&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/gnash/server/LoadVariablesThread.h?cvsroot=gnash&r1=1.3&r2=1.4 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5397 retrieving revision 1.5398 diff -u -b -r1.5397 -r1.5398 --- ChangeLog 15 Jan 2008 09:35:10 -0000 1.5397 +++ ChangeLog 15 Jan 2008 10:26:40 -0000 1.5398 @@ -1,5 +1,11 @@ 2008-01-15 Sandro Santilli <[EMAIL PROTECTED]> + * server/LoadVariablesThread.{cpp,h}: implement download canceling + and proper destructor (cancels&joins). Fixes segfault reported + in bug #21675 (comment #6). + +2008-01-15 Sandro Santilli <[EMAIL PROTECTED]> + * testsuite/swfdec/PASSING: shift-{5,6,7}.swf succeed * server/vm/ASHandlers.cpp: fix ActionShift* opcodes. * testsuite/actionscript.all/ops.as: add tests for ActionShiftRight2 Index: server/LoadVariablesThread.cpp =================================================================== RCS file: /sources/gnash/gnash/server/LoadVariablesThread.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- server/LoadVariablesThread.cpp 11 Jan 2008 16:50:36 -0000 1.6 +++ server/LoadVariablesThread.cpp 15 Jan 2008 10:26:40 -0000 1.7 @@ -75,6 +75,12 @@ // eof, get out ! if ( _stream->get_eof() ) break; + + if ( cancelRequested() ) + { + log_debug("Cancelling LoadVariables download thread..."); + break; + } } if ( ! toparse.empty() ) @@ -99,7 +105,8 @@ LoadVariablesThread::LoadVariablesThread(const URL& url, const std::string& postdata) : _stream(StreamProvider::getDefaultInstance().getStream(url, postdata)), - _completed(false) + _completed(false), + _canceled(false) { if ( ! _stream.get() ) { @@ -110,7 +117,8 @@ LoadVariablesThread::LoadVariablesThread(const URL& url) : _stream(StreamProvider::getDefaultInstance().getStream(url)), - _completed(false) + _completed(false), + _canceled(false) { if ( ! _stream.get() ) { @@ -118,4 +126,29 @@ } } +void +LoadVariablesThread::cancel() +{ + boost::mutex::scoped_lock lock(_mutex); + _canceled = true; +} + +bool +LoadVariablesThread::cancelRequested() +{ + boost::mutex::scoped_lock lock(_mutex); + return _canceled; +} + +LoadVariablesThread::~LoadVariablesThread() +{ + if ( _thread.get() ) + { + cancel(); + _thread->join(); + _thread.reset(); + } +} + + } // namespace gnash Index: server/LoadVariablesThread.h =================================================================== RCS file: /sources/gnash/gnash/server/LoadVariablesThread.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- server/LoadVariablesThread.h 10 Oct 2007 17:49:45 -0000 1.3 +++ server/LoadVariablesThread.h 15 Jan 2008 10:26:40 -0000 1.4 @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: LoadVariablesThread.h,v 1.3 2007/10/10 17:49:45 strk Exp $ */ +/* $Id: LoadVariablesThread.h,v 1.4 2008/01/15 10:26:40 strk Exp $ */ #ifndef GNASH_LOADVARIABLESTHREAD_H #define GNASH_LOADVARIABLESTHREAD_H @@ -80,6 +80,9 @@ /// LoadVariablesThread(const URL& url, const std::string& postdata); + /// Destroy the LoadVariablesThread, joining the thread if spawned + ~LoadVariablesThread(); + /// Return the name,value map parsed out of the loaded stream ValuesMap& getValues() { @@ -94,6 +97,12 @@ _thread.reset( new boost::thread(boost::bind(LoadVariablesThread::execLoadingThread, this)) ); } + /// Cancel a download in progress + // + /// Locks _mutex + /// + void cancel(); + /// Return true if loading/parsing is in progress bool inProgress() { @@ -181,6 +190,12 @@ return _vals.size(); } + /// Check if download cancel was requested + // + /// Locks _mutex + /// + bool cancelRequested(); + size_t _bytesLoaded; size_t _bytesTotal; @@ -193,6 +208,8 @@ bool _completed; + bool _canceled; + boost::mutex _mutex; }; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit