ws2_32-TransmitFile: Remove patches.

Erich can't remember the purpose of these, and suspects that it was incidental
to the other patches for TransmitFile (which used to be in the same Wine-Staging
patch set); those were for WineHQ bug 5048.

Moreover, these aren't correct, and a correct implementation would take a lot of
work, and wouldn't really be able to use anything from these patches as a
reference.

Hence, they're not providing any value to anyone, so remove them.
This commit is contained in:
Zebediah Figura 2024-03-21 19:03:46 -05:00
parent 63300ffaad
commit 761fef8d70
3 changed files with 0 additions and 277 deletions

View File

@ -1,76 +0,0 @@
From c29cd38f3c72aee2e02c60945fc5bda1fab4d556 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Wed, 4 Mar 2015 13:16:20 -0700
Subject: [PATCH] ws2_32: Add support for TF_DISCONNECT to TransmitFile.
---
dlls/ws2_32/socket.c | 16 +++++++++++++---
dlls/ws2_32/tests/sock.c | 11 +++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 59dff66e37f..07f812b2391 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3081,7 +3081,16 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
return wsaErrStatus();
}
- return status;
+ if (status != STATUS_SUCCESS)
+ return status;
+
+ if (wsa->flags & TF_DISCONNECT)
+ {
+ /* we can't use WS_closesocket because it modifies the last error */
+ NtClose( SOCKET2HANDLE(wsa->write.hSocket) );
+ }
+
+ return STATUS_SUCCESS;
}
/***********************************************************************
@@ -3117,6 +3126,7 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
LPOVERLAPPED overlapped, LPTRANSMIT_FILE_BUFFERS buffers,
DWORD flags )
{
+ DWORD unsupported_flags = flags & ~(TF_DISCONNECT);
union generic_unix_sockaddr uaddr;
socklen_t uaddrlen = sizeof(uaddr);
struct ws2_transmitfile_async *wsa;
@@ -3138,8 +3148,8 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
WSASetLastError( WSAENOTCONN );
return FALSE;
}
- if (flags)
- FIXME("Flags are not currently supported (0x%x).\n", flags);
+ if (unsupported_flags)
+ FIXME("Flags are not currently supported (0x%x).\n", unsupported_flags);
if (h && GetFileType( h ) != FILE_TYPE_DISK)
{
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 60360bacc21..134bb9625a6 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -9057,6 +9057,17 @@ static void test_TransmitFile(void)
ok(memcmp(buf, &footer_msg[0], sizeof(footer_msg)) == 0,
"TransmitFile footer buffer did not match!\n");
+ /* Test TransmitFile w/ TF_DISCONNECT */
+ SetFilePointer(file, 0, NULL, FILE_BEGIN);
+ bret = pTransmitFile(client, file, 0, 0, NULL, NULL, TF_DISCONNECT);
+ ok(bret, "TransmitFile failed unexpectedly.\n");
+ compare_file(file, dest, 0);
+ closesocket(client);
+ ok(send(client, "test", 4, 0) == -1, "send() after TF_DISCONNECT succeeded unexpectedly.\n");
+ err = WSAGetLastError();
+ todo_wine ok(err == WSAENOTSOCK, "send() after TF_DISCONNECT triggered unexpected errno (%d != %d)\n",
+ err, WSAENOTSOCK);
+
/* Test TransmitFile with a UDP datagram socket */
closesocket(client);
client = socket(AF_INET, SOCK_DGRAM, 0);
--
2.19.1

View File

@ -1,198 +0,0 @@
From 89a20d7e379e9be6da4230e303b830d190ab1b2c Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 19:08:30 -0700
Subject: [PATCH] ws2_32: Add support for TF_REUSE_SOCKET to TransmitFile.
---
dlls/ws2_32/socket.c | 13 ++++++++-
dlls/ws2_32/tests/sock.c | 1 -
include/winsock.h | 1 +
server/protocol.def | 6 ++++
server/sock.c | 63 +++++++++++++++++++++++++++++++++++-----
5 files changed, 74 insertions(+), 10 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index fed5329b37a..ee449cce581 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3147,6 +3147,17 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
if (status != STATUS_SUCCESS)
return status;
+ if (wsa->flags & TF_REUSE_SOCKET)
+ {
+ SERVER_START_REQ( reuse_socket )
+ {
+ req->handle = wine_server_obj_handle( wsa->write.hSocket );
+ status = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ if (status != STATUS_SUCCESS)
+ return status;
+ }
if (wsa->flags & TF_DISCONNECT)
{
/* we can't use WS_closesocket because it modifies the last error */
@@ -3189,7 +3200,7 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
LPOVERLAPPED overlapped, LPTRANSMIT_FILE_BUFFERS buffers,
DWORD flags )
{
- DWORD unsupported_flags = flags & ~(TF_DISCONNECT);
+ DWORD unsupported_flags = flags & ~(TF_DISCONNECT|TF_REUSE_SOCKET);
union generic_unix_sockaddr uaddr;
socklen_t uaddrlen = sizeof(uaddr);
struct ws2_transmitfile_async *wsa;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 3d338741e0e..492d68e037c 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -8874,7 +8874,6 @@ static void test_TransmitFile(void)
err, WSAENOTSOCK);
/* Test TransmitFile with a UDP datagram socket */
- closesocket(client);
client = socket(AF_INET, SOCK_DGRAM, 0);
bret = pTransmitFile(client, NULL, 0, 0, NULL, NULL, 0);
err = WSAGetLastError();
diff --git a/include/winsock.h b/include/winsock.h
index a8bb35a4c41..42d8f751094 100644
--- a/include/winsock.h
+++ b/include/winsock.h
@@ -835,6 +835,7 @@ typedef struct WS(WSAData)
/* internal per-socket flags */
#ifdef __WINESRC__
+#define FD_WINE_REUSE 0x08000000
#define FD_WINE_LISTENING 0x10000000
#define FD_WINE_NONBLOCKING 0x20000000
#define FD_WINE_CONNECTED 0x40000000
diff --git a/server/protocol.def b/server/protocol.def
index 92290af701c..77b823caad8 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1410,6 +1410,12 @@ enum server_fd_type
@END
+/* Mark a socket to be reused after "closed" */
+@REQ(reuse_socket)
+ obj_handle_t handle; /* handle to the socket */
+@END
+
+
/* Set socket event parameters */
@REQ(set_socket_event)
obj_handle_t handle; /* handle to the socket */
diff --git a/server/sock.c b/server/sock.c
index 1a53ce4b091..03e4ca2eec5 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -86,6 +86,7 @@
#define FD_CLOSE 0x00000020
/* internal per-socket flags */
+#define FD_WINE_REUSE 0x08000000
#define FD_WINE_LISTENING 0x10000000
#define FD_WINE_NONBLOCKING 0x20000000
#define FD_WINE_CONNECTED 0x40000000
@@ -132,6 +133,7 @@ static enum server_fd_type sock_get_fd_type( struct fd *fd );
static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
static void sock_queue_async( struct fd *fd, struct async *async, int type, int count );
static void sock_reselect_async( struct fd *fd, struct async_queue *queue );
+static int sock_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
static int sock_get_ntstatus( int err );
static unsigned int sock_get_error( int err );
@@ -155,7 +157,7 @@ static const struct object_ops sock_ops =
NULL, /* unlink_name */
no_open_file, /* open_file */
no_kernel_obj_list, /* get_kernel_obj_list */
- fd_close_handle, /* close_handle */
+ sock_close_handle, /* close_handle */
sock_destroy /* destroy */
};
@@ -607,6 +609,46 @@ static struct fd *sock_get_fd( struct object *obj )
return (struct fd *)grab_object( sock->fd );
}
+static int init_sockfd( int family, int type, int protocol )
+{
+ int sockfd;
+
+ sockfd = socket( family, type, protocol );
+ if (sockfd == -1)
+ {
+ if (errno == EINVAL) set_win32_error( WSAESOCKTNOSUPPORT );
+ else set_win32_error( sock_get_error( errno ));
+ return sockfd;
+ }
+ fcntl(sockfd, F_SETFL, O_NONBLOCK); /* make socket nonblocking */
+ return sockfd;
+}
+
+static int sock_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
+{
+ struct sock *sock = (struct sock *)obj;
+
+ assert( obj->ops == &sock_ops );
+ if (!fd_close_handle( obj, process, handle ))
+ return FALSE;
+
+ if (sock->state & FD_WINE_REUSE)
+ {
+ struct fd *fd;
+ int sockfd;
+
+ if ((sockfd = init_sockfd( sock->family, sock->type, sock->proto )) == -1)
+ return TRUE;
+ if (!(fd = create_anonymous_fd( &sock_fd_ops, sockfd, &sock->obj, get_fd_options(sock->fd) )))
+ return TRUE;
+ shutdown( get_unix_fd(sock->fd), SHUT_RDWR );
+ release_object( sock->fd );
+ sock->fd = fd;
+ return FALSE;
+ }
+ return TRUE;
+}
+
static void sock_destroy( struct object *obj )
{
struct sock *sock = (struct sock *)obj;
@@ -660,14 +702,8 @@ static struct object *create_socket( int family, int type, int protocol, unsigne
struct sock *sock;
int sockfd;
- sockfd = socket( family, type, protocol );
- if (sockfd == -1)
- {
- if (errno == EINVAL) set_win32_error( WSAESOCKTNOSUPPORT );
- else set_win32_error( sock_get_error( errno ));
+ if ((sockfd = init_sockfd( family, type, protocol )) == -1)
return NULL;
- }
- fcntl(sockfd, F_SETFL, O_NONBLOCK); /* make socket nonblocking */
if (!(sock = alloc_object( &sock_ops )))
{
close( sockfd );
@@ -1218,6 +1254,17 @@ DECL_HANDLER(accept_into_socket)
release_object( sock );
}
+/* mark a socket to be recreated on close */
+DECL_HANDLER(reuse_socket)
+{
+ struct sock *sock;
+
+ if (!(sock = (struct sock *)get_handle_obj( current->process, req->handle,
+ FILE_WRITE_ATTRIBUTES, &sock_ops))) return;
+ sock->state |= FD_WINE_REUSE;
+ release_object( &sock->obj );
+}
+
/* set socket event parameters */
DECL_HANDLER(set_socket_event)
{
--
2.28.0

View File

@ -1,3 +0,0 @@
# Fixes: [5048] Support for TransmitFile
# Broken nontrivially by db8a75312, and I'm working on a proper implementation for this.
Disabled: true