ntdll: Assert when trying to replace an exiting file descriptor in fd_cache.

This commit is contained in:
Sebastian Lackner 2015-03-01 02:36:45 +01:00 committed by Alexandre Julliard
parent 36bc8563cf
commit bf65fef8bc

View File

@ -821,7 +821,6 @@ static BOOL add_fd_to_cache( HANDLE handle, int fd, enum server_fd_type type,
unsigned int access, unsigned int options ) unsigned int access, unsigned int options )
{ {
unsigned int entry, idx = handle_to_index( handle, &entry ); unsigned int entry, idx = handle_to_index( handle, &entry );
int prev_fd;
if (entry >= FD_CACHE_ENTRIES) if (entry >= FD_CACHE_ENTRIES)
{ {
@ -841,11 +840,11 @@ static BOOL add_fd_to_cache( HANDLE handle, int fd, enum server_fd_type type,
} }
} }
/* store fd+1 so that 0 can be used as the unset value */ /* store fd+1 so that 0 can be used as the unset value */
prev_fd = interlocked_xchg( &fd_cache[entry][idx].fd, fd + 1 ) - 1; fd = interlocked_xchg( &fd_cache[entry][idx].fd, fd + 1 );
fd_cache[entry][idx].type = type; fd_cache[entry][idx].type = type;
fd_cache[entry][idx].access = access; fd_cache[entry][idx].access = access;
fd_cache[entry][idx].options = options; fd_cache[entry][idx].options = options;
if (prev_fd != -1) close( prev_fd ); assert( !fd );
return TRUE; return TRUE;
} }