summaryrefslogtreecommitdiff
path: root/lib/handshake.c
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2018-12-04 17:15:02 +0100
committerTim Rühsen <tim.ruehsen@gmx.de>2018-12-06 16:13:00 +0100
commit3507f23cec212506da3c6836dbb159df4b41439f (patch)
treeff2f02ed31c2473c6fc795864ba98d758cce5c49 /lib/handshake.c
parent493723ee38cd817a60f25bb0bea505c80b22407c (diff)
downloadgnutls-3507f23cec212506da3c6836dbb159df4b41439f.tar.gz
Fix gnutls_handshake_set_timeout() for values < 1000tmp-fix-timeout
handshake-timeout.c now tests for <1000ms timeout and for >=1000ms timeout. The test duration decreased from 45s to 1.2s. Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
Diffstat (limited to 'lib/handshake.c')
-rw-r--r--lib/handshake.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/handshake.c b/lib/handshake.c
index 5080756c28..d83a51c9bb 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -2737,6 +2737,10 @@ int gnutls_handshake(gnutls_session_t session)
}
if (STATE == STATE0) {
+ unsigned int tmo_ms;
+ struct timespec *end;
+ struct timespec *start;
+
/* first call */
if (session->internals.priorities == NULL ||
session->internals.priorities->cs.size == 0)
@@ -2752,10 +2756,17 @@ int gnutls_handshake(gnutls_session_t session)
session->internals.handshake_in_progress = 1;
session->internals.vc_status = -1;
gnutls_gettime(&session->internals.handshake_start_time);
- if (session->internals.handshake_timeout_ms &&
- session->internals.handshake_endtime == 0)
- session->internals.handshake_endtime = session->internals.handshake_start_time.tv_sec +
- session->internals.handshake_timeout_ms / 1000;
+
+ tmo_ms = session->internals.handshake_timeout_ms;
+ end = &session->internals.handshake_endtime;
+ start = &session->internals.handshake_start_time;
+
+ if (tmo_ms && end->tv_sec == 0 && end->tv_nsec == 0) {
+ end->tv_sec =
+ start->tv_sec + (start->tv_nsec + tmo_ms * 1000000LL) / 1000000000LL;
+ end->tv_nsec =
+ (start->tv_nsec + tmo_ms * 1000000LL) % 1000000000LL;
+ }
}
if (session->internals.recv_state == RECV_STATE_FALSE_START) {