I have a try to apport-bug, but it is not working on my ubunto
here is the full test code 


#include <stdio.h>
#include <errno.h>
#include <pthread.h>
#include <sys/time.h>
#include <syslog.h>

pthread_mutex_t  mut  = PTHREAD_MUTEX_INITIALIZER; 
pthread_cond_t   cond = PTHREAD_COND_INITIALIZER;

int sync_wait(int timeout)
{
    struct timeval nwtm;
    struct timespec sync_timer;
    int retcode = 0;

    pthread_mutex_lock(&mut);
    gettimeofday(&nwtm, NULL);
    sync_timer.tv_sec = nwtm.tv_sec + timeout;
    sync_timer.tv_nsec = nwtm.tv_usec * 1000;
    retcode = pthread_cond_timedwait(&cond, &mut, &sync_timer);  
//在ubuntu10.10下睡眠唤醒后能继续执行,但在ubuntu11.04下不行
    pthread_mutex_unlock(&mut);

    return retcode;    
}

int sync_notify()
{
    int retcode;
    pthread_mutex_lock(&mut);
    retcode = pthread_cond_signal(&cond);
    pthread_mutex_unlock(&mut);
    return retcode;
}

int main(int argc, char *argv[])
{
    int icount = 0;
    sync_notify();
    
    while (1)
    {
        if (ETIMEDOUT == sync_wait(50))
        {
            syslog(LOG_ERR, "sync_wait is timeout.\n");
        }

        icount++;
        if (10 < icount)
        {
            break;
        }
    }

    return 1;
}

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/806844

Title:
  pthread_cond_timedwait hang when hibernate and wake up

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+bug/806844/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to