Bump the pdu timeout by 1000ms when we do not have clock_gettime()
If we fallback to time() we have 1 second granularity of our timestamps. Thus we need to bump the pdu timestamp we set by this granularity or the timeout will trigger too early. For a 1s timeout, this means that we now will trigger the timeout between 1.0 - 2.0 seconds instead of the previous 0.0 - 1.0 seconds. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>libnfs-4.0.0-vitalif
parent
fb1efbe51c
commit
fc677be6a3
11
lib/pdu.c
11
lib/pdu.c
|
@ -1,3 +1,4 @@
|
|||
/* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
|
@ -224,6 +225,16 @@ int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu)
|
|||
|
||||
if (rpc->timeout > 0) {
|
||||
pdu->timeout = rpc_current_time() + rpc->timeout;
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
/* If we do not have GETTIME we fallback to time() which
|
||||
* has 1s granularity for its timestamps.
|
||||
* We thus need to bump the timeout by 1000ms
|
||||
* so that the PDU will timeout within 1.0 - 2.0 seconds.
|
||||
* Otherwise setting a 1s timeout would trigger within
|
||||
* 0.001 - 1.0s.
|
||||
*/
|
||||
pdu->timeout += 1000;
|
||||
#endif
|
||||
} else {
|
||||
pdu->timeout = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue