summaryrefslogtreecommitdiff
path: root/lib/system.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2015-10-12 13:52:03 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2015-10-12 14:56:17 +0200
commit8d43daf7b5f75952a7d5ec49f1138db18ebe8ddb (patch)
tree7e5797d1dbca3e064236eec3810ea9d76b69cc48 /lib/system.c
parentc141b08728e0853633c8cd3dc35d108984d47f9c (diff)
downloadgnutls-8d43daf7b5f75952a7d5ec49f1138db18ebe8ddb.tar.gz
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
Diffstat (limited to 'lib/system.c')
-rw-r--r--lib/system.c11
1 files changed, 7 insertions, 4 deletions
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;