]> git.sesse.net Git - vlc/commitdiff
SD: pull down cancellation safety on those SD with lame threads
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 28 Aug 2008 19:38:30 +0000 (22:38 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 28 Aug 2008 19:42:06 +0000 (22:42 +0300)
modules/services_discovery/hal.c
modules/services_discovery/podcast.c
modules/services_discovery/shout.c

index b45b5fdee0485db9e789c5b4fa601b05a91dddae..3d6c32e4283345ab3ac59f8255af878bb0e0ed87 100644 (file)
@@ -300,6 +300,7 @@ static void Run( services_discovery_t *p_sd )
     int i, i_devices;
     char **devices;
     services_discovery_sys_t    *p_sys  = p_sd->p_sys;
+    int canc = vlc_savecancel();
 
     /* parse existing devices first */
     if( ( devices = libhal_get_all_devices( p_sys->p_ctx, &i_devices, NULL ) ) )
@@ -310,12 +311,16 @@ static void Run( services_discovery_t *p_sd )
             libhal_free_string( devices[ i ] );
         }
     }
+
+    /* FIXME: Totally lame. There are DBus watch functions to do this properly.
+     * -- Courmisch, 28/08/2008 */
     while( vlc_object_alive (p_sd) )
     {
         /* look for events on the bus, blocking 1 second */
         dbus_connection_read_write_dispatch( p_sys->p_connection, 1000 );
         /* HAL 0.5.8.1 can use libhal_ctx_get_dbus_connection(p_sys->p_ctx) */
     }
+    vlc_restorecancel (canc);
 }
 
 void DeviceAdded( LibHalContext *p_ctx, const char *psz_udi )
index 2c4e8f2ef747f2e00fb7cdc6eff672cb1f3cca31..95d4ba6f68f36e059c4728848cbac884c999f97a 100644 (file)
@@ -159,9 +159,12 @@ static void Run( services_discovery_t *p_sd )
     var_Create( p_sd, "podcast-urls", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_AddCallback( p_sd, "podcast-urls", UrlsChange, p_sys );
 
-    while( vlc_object_alive (p_sd) )
+    for( ;; )
     {
-        int i;
+        /* FIXME: That's 2000 wake up per seconds too many. */
+        msleep( 500 );
+
+        int canc = vlc_savecancel (); /* <- FIXME: should not be needed */
         if( p_sys->b_update == true )
         {
             msg_Dbg( p_sd, "Update required" );
@@ -172,7 +175,7 @@ static void Run( services_discovery_t *p_sd )
             p_sys->b_update = false;
         }
 
-        for( i = 0; i < p_sd->p_sys->i_input; i++ )
+        for( int i = 0; i < p_sd->p_sys->i_input; i++ )
         {
             if( p_sd->p_sys->pp_input[i]->b_eof
                 || p_sd->p_sys->pp_input[i]->b_error )
@@ -184,7 +187,7 @@ static void Run( services_discovery_t *p_sd )
                 i--;
             }
         }
-        msleep( 500 );
+        vlc_restorecancel (canc);
     }
 }
 
index bab1f0204b8370572e9e95697daa8f13f792cf25..277cf72893b2d58cbd31ccb6089ca88654997f9b 100644 (file)
@@ -215,6 +215,7 @@ static void Run( services_discovery_t *p_sd )
 {
     enum type_e i_type = (enum type_e)p_sd->p_sys;
     int i, j;
+    int canc = vlc_savecancel();
     
     if( !p_items[i_type].p_children )
     {
@@ -238,6 +239,7 @@ static void Run( services_discovery_t *p_sd )
             vlc_gc_decref( p_input );
         }
     }
+    vlc_restorecancel(canc);
 }
 
 /*****************************************************************************