http.sys: Translate WSAEADDRINUSE to STATUS_SHARING_VIOLATION.

Fixes intermittent failures on the Debian 10 testbot.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-01-24 13:55:37 -06:00 committed by Alexandre Julliard
parent 62069b4ee8
commit 533acfb1f6
2 changed files with 10 additions and 3 deletions
dlls
http.sys
httpapi/tests

View File

@ -1104,10 +1104,15 @@ static NTSTATUS http_add_url(struct request_queue *queue, IRP *irp)
addr.sin_addr.S_un.S_addr = INADDR_ANY;
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) == -1)
{
ERR("Failed to bind socket, error %u.\n", WSAGetLastError());
LeaveCriticalSection(&http_cs);
closesocket(s);
heap_free(url);
if (WSAGetLastError() == WSAEADDRINUSE)
{
WARN("Address %s is already in use.\n", debugstr_a(params->url));
return STATUS_SHARING_VIOLATION;
}
ERR("Failed to bind socket, error %u.\n", WSAGetLastError());
return STATUS_UNSUCCESSFUL;
}

View File

@ -113,8 +113,9 @@ static unsigned short add_url_v1(HANDLE queue)
for (port = 50000; port < 51000; ++port)
{
swprintf(url, ARRAY_SIZE(url), L"http://localhost:%u/", port);
if ((ret = HttpAddUrl(queue, url, NULL)) != ERROR_SHARING_VIOLATION)
if (!(ret = HttpAddUrl(queue, url, NULL)))
return port;
ok(ret == ERROR_SHARING_VIOLATION, "Failed to add %s, error %u.\n", debugstr_w(url), ret);
}
ok(0, "Failed to add url %s, error %u.\n", debugstr_w(url), ret);
return 0;
@ -129,8 +130,9 @@ static ULONG add_url_v2(HTTP_URL_GROUP_ID group)
for (port = 50010; port < 51000; ++port)
{
swprintf(url, ARRAY_SIZE(url), L"http://localhost:%u/", port);
if ((ret = pHttpAddUrlToUrlGroup(group, url, 0xdeadbeef, 0)) != ERROR_SHARING_VIOLATION)
if (!(ret = pHttpAddUrlToUrlGroup(group, url, 0xdeadbeef, 0)))
return port;
ok(ret == ERROR_SHARING_VIOLATION, "Failed to add %s, error %u.\n", debugstr_w(url), ret);
}
ok(0, "Failed to add url %s, error %u.\n", debugstr_w(url), ret);
return 0;