From 8d43daf7b5f75952a7d5ec49f1138db18ebe8ddb Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 12 Oct 2015 13:52:03 +0200 Subject: Introduced GNUTLS_INDEFINITE_TIMEOUT This allows to specify an indefinite timeout to gnutls_record_set_timeout(). In addition this flag is accepted by gnutls_handshake_set_timeout() and cancels out a previously set timeout. Resolves #41 --- lib/system.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/system.c') diff --git a/lib/system.c b/lib/system.c index 4d72968f13..ab8d89df8e 100644 --- a/lib/system.c +++ b/lib/system.c @@ -160,17 +160,20 @@ system_read(gnutls_transport_ptr_t ptr, void *data, size_t data_size) int gnutls_system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms) { fd_set rfds; - struct timeval tv; + struct timeval _tv, *tv = NULL; int ret; int fd = GNUTLS_POINTER_TO_INT(ptr); FD_ZERO(&rfds); FD_SET(fd, &rfds); - tv.tv_sec = ms/1000; - tv.tv_usec = (ms % 1000) * 1000; + if (ms != GNUTLS_INDEFINITE_TIMEOUT) { + _tv.tv_sec = ms/1000; + _tv.tv_usec = (ms % 1000) * 1000; + tv = &_tv; + } - ret = select(fd + 1, &rfds, NULL, NULL, &tv); + ret = select(fd + 1, &rfds, NULL, NULL, tv); if (ret <= 0) return ret; -- cgit v1.2.1