View Issue Details

IDProjectCategoryView StatusLast Update
00002391003.1(2008)/Issue 7System Interfacespublic2013-04-16 13:06
Reportergeoffclare Assigned Toajosey  
PrioritynormalSeverityCommentTypeError
Status ClosedResolutionAccepted 
NameGeoff Clare
OrganizationThe Open Group
User Reference
Sectionpthread_cond_timedwait
Page Number1590
Line Number51186
Interp Status---
Final Accepted Text
Summary0000239: minor correction to pthread_cond_timedwait() example code
DescriptionAt the end of the rationale on the pthread_cond_timedwait() page there
is some example code showing the use of pthread_cond_timedwait(),
which includes the following:

    rc = 0;
    while (! mypredicate(&t) && rc == 0)
        rc = pthread_cond_timedwait(&t.cond, &t.mn, &ts);
    t.waiters--;
    if (rc == 0) setmystate(&t);


This follows the advice stated near the beginning of the rationale:

    "The application needs to recheck the predicate on any return"

in that the code correctly checks the predicate in the while condition.
However, there is a possible code path where rc is set to ETIMEDOUT but
then the predicate is true in the while condition, in which case the
code after the loop fails to act on the predicate being true.
Desired ActionChange

    if (rc == 0) setmystate(&t);

to

    if (rc == 0 || mypredicate(&t))
        setmystate(&t);
Tagstc1-2008

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2010-04-13 14:43 geoffclare New Issue
2010-04-13 14:43 geoffclare Status New => Under Review
2010-04-13 14:43 geoffclare Assigned To => ajosey
2010-04-13 14:43 geoffclare Name => Geoff Clare
2010-04-13 14:43 geoffclare Organization => The Open Group
2010-04-13 14:43 geoffclare Section => pthread_cond_timedwait
2010-04-13 14:43 geoffclare Page Number => 1590
2010-04-13 14:43 geoffclare Line Number => 51186
2010-04-13 14:43 geoffclare Interp Status => ---
2010-04-22 15:11 ajosey Status Under Review => Resolved
2010-04-22 15:11 ajosey Resolution Open => Accepted
2010-08-27 11:24 ajosey Tag Attached: tc1-2008
2013-04-16 13:06 ajosey Status Resolved => Closed