]> git.sesse.net Git - vlc/commitdiff
addons: Retrieve: narrow lock
authorFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 20 Feb 2014 21:01:42 +0000 (22:01 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 20 Feb 2014 21:02:28 +0000 (22:02 +0100)
allows UI updates while downloading

modules/misc/addons/fsstorage.c
modules/misc/addons/vorepository.c

index 6db9077d11180a2861f1ad05e7247115266f2bc3..6bdcacb9f922e2bd2cca224c5ed5a5919ff31692 100644 (file)
@@ -498,14 +498,15 @@ static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry )
                                       p_entry->psz_source_module, true );
     if( p_module )
     {
-        vlc_mutex_lock( &p_entry->lock );
         if ( p_finder->pf_retrieve( p_finder, p_entry ) == VLC_SUCCESS )
         {
             /* Do things while retrieved data is here */
+            vlc_mutex_lock( &p_entry->lock );
             i_ret = InstallAllFiles( p_storage, p_entry );
+            vlc_mutex_unlock( &p_entry->lock );
             /* !Do things while retrieved data is here */
         }
-        vlc_mutex_unlock( &p_entry->lock );
+
         module_unneed( p_finder, p_module );
     }
 
index 93a70658cfc61ac837d57137bcc4ede890081bf6..4ca010e4d6f1c87e95a7874cb1a418835c120dd4 100644 (file)
@@ -347,27 +347,39 @@ static int Find( addons_finder_t *p_finder )
 
 static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
 {
+    vlc_mutex_lock( &p_entry->lock );
     if ( !p_entry->psz_archive_uri )
+    {
+        vlc_mutex_unlock( &p_entry->lock );
         return VLC_EGENERIC;
+    }
+    char *psz_archive_uri = strdup( p_entry->psz_archive_uri );
+    vlc_mutex_unlock( &p_entry->lock );
+    if ( !psz_archive_uri )
+        return VLC_ENOMEM;
 
     /* get archive and parse manifest */
     stream_t *p_stream;
 
-    if ( p_entry->psz_archive_uri[0] == '/' )
+    if ( psz_archive_uri[0] == '/' )
     {
         /* Relative path */
         char *psz_uri;
-        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", p_entry->psz_archive_uri ) )
+        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", psz_archive_uri ) )
+        {
+            free( psz_archive_uri );
             return VLC_ENOMEM;
+        }
         p_stream = stream_UrlNew( p_finder, psz_uri );
         free( psz_uri );
     }
     else
     {
-        p_stream = stream_UrlNew( p_finder, p_entry->psz_archive_uri );
+        p_stream = stream_UrlNew( p_finder, psz_archive_uri );
     }
 
-    msg_Dbg( p_finder, "downloading archive %s", p_entry->psz_archive_uri );
+    msg_Dbg( p_finder, "downloading archive %s", psz_archive_uri );
+    free ( psz_archive_uri );
     if ( !p_stream ) return VLC_EGENERIC;
 
     /* In case of pf_ reuse */
@@ -430,8 +442,10 @@ static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
         return VLC_EGENERIC;
     }
 
+    vlc_mutex_lock( &p_entry->lock );
     int i_ret = ( ParseManifest( p_finder, p_entry, psz_tempfileuri, p_stream ) > 0 )
                     ? VLC_SUCCESS : VLC_EGENERIC;
+    vlc_mutex_unlock( &p_entry->lock );
     free( psz_tempfileuri );
     stream_Delete( p_stream );