[vlc-devel] commit: vlc_thread_set_priority: don't mess up the thread_id ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Jul 24 21:03:55 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Jul 24 22:04:53 2008 +0300| [418410c4cf946f467bee5e88361b2a071aeffa9b]

vlc_thread_set_priority: don't mess up the thread_id

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

 src/misc/threads.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index 8b503b7..2405bdb 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -622,6 +622,17 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
 {
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    if( !p_priv->b_thread )
+    {
+#ifndef __APPLE__
+        msg_Err( p_this, "couldn't set priority of non-existent thread" );
+        return ESRCH;
+#else
+# warning FIXME: this is wrong
+        p_priv->b_thread = pthread_self();
+#endif
+    }
+
 #if defined( LIBVLC_USE_PTHREAD )
 # ifndef __APPLE__
     if( config_GetInt( p_this, "rt-priority" ) > 0 )
@@ -643,10 +654,8 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
             param.sched_priority = i_priority;
             i_policy = SCHED_RR;
         }
-        if( !p_priv->thread_id )
-            p_priv->thread_id = pthread_self();
         if( (i_error = pthread_setschedparam( p_priv->thread_id,
-                                               i_policy, &param )) )
+                                              i_policy, &param )) )
         {
             errno = i_error;
             msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
@@ -658,8 +667,6 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
 #elif defined( WIN32 ) || defined( UNDER_CE )
     VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
 
-    if( !p_priv->thread_id )
-        p_priv->thread_id = GetCurrentThread();
     if( !SetThreadPriority(p_priv->thread_id, i_priority) )
     {
         msg_Warn( p_this, "couldn't set a faster priority" );




More information about the vlc-devel mailing list