CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/12/21 00:55:24
Modified files: . : ChangeLog libbase : LoadThread.h server/asobj : xml.cpp Log message: Don't rely on LoadThread::getBytesTotal, and document why you shouldn't. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5235&r2=1.5236 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.h?cvsroot=gnash&r1=1.17&r2=1.18 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.59&r2=1.60 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5235 retrieving revision 1.5236 diff -u -b -r1.5235 -r1.5236 --- ChangeLog 21 Dec 2007 00:39:18 -0000 1.5235 +++ ChangeLog 21 Dec 2007 00:55:23 -0000 1.5236 @@ -1,5 +1,14 @@ 2007-12-20 Sandro Santilli <[EMAIL PROTECTED]> + * libbase/LoadThread.h: add warnings about getBytesTotal() use + and a call for better documenting current behaviour. + * server/asobj/xml.cpp (checkLoad): drop the assertion completely + and substitute with a check & log_debug. The assertion was + about LoadThread::getBytesTotal() returning a number which would + be fully available for a singleLoadThread::read() to consume... + +2007-12-20 Sandro Santilli <[EMAIL PROTECTED]> + * server/asobj/xml.cpp (checkLoad): fixed typo in an assertion. 2007-12-20 Sandro Santilli <[EMAIL PROTECTED]> Index: libbase/LoadThread.h =================================================================== RCS file: /sources/gnash/gnash/libbase/LoadThread.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -b -r1.17 -r1.18 --- libbase/LoadThread.h 20 Dec 2007 22:31:31 -0000 1.17 +++ libbase/LoadThread.h 21 Dec 2007 00:55:24 -0000 1.18 @@ -90,6 +90,19 @@ long getBytesLoaded(); /// Returns the total size of the file + // + /// NOTE: + /// You can't rely on returned + /// value to know the exact size, as network + /// server (http/ftp) might return misleading + /// information about the size of a resource. + /// + /// TODO: + /// Document current implementation when it + /// comes to read past that advertised size + /// or short of it... Reading the code is + /// discouraging for me (--strk) + /// long getBytesTotal(); /// Check if the load is completed Index: server/asobj/xml.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -u -b -r1.59 -r1.60 --- server/asobj/xml.cpp 21 Dec 2007 00:39:18 -0000 1.59 +++ server/asobj/xml.cpp 21 Dec 2007 00:55:24 -0000 1.60 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: xml.cpp,v 1.59 2007/12/21 00:39:18 strk Exp $ */ +/* $Id: xml.cpp,v 1.60 2007/12/21 00:55:24 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -471,8 +471,15 @@ size_t xmlsize = lt->getBytesTotal(); boost::scoped_array<char> buf(new char[xmlsize+1]); size_t actuallyRead = lt->read(buf.get(), xmlsize); - assert(actuallyRead == xmlsize); - buf[xmlsize] = '\0'; + if ( actuallyRead != xmlsize ) + { + // This would be either a bug of LoadThread or an expected + // possibility which lacks documentation (thus a bug in documentation) + // + log_debug("LoadThread::getBytesTotal() returned %d but ::read(%d) returned %d", + xmlsize, actuallyRead); + } + buf[actuallyRead] = '\0'; as_value dataVal(buf.get()); // memory copy here (optimize?) it = _loadThreads.erase(it); _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit