<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src</tt></b></td></tr>
<tr><td><tt><a href="#file1">tqueue.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+8</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-2</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">0b947d924029 -> 32b2a340f8b3</td></tr>
</table>
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Fix silly errors in tqueue implementation
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>tqueue.c</b></big> <small id="info" style="color: #888888;" >0b947d924029 -> 32b2a340f8b3</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/tqueue.c
+++ lxdream/src/tqueue.c
@@ -41,7 +41,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 /************** Producer thread **************/
 #define TQUEUE_EMPTY() (tqueue.head == tqueue.tail)
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-#define TQUEUE_FULL() ((tqueue.head == tqueue.tail+1) || (tqueue.head == 0 && tqueue.tail == <span id="removedchars" style="background-color:#ff9999;font-weight:bolder;" >TQUEUE_LENGTH</span>))
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#define TQUEUE_FULL() ((tqueue.head == tqueue.tail+1) || (tqueue.head == 0 && tqueue.tail == <span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >(TQUEUE_LENGTH-1)</span>))
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 static void tqueue_enqueue( tqueue_callback callback, void *data, gboolean sync )
 {
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -50,6 +50,8 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     tqueue.tqueue[tqueue.tail].data = data;
     tqueue.tqueue[tqueue.tail].synchronous = sync;
     tqueue.tail++;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    if( tqueue.tail == TQUEUE_LENGTH )
+        tqueue.tail = 0;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
 
 /**
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -73,6 +75,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  */
 int tqueue_send_message( tqueue_callback callback, void *data )
 {
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    int result;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     pthread_mutex_lock(&tqueue.mutex);
     if( TQUEUE_FULL() ) {
         /* Wait for the queue to clear */
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -81,8 +84,9 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     tqueue_enqueue( callback, data, TRUE );
     pthread_cond_signal(&tqueue.consumer_wait);
     pthread_cond_wait(&tqueue.producer_sync_wait, &tqueue.mutex);
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    re<span id="removedchars" style="background-color:#ff9999;font-weight:bolder;" >turn</span> tqueue.last_result;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    re<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >sult =</span> tqueue.last_result;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     pthread_mutex_unlock(&tqueue.mutex);
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    return result;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
 
 /************** Consumer thread **************/
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -95,6 +99,8 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         void *data = tqueue.tqueue[tqueue.head].data;
         gboolean sync = tqueue.tqueue[tqueue.head].synchronous;
         tqueue.head++;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        if( tqueue.head == TQUEUE_LENGTH )
+            tqueue.head = 0;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
         if( wasFull ) {
             pthread_cond_signal( &tqueue.producer_full_wait );
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>