From 3f457bea08a6bd60d99950c59c5432b8e78c69e2 Mon Sep 17 00:00:00 2001 From: Bruce Cran Date: Wed, 10 Oct 2012 13:37:41 +0100 Subject: [PATCH] fio patch: Windows netio fixes Jens, I've attached a patch to fix netio on Windows: Add call to WSAStartup() to engines\net.c. Fix NULL dereference in poll(). Add inet_aton(). -- Bruce Cran Signed-off-by: Jens Axboe --- engines/net.c | 7 ++++++- os/windows/posix.c | 14 ++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/engines/net.c b/engines/net.c index 7354d310..c5337994 100644 --- a/engines/net.c +++ b/engines/net.c @@ -144,7 +144,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u) td_verror(td, EINVAL, "bad direction"); return 1; } - + return 0; } @@ -687,6 +687,11 @@ static int fio_netio_init(struct thread_data *td) struct netio_options *o = td->eo; int ret; +#ifdef WIN32 + WSADATA wsd; + WSAStartup(MAKEWORD(2,2), &wsd); +#endif + if (td_random(td)) { log_err("fio: network IO can't be random\n"); return 1; diff --git a/os/windows/posix.c b/os/windows/posix.c index 6ad47df8..24517729 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -628,11 +628,11 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) int i; int rc; - if (timeout != -1) + if (timeout != -1) { to = &tv; - - to->tv_sec = timeout / 1000; - to->tv_usec = (timeout % 1000) * 1000; + to->tv_sec = timeout / 1000; + to->tv_usec = (timeout % 1000) * 1000; + } FD_ZERO(&readfds); FD_ZERO(&writefds); @@ -811,9 +811,15 @@ const char* inet_ntop(int af, const void *restrict src, errno = ENOSPC; WSACleanup(); + return ret; } +int inet_aton(const char *cp, struct in_addr *inp) +{ + return inet_pton(AF_INET, cp, inp); +} + int inet_pton(int af, const char *restrict src, void *restrict dst) { INT status = SOCKET_ERROR; -- 2.25.1