1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 03:45:57 +00:00

http.sys: Use SO_EXCLUSIVEADDRUSE on listening socket.

This commit is contained in:
Paul Gofman 2022-10-31 15:58:23 -06:00 committed by Alexandre Julliard
parent a9ae1e041c
commit 0ba9567a56
2 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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);