ntdll/server and unix_fd handling

Alexandre Julliard julliard at winehq.org
Tue Jul 22 04:49:33 CDT 2008

Kai Blin <kai.blin at gmail.com> writes:

> 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?

Because the file descriptor has to remain valid until it is released, so
we have to dup() it as it may get closed from a different thread in the
meantime. We can avoid the dup() in some cases in ntdll, but not in
other dlls since it would let anybody screw up the fd cache.

Alexandre Julliard
julliard at winehq.org

More information about the wine-devel mailing list