Revision 15001cb1 src/raft/ReplicaThread.cc

View differences:

src/raft/ReplicaThread.cc
65 65
// -----------------------------------------------------------------------------
66 66
// -----------------------------------------------------------------------------
67 67

  
68
static void set_timeout(struct timespec& timeout, time_t nsec )
69
{
70
    clock_gettime(CLOCK_REALTIME, &timeout);
71

  
72
    timeout.tv_nsec += nsec;
73

  
74
    while ( timeout.tv_nsec >= 1000000000 )
75
    {
76
        timeout.tv_sec  += 1;
77
        timeout.tv_nsec -= 1000000000;
78
    }
79
}
80

  
68 81
void ReplicaThread::do_replication()
69 82
{
70 83
    int rc;
......
79 92
        {
80 93
            struct timespec timeout;
81 94

  
82
            timeout.tv_sec  = time(NULL);
83
            timeout.tv_nsec = retry_timeout;
95
            set_timeout(timeout, retry_timeout);
84 96

  
85 97
            if ( pthread_cond_timedwait(&cond, &mutex, &timeout) == ETIMEDOUT )
86 98
            {

Also available in: Unified diff