]> granicus.if.org Git - libevent/commitdiff
*fix: bench_httpclient to support win32
authorzeliard <spacesun@naver.com>
Fri, 5 Jun 2015 07:39:26 +0000 (16:39 +0900)
committerzeliard <spacesun@naver.com>
Fri, 5 Jun 2015 07:39:26 +0000 (16:39 +0900)
test/bench_httpclient.c

index 22f174da5b662640a835964b7fbb35f070f8c3ed..8700754fd303dc753c9e284a3686b270f0f8e14d 100644 (file)
@@ -152,6 +152,9 @@ launch_request(void)
        frob_socket(sock);
        if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) < 0) {
                int e = errno;
+#ifdef _WIN32
+               e = WSAGetLastError();
+#endif
                if (! EVUTIL_ERR_CONNECT_RETRIABLE(e)) {
                        evutil_closesocket(sock);
                        return -1;
@@ -183,6 +186,11 @@ main(int argc, char **argv)
        double throughput;
        resource = "/ref";
 
+#ifdef _WIN32
+       WSADATA WSAData;
+       WSAStartup(0x101, &WSAData);
+#endif
+
        setvbuf(stdout, NULL, _IONBF, 0);
 
        base = event_base_new();
@@ -226,5 +234,9 @@ main(int argc, char **argv)
            (double)(usec/1000) / total_n_handled,
            (I64_TYP)total_n_bytes, n_errors);
 
+#ifdef _WIN32
+       WSACleanup();
+#endif
+
        return 0;
 }