ntdll/server and unix_fd handling

Kai Blin kai.blin at gmail.com
Tue Jul 22 02:52:36 CDT 2008

Hi folks,

I'm currently trying to get some integrated Wine/Samba tests working and in 
order to do so, I'm trying to add Samba socket wrapper support to Wine (i.e. 
allow Wine to hook into Samba's fake AF_FILE-based networking for testing).

The socket wrapper code keeps track of the unix_fds of the sockets it's 
wrapping, because it can also _not_ wrap other fds.

Now, I've been trying to connect this in dlls/ws2_32/socket.c:WSASocketW() by 
getting the unix_fd of the SOCKET the create_socket wineserver call returns, 
by calling get_sock_fd().

Now I noticed that every time I call this for the same SOCKET, the unix_fd 
increases by 1, effectively killing the tracking socket_wrapper does.

After some more digging, upstream of the get_sock_fd call, the 
server_get_unix_fd() call always gets the same fd, either from wineserver or 
from the cache. wine_server_handle_to_fd() then seems to call dup() on the 
unix_fd. This seems to be needed because for some reason unix fds are used 
only temporary, so get_sock_fd is always followed by release_sock_fd(), which 
calls a close(). Why is this handled this way?


Kai Blin
WorldForge developer  http://www.worldforge.org/
Wine developer        http://wiki.winehq.org/KaiBlin
Samba team member     http://www.samba.org/samba/team/
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20080722/bc2cdd3c/attachment.pgp 

More information about the wine-devel mailing list