Hans Leidekker : wininet: Map socket errors to ERROR_INTERNET_CANNOT_CONNECT in create_netconn_socket .

Alexandre Julliard julliard at winehq.org
Wed Dec 19 14:01:10 CST 2012


Module: wine
Branch: master
Commit: f33f7a5df1a5029adf5da2b3f5ce52665b95fb02
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f33f7a5df1a5029adf5da2b3f5ce52665b95fb02

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Dec 19 12:02:36 2012 +0100

wininet: Map socket errors to ERROR_INTERNET_CANNOT_CONNECT in create_netconn_socket.

---

 dlls/wininet/netconnection.c |    2 +-
 dlls/wininet/tests/http.c    |   27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c
index e7a3274..8d5fc6f 100644
--- a/dlls/wininet/netconnection.c
+++ b/dlls/wininet/netconnection.c
@@ -646,7 +646,7 @@ static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD t
         }
     }
     if(result == -1)
-        return sock_get_error(errno);
+        return ERROR_INTERNET_CANNOT_CONNECT;
 
 #ifdef TCP_NODELAY
     flag = 1;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index c9bd0a4..ba4ec4d 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -4041,6 +4041,32 @@ static void test_InternetCloseHandle(void)
        closetest_req, res, GetLastError());
 }
 
+static void test_connection_failure(void)
+{
+    HINTERNET session, connect, request;
+    DWORD error;
+    BOOL ret;
+
+    session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
+    ok(session != NULL, "failed to get session handle\n");
+
+    connect = InternetConnectA(session, "localhost", 1, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(connect != NULL, "failed to get connection handle\n");
+
+    request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, 0, 0);
+    ok(request != NULL, "failed to get request handle\n");
+
+    SetLastError(0xdeadbeef);
+    ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+    error = GetLastError();
+    ok(!ret, "unexpected success\n");
+    ok(error == ERROR_INTERNET_CANNOT_CONNECT, "wrong error %u\n", error);
+
+    InternetCloseHandle(request);
+    InternetCloseHandle(connect);
+    InternetCloseHandle(session);
+}
+
 static void init_status_tests(void)
 {
     memset(expect, 0, sizeof(expect));
@@ -4117,4 +4143,5 @@ START_TEST(http)
     InternetReadFile_chunked_test();
     HttpSendRequestEx_test();
     InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]);
+    test_connection_failure();
 }




More information about the wine-cvs mailing list