From 2e12c7f3e8dca7e1696ebd92199617ce413565e7 Mon Sep 17 00:00:00 2001 From: "Roland C. Dowdeswell" Date: Mon, 12 Mar 2012 15:39:24 +0000 Subject: [PATCH] Switch from select(2) to poll(2) in send_to_kdc.c. Reviewed by: nico@cryptonector.com. --- lib/krb5/krb5_locl.h | 2 ++ lib/krb5/send_to_kdc.c | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/krb5/krb5_locl.h b/lib/krb5/krb5_locl.h index d0c68927f..e148b4e00 100644 --- a/lib/krb5/krb5_locl.h +++ b/lib/krb5/krb5_locl.h @@ -47,6 +47,8 @@ #include #include +#include + #include #ifdef HAVE_SYS_TYPES_H diff --git a/lib/krb5/send_to_kdc.c b/lib/krb5/send_to_kdc.c index 7dd5ee1fc..fdf8a0c44 100644 --- a/lib/krb5/send_to_kdc.c +++ b/lib/krb5/send_to_kdc.c @@ -47,9 +47,7 @@ struct send_to_kdc { static int timed_connect(int s, struct addrinfo *addr, time_t tmout) { - struct timeval timeout; socklen_t sl; - fd_set wfds; int err; int flags; int ret; @@ -67,12 +65,13 @@ timed_connect(int s, struct addrinfo *addr, time_t tmout) return -1; for (;;) { - FD_ZERO(&wfds); - FD_SET(s, &wfds); - timeout.tv_sec = tmout; - timeout.tv_usec = 0; + struct pollfd fds; - ret = select(s + 1, NULL, &wfds, NULL, &timeout); + fds.fd = s; + fds.events = POLLIN | POLLOUT; + fds.revents = 0; + + ret = poll(&fds, 1, tmout * 1000); if (ret != -1 || errno != EINTR) break; } -- 2.11.4.GIT