ws2_32: WSACleanup cleans up open sockets (OSX only)
Matt Durgavich
mattdurgavich at gmail.com
Thu Aug 27 22:46:20 CDT 2015
Another try, this time server side. It was much simpler to do
---
dlls/ws2_32/socket.c | 13 ++++++++++++-
server/handle.c | 12 ++++++++++++
server/protocol.def | 3 +++
server/sock.c | 2 +-
4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index ca82ec9..66d5b2b 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1471,7 +1471,18 @@ INT WINAPI WSACleanup(void)
{
if (num_startup) {
num_startup--;
- TRACE("pending cleanups: %d\n", num_startup);
+ if (num_startup == 0)
+ {
+ SERVER_START_REQ(close_all_sockets)
+ {
+ wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ }
+ else
+ {
+ TRACE("pending cleanups: %d\n", num_startup);
+ }
return 0;
}
SetLastError(WSANOTINITIALISED);
diff --git a/server/handle.c b/server/handle.c
index 5043ff7..b4b5ecb 100644
--- a/server/handle.c
+++ b/server/handle.c
@@ -39,6 +39,8 @@
#include "security.h"
#include "request.h"
+extern struct object_ops sock_ops;
+
struct handle_entry
{
struct object *ptr; /* object */
@@ -608,6 +610,16 @@ DECL_HANDLER(set_handle_info)
reply->old_flags = set_handle_flags( current->process, req->handle, req->mask, req->flags );
}
+DECL_HANDLER(close_all_sockets)
+{
+ obj_handle_t sock;
+ UINT index = 0;
+ while ( (sock = enumerate_handles(current->process, &sock_ops, &index)) )
+ {
+ close_handle(current->process, sock);
+ }
+}
+
/* duplicate a handle */
DECL_HANDLER(dup_handle)
{
diff --git a/server/protocol.def b/server/protocol.def
index c313006..651af47 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -942,6 +942,9 @@ struct rawinput_device
obj_handle_t handle; /* handle to close */
@END
+/* Close all sockets for the current process */
+ at REQ(close_all_sockets)
+ at END
/* Set a handle information */
@REQ(set_handle_info)
diff --git a/server/sock.c b/server/sock.c
index 67d6416..2a9f444 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -138,7 +138,7 @@ static int sock_get_ntstatus( int err );
static int sock_get_error( int err );
static void sock_set_error(void);
-static const struct object_ops sock_ops =
+const struct object_ops sock_ops =
{
sizeof(struct sock), /* size */
sock_dump, /* dump */
--
2.3.2 (Apple Git-55)
> On Aug 27, 2015, at 9:58 AM, Bruno Jesus <00cpxxx at gmail.com> wrote:
>
> That indeed sounds much easier than having to keep our own list inside the dll. Thanks, Henri.
>
> Bruno
>
> On Thursday, August 27, 2015, Matt Durgavich <mattdurgavich at gmail.com <mailto:mattdurgavich at gmail.com>> wrote:
> Cool. I'll whip up another patch with this approach. I thought this piece of work would be straightforward ;)
>
> Thanks!
>
> Best,
> -Matt
>
>
> On Thu, Aug 27, 2015 at 8:47 AM, Henri Verbeet <hverbeet at gmail.com <javascript:_e(%7B%7D,'cvml','hverbeet at gmail.com');>> wrote:
>
> On 27 August 2015 at 14:09, Bruno Jesus <00cpxxx at gmail.com <javascript:_e(%7B%7D,'cvml','00cpxxx at gmail.com');>> wrote:
> > I have other email asking how to list all sockets from inside the server but
> > I didn't get any replies so at that time I thought it was not possible to do
> > that.
> You'd iterate over current->process->handles->entries and compare
> entry->ptr->ops against sock_ops. I.e., enumerate_handles() in
> server/handle.c, although that seems currently unused.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20150827/a8998b45/attachment.html>
More information about the wine-devel
mailing list