ntdll: Use lockfree implementation for get_cached_fd. (try 2)

Sebastian Lackner sebastian at fds-team.de
Sat May 31 12:05:21 CDT 2014


I already hit the send button when I noticed one possible race condition
:/, but this should be fixed in this updated patch. Take a look at try 1
for more details about the purpose and details.

Changes in try 2:

* Always try to access the fd cache two times - this ensures that we
don't release a file descriptor when its still in use by a second thread.

* Replace interlocked_xchg() with an assert(). The original code looks
like its valid that the fd is nonzero at this point, but in fact this
would cause releasing a file descriptor which is still in use. Replacing
with an assert() also saves a couple of CPU cycles.

---
 dlls/ntdll/server.c |   57
++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 41 insertions(+), 16 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ntdll-Use-lockfree-implementation-for-get_cached_fd.patch
Type: text/x-patch
Size: 4366 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20140531/a59dcc2a/attachment.bin>


More information about the wine-patches mailing list