done ; \
exit $$fail
+sc_prohibit_select:
+ @prohibit="\\<select *\\(" \
+ halt="use poll(), not se""lect()" \
+ $(_sc_search_regexp)
+
# Prohibit the inclusion of <ctype.h>.
sc_prohibit_ctype_h:
@prohibit='^# *include *<ctype\.h>' \
#include <netdb.h>
#include <fcntl.h>
#include <domain_event.h>
+#include <poll.h>
#include "internal.h"
#include "virauth.h"
static int
waitsocket(int socket_fd, LIBSSH2_SESSION * session)
{
- struct timeval timeout;
- fd_set fd;
- fd_set *writefd = NULL;
- fd_set *readfd = NULL;
+ struct pollfd fds[1];
int dir;
- timeout.tv_sec = 0;
- timeout.tv_usec = 1000;
-
- FD_ZERO(&fd);
-
- FD_SET(socket_fd, &fd);
+ memset(fds, 0, sizeof(fds));
+ fds[0].fd = socket_fd;
/* now make sure we wait in the correct direction */
dir = libssh2_session_block_directions(session);
if (dir & LIBSSH2_SESSION_BLOCK_INBOUND)
- readfd = &fd;
+ fds[0].events |= POLLIN;
if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
- writefd = &fd;
+ fds[0].events |= POLLOUT;
- return select(socket_fd + 1, readfd, writefd, NULL, &timeout);
+ return poll(fds, ARRAY_CARDINALITY(fds), -1);
}
/* this function is the layer that manipulates the ssh channel itself
#define VIR_FROM_THIS VIR_FROM_NET
-#define NETLINK_ACK_TIMEOUT_S 2
+#define NETLINK_ACK_TIMEOUT_S (2*1000)
#if defined(__linux__) && defined(HAVE_LIBNL)
/* State for a single netlink event handle */
.nl_groups = 0,
};
ssize_t nbytes;
- struct timeval tv = {
- .tv_sec = NETLINK_ACK_TIMEOUT_S,
- };
- fd_set readfds;
+ struct pollfd fds[1];
int fd;
int n;
struct nlmsghdr *nlmsg = nlmsg_hdr(nl_msg);
goto error;
}
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
+ memset(fds, 0, sizeof(fds));
+ fds[0].fd = fd;
+ fds[0].events = POLLIN;
- n = select(fd + 1, &readfds, NULL, NULL, &tv);
+ n = poll(fds, ARRAY_CARDINALITY(fds), NETLINK_ACK_TIMEOUT_S);
if (n <= 0) {
if (n < 0)
virReportSystemError(errno, "%s",
- _("error in select call"));
+ _("error in poll call"));
if (n == 0)
virReportSystemError(ETIMEDOUT, "%s",
_("no valid netlink response was received"));