fio patch: Windows netio fixes
authorBruce Cran <bruce@cran.org.uk>
Wed, 10 Oct 2012 12:37:41 +0000 (13:37 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Oct 2012 14:18:43 +0000 (08:18 -0600)
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 <axboe@kernel.dk>
engines/net.c
os/windows/posix.c

index 7354d310141d2f7b4a9da29827da31ea6a319c67..c5337994fa41509acad7a4cf91003b0ac1422503 100644 (file)
@@ -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;
index 6ad47df8c7d08381314460558f05aba166f22216..245177298f5307502bf8bbb563d34ad4f323ffc1 100755 (executable)
@@ -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;