Martin Wilck Martin.Wilck@fujitsu-siemens.com writes:
The dup() in wine_server_handle_to_fd() requires dozens of close() calls spread over the wine code. I think this is confusing and error-prone (close() calls are easily forgotten, leading to rapid fd leak - actually, when looking through the code, I found a number of functions where I had expected a close(), but it was lacking). Moreover, I can't see why that dup() is necessary (any more).
I think it's cleaner to return a dup of the fd instead of relying on the fact that the fd is cached internally. This may not always be the case, and it's better to risk an fd leak than to risk invalidating the cached value in case someone closes the fd when they shouldn't.