diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-01-28 10:45:17 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-01-28 11:16:40 +0100 |
commit | f64fbce6e2ef574359b01ac6f89f5a6b9a125e28 (patch) | |
tree | 546045fdaa359c17c7b28946560129af687d3b80 | |
parent | c58f4391ded0dc6ef282b6c6376fac3de25524c1 (diff) | |
download | gnutls-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.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | doc/cha-gtls-app.texi | 2 | ||||
-rw-r--r-- | lib/system.c | 25 | ||||
-rw-r--r-- | tests/seccomp.c | 4 |
4 files changed, 24 insertions, 9 deletions
@@ -30,6 +30,8 @@ See the end for copying conditions. ** libgnutls: Replaced writev() system call with sendmsg(). +** libgnutls: Replaced select() system call with poll() on POSIX systems. + ** certtool: Added the --provable option. ** API and ABI modifications: diff --git a/doc/cha-gtls-app.texi b/doc/cha-gtls-app.texi index 03a17d6288..0bfd9fbc0f 100644 --- a/doc/cha-gtls-app.texi +++ b/doc/cha-gtls-app.texi @@ -261,7 +261,7 @@ operation. @item sendmsg @item read (to read from /dev/urandom) @item getrandom (this is Linux-kernel specific) -@item select +@item poll @end itemize As well as any calls needed for memory allocation to work. Note however, that GnuTLS 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; diff --git a/tests/seccomp.c b/tests/seccomp.c index 8427fd9f7b..f5c0f2a766 100644 --- a/tests/seccomp.c +++ b/tests/seccomp.c @@ -76,9 +76,7 @@ int disable_system_calls(void) ADD_SYSCALL(rt_sigprocmask, 0); /* used in to detect reading timeouts */ - ADD_SYSCALL(select, 0); - /* in x86, glibc uses _newselect() */ - ADD_SYSCALL(_newselect, 0); + ADD_SYSCALL(poll, 0); /* for memory allocation */ ADD_SYSCALL(brk, 0); |