Fix a file descriptor leak when opening the first file on a removable
device.
This commit is contained in:
parent
b3b5ab8977
commit
b4c69e0f12
@ -487,7 +487,11 @@ int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *uni
|
|||||||
SERVER_END_REQ;
|
SERVER_END_REQ;
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
|
|
||||||
if (fd != -1) break;
|
if (fd != -1)
|
||||||
|
{
|
||||||
|
if ((fd = dup(fd)) == -1) return FILE_GetNtStatus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* it wasn't in the cache, get it from the server */
|
/* it wasn't in the cache, get it from the server */
|
||||||
fd = receive_fd( &fd_handle );
|
fd = receive_fd( &fd_handle );
|
||||||
@ -500,11 +504,7 @@ int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *uni
|
|||||||
if (FILE_GetDeviceInfo( fd, &info ) == STATUS_SUCCESS)
|
if (FILE_GetDeviceInfo( fd, &info ) == STATUS_SUCCESS)
|
||||||
removable = (info.Characteristics & FILE_REMOVABLE_MEDIA) != 0;
|
removable = (info.Characteristics & FILE_REMOVABLE_MEDIA) != 0;
|
||||||
}
|
}
|
||||||
else if (removable) /* don't cache it */
|
else if (removable) break; /* don't cache it */
|
||||||
{
|
|
||||||
*unix_fd = fd;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and store it back into the cache */
|
/* and store it back into the cache */
|
||||||
SERVER_START_REQ( set_handle_fd )
|
SERVER_START_REQ( set_handle_fd )
|
||||||
@ -514,11 +514,10 @@ int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *uni
|
|||||||
req->removable = removable;
|
req->removable = removable;
|
||||||
if (!(ret = wine_server_call( req )))
|
if (!(ret = wine_server_call( req )))
|
||||||
{
|
{
|
||||||
if (reply->cur_fd != fd && reply->cur_fd != -1)
|
if (reply->cur_fd != -1) /* it has been cached */
|
||||||
{
|
{
|
||||||
/* someone was here before us */
|
if (reply->cur_fd != fd) close( fd ); /* someone was here before us */
|
||||||
close( fd );
|
if ((fd = dup(reply->cur_fd)) == -1) ret = FILE_GetNtStatus();
|
||||||
fd = reply->cur_fd;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -535,9 +534,9 @@ int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *uni
|
|||||||
* a race with another thread; we restart everything from
|
* a race with another thread; we restart everything from
|
||||||
* scratch in this case.
|
* scratch in this case.
|
||||||
*/
|
*/
|
||||||
|
close( fd );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd != -1) && ((fd = dup(fd)) == -1)) return STATUS_TOO_MANY_OPENED_FILES;
|
|
||||||
*unix_fd = fd;
|
*unix_fd = fd;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user