do unlock thread before send signal
[enigma2.git] / lib / gdi / grc.cpp
index e4e4a8615c5149933d063b954be6fb76225a8412..de6761e810d4f0f335a4f338c95489c6e9339e53 100644 (file)
@@ -63,8 +63,7 @@ void gRC::submit(const gOpcode &o)
 #ifndef SYNC_PAINT
                pthread_mutex_lock(&mutex);
 #endif
 #ifndef SYNC_PAINT
                pthread_mutex_lock(&mutex);
 #endif
-               int tmp=wp;
-               tmp+=1;
+               int tmp=wp+1;
                if ( tmp == MAXSIZE )
                        tmp=0;
                if ( tmp == rp )
                if ( tmp == MAXSIZE )
                        tmp=0;
                if ( tmp == rp )
@@ -85,10 +84,10 @@ void gRC::submit(const gOpcode &o)
                queue[wp++]=o;
                if ( wp == MAXSIZE )
                        wp = 0;
                queue[wp++]=o;
                if ( wp == MAXSIZE )
                        wp = 0;
+               pthread_mutex_unlock(&mutex);
                if (o.opcode==gOpcode::flush||o.opcode==gOpcode::shutdown||o.opcode==gOpcode::notify)
 #ifndef SYNC_PAINT
                        pthread_cond_signal(&cond);  // wakeup gdi thread
                if (o.opcode==gOpcode::flush||o.opcode==gOpcode::shutdown||o.opcode==gOpcode::notify)
 #ifndef SYNC_PAINT
                        pthread_cond_signal(&cond);  // wakeup gdi thread
-               pthread_mutex_unlock(&mutex);
 #else
                        thread(); // paint
 #endif
 #else
                        thread(); // paint
 #endif
@@ -109,8 +108,7 @@ void *gRC::thread()
                pthread_mutex_lock(&mutex);
                if ( rp != wp )
                {
                pthread_mutex_lock(&mutex);
                if ( rp != wp )
                {
-                       gOpcode o(queue[rp]);
-                       rp++;
+                       gOpcode o(queue[rp++]);
                        if ( rp == MAXSIZE )
                                rp=0;
                        pthread_mutex_unlock(&mutex);
                        if ( rp == MAXSIZE )
                                rp=0;
                        pthread_mutex_unlock(&mutex);
@@ -131,7 +129,6 @@ void *gRC::thread()
 #ifndef SYNC_PAINT
                        pthread_cond_wait(&cond, &mutex);
 #endif
 #ifndef SYNC_PAINT
                        pthread_cond_wait(&cond, &mutex);
 #endif
-                       pthread_mutex_unlock(&mutex);
                }
        }
 #ifndef SYNC_PAINT
                }
        }
 #ifndef SYNC_PAINT