c++ - pthread_cond_timedwait returns error 138 -


i can't find information on google, post here hoping can help...

my problem windows pthread function pthread_cond_timedwait(). when indicated time elapsed, function should return value etimedout. instead in code, conditional variable not signaled, returns value 138 , earlier expected timeout, immediately.

so questions are: error 138? , why timeout not elapsed? code use thread is:

int retcode = 0; timeb tb; ftime(&tb); struct timespec timeout; timeout.tv_sec = tb.time + 8; timeout.tv_nsec = tb.millitm * 1000 * 1000;  pthread_mutex_lock(&mutex_); retcode = pthread_cond_timedwait(&cond_, &mutex_, &timeout); pthread_mutex_unlock(&mutex_); if (retcode == etimedout)   {   addlog("timed-out. sending request...", log_debug);   } else // happened   {   std::stringstream ss;   ss << "thread interrupted (error " << retcode << ")";   addlog(ss.str().c_str(), log_debug);   } 

is there wrong absolute timeout computation?

only thread , calling thread present. calling 1 joins created 1 after creation , correctly waits until finishes. conditional variable cond_ never signaled, if try it, pthread_cond_timedwait() returns value 0 expected. if not shown here, both cond_ , mutex_ correctly initialised (if dont't it, einval error).

also following pthread code can't find error. can find return errno produce it, don't know meaning of 138.

if can help, using visual studio 2003 pthreads win32 v2.9.1.

thanks,

rg

maybe answer helpful someone.

i encountered same issue. pthread_cond_timedwait returns error 138 rummaged source code of pthread_win32 didn't find similar error code 138. downloaded source code of pthread, built visual studio 2008 and... work nice! :(

cause of such behaviour precompilled dll built msvc100, build app msvc90. etimedout in msvc100 138, in msvc90 10060.

thats all! windows, bro!


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -