From nobody  Tue Sep 16 06:25:35 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id GAA23560;
          Tue, 16 Sep 1997 06:25:35 -0700 (PDT)
Message-Id: <199709161325.GAA23560@hub.freebsd.org>
Date: Tue, 16 Sep 1997 06:25:35 -0700 (PDT)
From: thz@tuebingen.netsurf.de
To: freebsd-gnats-submit@freebsd.org
Subject: pthread_cond_wait() doesn't wait for pthread_cond_signal()
X-Send-Pr-Version: www-1.0

>Number:         4554
>Category:       bin
>Synopsis:       pthread_cond_wait() doesn't wait for pthread_cond_signal()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 16 06:30:00 PDT 1997
>Closed-Date:    Mon Nov 24 18:39:45 PST 1997
>Last-Modified:  Mon Nov 24 18:41:12 PST 1997
>Originator:     Thomas Zenker
>Release:        2.2.1/2.2.2
>Organization:
Lennartz electronic
>Environment:
>Description:
pthread_cond_wait returns immediately without
waiting for pthread_cond_signal by another thread.

the reason is that in pthread_cond_wait the wakeup_time.tv_sec
is not explicitely set to "wait forever" (-1).
Debugging shows: wakeup_time.tv_sec is allways implicitely 
set to "wakeup immediately" (0).

>How-To-Repeat:
Calling pthread_cond_wait() never stops the current thread.

>Fix:
Set wakeup_time.tv_sec explicitely to wait forever in the function
pthread_cond_wait() in file "uthread_cond.c".

*** /vol/cdrom/usr/src/lib/libc_r/uthread/uthread_cond.c        Fri Sep 20 08:3:50 1996
--- ./uthread_cond.c    Tue Sep 16 12:54:56 1997
***************
*** 149,154 ****
--- 149,158 ----
                switch ((*cond)->c_type) {
                        /* Fast condition variable: */
                case COND_TYPE_FAST:
+                       /* Set the wakeup time: wait forever */
+                       _thread_run->wakeup_time.tv_sec = -1;
+                       _thread_run->wakeup_time.tv_nsec = -1;
+ 
                        /* Queue the running thread for the condition variable:*/
                                _thread_queue_enq(&(*cond)->c_queue, _thread_run
);
  

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: alex 
State-Changed-When: Mon Nov 24 18:39:45 PST 1997 
State-Changed-Why:  
Fixed in rev 1.3.2.1 by julian. 
>Unformatted:
