summaryrefslogtreecommitdiff
path: root/lib/system.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-01-28 10:45:17 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-01-28 11:16:40 +0100
commitf64fbce6e2ef574359b01ac6f89f5a6b9a125e28 (patch)
tree546045fdaa359c17c7b28946560129af687d3b80 /lib/system.c
parentc58f4391ded0dc6ef282b6c6376fac3de25524c1 (diff)
downloadgnutls-f64fbce6e2ef574359b01ac6f89f5a6b9a125e28.tar.gz
Replaced select() system call with poll() on POSIX systems
This allows to use the default gnutls functions with file descriptors over the maximum supported by select.
Diffstat (limited to 'lib/system.c')
-rw-r--r--lib/system.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/system.c b/lib/system.c
index f5f9c76ece..a096cea242 100644
--- a/lib/system.c
+++ b/lib/system.c
@@ -45,8 +45,9 @@ static HMODULE Crypt32_dll;
# define pCertEnumCRLsInStore CertEnumCRLsInStore
# endif
-#else /* _WIN32 */
-# include <sys/select.h>
+#else /* !_WIN32 */
+
+# include <poll.h>
# ifdef HAVE_PTHREAD_LOCKS
# include <pthread.h>
@@ -164,10 +165,24 @@ 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, *tv = NULL;
int ret;
int fd = GNUTLS_POINTER_TO_INT(ptr);
+#ifndef _WIN32
+ int timeo;
+ struct pollfd pfd;
+
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+
+ if (ms == GNUTLS_INDEFINITE_TIMEOUT)
+ timeo = -1;
+ else
+ timeo = ms;
+ ret = poll(&pfd, 1, timeo);
+#else
+ fd_set rfds;
+ struct timeval _tv, *tv = NULL;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
@@ -179,6 +194,7 @@ int gnutls_system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms)
}
ret = select(fd + 1, &rfds, NULL, NULL, tv);
+#endif
if (ret <= 0)
return ret;
@@ -437,7 +453,6 @@ static
int add_system_trust(gnutls_x509_trust_list_t list, unsigned int tl_flags,
unsigned int tl_vflags)
{
- char path[GNUTLS_PATH_MAX];
unsigned int i;
int r = 0;