CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 08/01/10 10:57:23
Modified files: . : ChangeLog server/parser : movie_def_impl.cpp movie_def_impl.h Log message: make exported resource container access thread-safe, cleanup debug messages in get_export_resource(). CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5364&r2=1.5365 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.96&r2=1.97 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.66&r2=1.67 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5364 retrieving revision 1.5365 diff -u -b -r1.5364 -r1.5365 --- ChangeLog 10 Jan 2008 10:26:51 -0000 1.5364 +++ ChangeLog 10 Jan 2008 10:57:22 -0000 1.5365 @@ -1,5 +1,8 @@ 2008-01-10 Sandro Santilli <[EMAIL PROTECTED]> + * server/parser/movie_def_impl.{cpp,h}: make exported resource + container access thread-safe, cleanup debug messages + in get_export_resource(). * server/swf/tag_loaders.cpp (sound_stream_head_loader): print unimplemented messages for unsupported tag records. * server/asClass.h, server/asobj/ClassHierarchy.h: comment out Index: server/parser/movie_def_impl.cpp =================================================================== RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -u -b -r1.96 -r1.97 --- server/parser/movie_def_impl.cpp 2 Jan 2008 14:13:59 -0000 1.96 +++ server/parser/movie_def_impl.cpp 10 Jan 2008 10:57:23 -0000 1.97 @@ -889,10 +889,11 @@ void movie_def_impl::export_resource(const std::string& symbol, resource* res) { - // FIXME: m_exports access should be protected by a mutex + // _exportedResources access should be protected by a mutex + boost::mutex::scoped_lock lock(_exportedResourcesMutex); // SWF sometimes exports the same thing more than once! - m_exports[symbol] = res; + _exportedResources[symbol] = res; } @@ -902,7 +903,7 @@ boost::intrusive_ptr<resource> res; #ifdef DEBUG_EXPORTS - log_msg(_("get_exported_resource called, frame count=%u"), m_frame_count); + log_debug(_("get_exported_resource called, frame count=%u"), m_frame_count); #endif // Don't call get_exported_resource() from this movie loader @@ -930,17 +931,22 @@ size_t loading_frame = (size_t)-1; // used to keep track of advancements for (;;) { - // FIXME: make m_exports access thread-safe - ExportMap::iterator it = m_exports.find(symbol); - if ( it != m_exports.end() ) return it->second; + // _exportedResources access is thread-safe + { + boost::mutex::scoped_lock lock(_exportedResourcesMutex); + ExportMap::iterator it = _exportedResources.find(symbol); + if ( it != _exportedResources.end() ) return it->second; + } size_t new_loading_frame = get_loading_frame(); if ( new_loading_frame != loading_frame ) { - log_msg(_("frame load advancement (from " +#ifdef DEBUG_EXPORTS + log_debug(_("looking for exported resource: frame load advancement (from " SIZET_FMT " to " SIZET_FMT ")"), loading_frame, new_loading_frame); +#endif loading_frame = new_loading_frame; timeout = def_timeout; } @@ -962,22 +968,32 @@ return res; } - log_error(_("no frame progress at iteration %lu"), timeout); +#ifdef DEBUG_EXPORTS + log_debug(_("No frame progress at iteration %lu of get_exported_resource(%s)"), + timeout, symbol.c_str()); +#endif continue; // not worth checking } if ( loading_frame >= m_frame_count ) { - log_error(_("At end of stream, still no '%s' symbol found " - "in m_exports (" SIZET_FMT " entries in it, " - "follow)"), symbol.c_str(), m_exports.size()); +#ifdef DEBUG_EXPORTS + boost::mutex::scoped_lock lock(_exportedResourcesMutex); + log_debug(_("At end of stream, still no '%s' symbol found " + "in _exportedResources (" SIZET_FMT " entries in it, " + "follow)"), symbol.c_str(), _exportedResources.size()); + for (ExportMap::const_iterator it=_exportedResources.begin(); it!=_exportedResources.end(); ++it) + { + log_debug(" symbol %s (%s)", it->first.c_str(), typeName(*(it->second)).c_str()); + } +#endif return res; } #ifdef DEBUG_EXPORTS - log_msg(_("We haven't finished loading (loading frame %u), " - "and m_exports.get returned no entries, " + log_debug(_("We haven't finished loading (loading frame %u), " + "and _exportedResources.get returned no entries, " "sleeping a bit and trying again"), get_loading_frame()); #endif @@ -1031,10 +1047,14 @@ i->second->setReachable(); } - for (ExportMap::const_iterator i=m_exports.begin(), e=m_exports.end(); i!=e; ++i) + // TODO: turn this into a markExportedResources() + { + boost::mutex::scoped_lock lock(_exportedResourcesMutex); + for (ExportMap::const_iterator i=_exportedResources.begin(), e=_exportedResources.end(); i!=e; ++i) { i->second->setReachable(); } + } for (ImportVect::const_iterator i=m_import_source_movies.begin(), e=m_import_source_movies.end(); i!=e; ++i) { Index: server/parser/movie_def_impl.h =================================================================== RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v retrieving revision 1.66 retrieving revision 1.67 diff -u -b -r1.66 -r1.67 --- server/parser/movie_def_impl.h 2 Jan 2008 14:13:59 -0000 1.66 +++ server/parser/movie_def_impl.h 10 Jan 2008 10:57:23 -0000 1.67 @@ -225,7 +225,10 @@ mutable boost::mutex _namedFramesMutex; typedef std::map<std::string, boost::intrusive_ptr<resource>, StringNoCaseLessThen > ExportMap; - ExportMap m_exports; + ExportMap _exportedResources; + + // Mutex protecting access to _exportedResources + mutable boost::mutex _exportedResourcesMutex; /// Items we import. std::vector<import_info> m_imports; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit