From: Nikos Mavrogiannopoulos Date: Thu, 28 Jan 2016 09:45:17 +0000 (+0100) Subject: Replaced select() system call with poll() on POSIX systems X-Git-Tag: gnutls_3_5_0~386 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f64fbce6e2ef574359b01ac6f89f5a6b9a125e28;p=thirdparty%2Fgnutls.git 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. --- diff --git a/NEWS b/NEWS index e3a824ed84..ae9c1a4005 100644 --- a/NEWS +++ b/NEWS @@ -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 +#else /* !_WIN32 */ + +# include # ifdef HAVE_PTHREAD_LOCKS # include @@ -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);