Commit 0ba9567a authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

http.sys: Use SO_EXCLUSIVEADDRUSE on listening socket.

parent a9ae1e04
......@@ -715,7 +715,7 @@ static NTSTATUS http_add_url(struct request_queue *queue, IRP *irp)
struct listening_socket *listening_sock;
char *url, *endptr;
size_t queue_url_len, new_url_len;
ULONG true = 1;
ULONG true = 1, value;
SOCKET s = INVALID_SOCKET;
TRACE("host %s, context %s.\n", debugstr_a(params->url), wine_dbgstr_longlong(params->context));
......@@ -781,6 +781,8 @@ static NTSTATUS http_add_url(struct request_queue *queue, IRP *irp)
addr.sin_family = AF_INET;
addr.sin_addr.S_un.S_addr = INADDR_ANY;
value = 1;
setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&value, sizeof(value));
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) == -1)
{
LeaveCriticalSection(&http_cs);
......
......@@ -1397,7 +1397,7 @@ static void test_v2_bound_port(void)
ok(!ret, "Failed to bind to port\n");
swprintf(url, ARRAY_SIZE(url), L"http://localhost:%u/", port);
ret = pHttpAddUrlToUrlGroup(group, url, 0xdeadbeef, 0);
todo_wine ok(ret == ERROR_SHARING_VIOLATION, "Unexpected failure adding %s, error %u.\n", debugstr_w(url), ret);
ok(ret == ERROR_SHARING_VIOLATION, "Unexpected failure adding %s, error %u.\n", debugstr_w(url), ret);
shutdown(s2, SD_BOTH);
closesocket(s2);
......@@ -1407,8 +1407,8 @@ static void test_v2_bound_port(void)
s = socket(AF_INET, SOCK_STREAM, 0);
ret = connect(s, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
todo_wine ok(ret, "Connecting to socket succeeded, %lu.\n", GetLastError());
todo_wine ok(GetLastError() == WSAECONNREFUSED, "Unexpected error connecting to socket, %lu.\n", GetLastError());
ok(ret, "Connecting to socket succeeded, %lu.\n", GetLastError());
ok(GetLastError() == WSAECONNREFUSED, "Unexpected error connecting to socket, %lu.\n", GetLastError());
closesocket(s);
ret = pHttpCloseRequestQueue(dummy_queue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment