[vlc-commits] lua: Mandate KillExtension to be called with command_lock locked

Hugo Beauzée-Luyssen git at videolan.org
Thu Mar 30 13:56:35 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar 30 11:25:36 2017 +0200| [bd8d39bc69077484ba868cf938b09a28a512c132] | committer: Hugo Beauzée-Luyssen

lua: Mandate KillExtension to be called with command_lock locked

Otherwise the caller always unlocks the lock, only to have it acquire
again by KillExtension.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bd8d39bc69077484ba868cf938b09a28a512c132
---

 modules/lua/extension.c        | 6 +++---
 modules/lua/extension_thread.c | 6 ++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 36bfcdb..801134c 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -1166,8 +1166,8 @@ static void WatchTimerCallback( void *data )
                 vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
                 p_ext->p_sys->p_progress_id = NULL;
             }
-            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
             KillExtension( p_mgr, p_ext );
+            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
             return;
         }
 
@@ -1182,8 +1182,8 @@ static void WatchTimerCallback( void *data )
                                          p_ext->psz_title );
         if( p_ext->p_sys->p_progress_id == NULL )
         {
-            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
             KillExtension( p_mgr, p_ext );
+            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
             return;
         }
         vlc_timer_schedule( p_ext->p_sys->timer, false, 100000, 0 );
@@ -1194,8 +1194,8 @@ static void WatchTimerCallback( void *data )
         {
             vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
             p_ext->p_sys->p_progress_id = NULL;
-            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
             KillExtension( p_mgr, p_ext );
+            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
             return;
         }
         vlc_timer_schedule( p_ext->p_sys->timer, false, 100000, 0 );
diff --git a/modules/lua/extension_thread.c b/modules/lua/extension_thread.c
index 03c3d64..7db1c0b 100644
--- a/modules/lua/extension_thread.c
+++ b/modules/lua/extension_thread.c
@@ -152,8 +152,8 @@ int Deactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
         // Extension is stuck, kill it now
         vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
         p_ext->p_sys->p_progress_id = NULL;
-        vlc_mutex_unlock( &p_ext->p_sys->command_lock );
         KillExtension( p_mgr, p_ext );
+        vlc_mutex_unlock( &p_ext->p_sys->command_lock );
         return VLC_SUCCESS;
     }
 
@@ -163,16 +163,14 @@ int Deactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
     return b_success ? VLC_SUCCESS : VLC_ENOMEM;
 }
 
+/* MUST be called with command_lock held */
 void KillExtension( extensions_manager_t *p_mgr, extension_t *p_ext )
 {
     msg_Dbg( p_mgr, "Killing extension now" );
     vlclua_fd_interrupt( &p_ext->p_sys->dtable );
-
-    vlc_mutex_lock( &p_ext->p_sys->command_lock );
     p_ext->p_sys->b_activated = false;
     p_ext->p_sys->b_exiting = true;
     vlc_cond_signal( &p_ext->p_sys->wait );
-    vlc_mutex_unlock( &p_ext->p_sys->command_lock );
 }
 
 /** Push a UI command */



More information about the vlc-commits mailing list