gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cpp


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cpp
Date: Thu, 16 Nov 2006 21:48:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/16 21:48:30

Modified files:
        .              : ChangeLog 
        server/parser  : movie_def_impl.cpp 

Log message:
        get_exported_resource() made more thread safe (well, not completely 
yet, as a movie importing itself will likely hang the player)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1634&r2=1.1635
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.36&r2=1.37

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1634
retrieving revision 1.1635
diff -u -b -r1.1634 -r1.1635
--- ChangeLog   16 Nov 2006 20:13:32 -0000      1.1634
+++ ChangeLog   16 Nov 2006 21:48:30 -0000      1.1635
@@ -1,9 +1,6 @@
 2006-11-16 Sandro Santilli <address@hidden>
 
        * server/parser/movie_def_impl.{cpp,h}:
-         get_exported_resource() and export_resource() moved
-         from header to implementation file, for (near) future
-         threads protection (notes added for it);
          get_exported_resource() changed to take incremental
          loading into account, by making sure the whole
          stream has been parsed before returning a failure

Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/parser/movie_def_impl.cpp    16 Nov 2006 20:13:32 -0000      1.36
+++ server/parser/movie_def_impl.cpp    16 Nov 2006 21:48:30 -0000      1.37
@@ -961,41 +961,64 @@
 {
        boost::intrusive_ptr<resource> res;
 
-       //
 #ifdef DEBUG_EXPORTS
        log_msg("get_exported_resource called, frame count=%u", m_frame_count);
 #endif
 
+       // FIXME: a movie importing from itself will likely
+       //        end up in a dead lock
+
+       // this is a simple utility so we don't forget
+       // to release our locks...
+       struct scoped_loader_locker {
+               MovieLoader& _loader;
+               scoped_loader_locker(MovieLoader& loader)
+                       :
+                       _loader(loader)
+               {
+                       _loader.lock();
+               }
+               ~scoped_loader_locker()
+               {
+                       _loader.unlock();
+               }
+       };
+
+
        // Keep trying until either we found the export or
        // the stream is over.
        bool found=false;
-       // FIXME: m_exports is not protected by a mutex
-       //        this method is usually called by the loader
-       //        thread of the *loader* movie, and the loader
-       //        thread of *this* movie, updating 'm_exports'
-       //        will be in another thread....
-       //        
-       while ( ! (found = m_exports.get(symbol, &res)) )
-       {
-               // FIXME: get_loading_frame() is not protected by a mutex.
-               //        this method is usually called by the loader
-               //        thread of the *loader* movie, and the loader
-               //        thread of *this* movie, updating 'loading_frame'
-               //        will be in another thread....
+       for (;;)
+       {
+               {
+               // lock the loader
+               scoped_loader_locker locker(_loader);
+       
+               if ( m_exports.get(symbol, &res) )
+               {
+                       found=true;
+                       break;
+               }
+
+               // be aware of not getting the lock twice
+               // (can happen if get_loading_frame() becomes
+               //  a locking function)
                if ( get_loading_frame() >= m_frame_count ) break;
 
 #ifdef DEBUG_EXPORTS
                log_msg("We haven't finished loading (loading frame %u), "
-                       "but m_exports.get returned no entries, "
+                       "and m_exports.get returned no entries, "
                        "sleeping a bit and trying again",
                        get_loading_frame());
 #endif
+               } // scoped_loader_locker goes out of scope here and gets
+                 // released...
+
                usleep(100); // take a breath
        }
 
        if ( ! found )
        {
-               found =  m_exports.get(symbol, &res);
                log_msg("At end of stream, still no '%s' symbol found "
                        "in m_exports (%u entries in it, follow)",
                        symbol.c_str(), m_exports.size());




reply via email to

[Prev in Thread] Current Thread [Next in Thread]