Changeset 2648


Ignore:
Timestamp:
28/02/2010 19:51:26 (2 years ago)
Author:
chris
Message:

Workaround for problem with nanosleep() return values on OSX causing test
to hang.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/common/Test.cpp

    r2506 r2648  
    463463        while (nanosleep(&ts, &ts) == -1 && errno == EINTR) 
    464464        { 
    465                 BOX_TRACE("safe_sleep interrupted with " << 
    466                         ts.tv_sec << "." << ts.tv_nsec << 
    467                         " secs remaining, sleeping again"); 
    468                 /* sleep again */ 
     465                // FIME evil hack for OSX, where ts.tv_sec contains 
     466                // a negative number interpreted as unsigned 32-bit 
     467                // when nanosleep() returns later than expected. 
     468 
     469                int32_t secs = (int32_t) ts.tv_sec; 
     470                int64_t remain_ns = (secs * 1000000000) + ts.tv_nsec; 
     471 
     472                if (remain_ns < 0) 
     473                { 
     474                        BOX_WARNING("nanosleep interrupted " << 
     475                                ((float)(0 - remain_ns) / 1000000000) << 
     476                                " secs late"); 
     477                        return; 
     478                } 
     479 
     480                BOX_TRACE("nanosleep interrupted with " << 
     481                        (remain_ns / 1000000000) << " secs remaining, " 
     482                        "sleeping again"); 
    469483        } 
    470484#endif 
Note: See TracChangeset for help on using the changeset viewer.