mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
Fix posix_file::close handling of EINTR:
fix #1445 These changes optimize for Linux at the possible expense of non-conforming platforms like HP-UX.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Version 213:
|
||||||
|
|
||||||
|
* Fix posix_file::close handling of EINTR
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 212:
|
Version 212:
|
||||||
|
|
||||||
* dynamic_buffer_ref tests and tidy
|
* dynamic_buffer_ref tests and tidy
|
||||||
|
@ -40,19 +40,30 @@ int
|
|||||||
file_posix::
|
file_posix::
|
||||||
native_close(native_handle_type& fd)
|
native_close(native_handle_type& fd)
|
||||||
{
|
{
|
||||||
|
/* https://github.com/boostorg/beast/issues/1445
|
||||||
|
|
||||||
|
This function is tuned for Linux / Mac OS:
|
||||||
|
|
||||||
|
* only calls close() once
|
||||||
|
* returns the error directly to the caller
|
||||||
|
* does not loop on EINTR
|
||||||
|
|
||||||
|
If this is incorrect for the platform, then the
|
||||||
|
caller will need to implement their own type
|
||||||
|
meeting the File requirements and use the correct
|
||||||
|
behavior.
|
||||||
|
|
||||||
|
See:
|
||||||
|
http://man7.org/linux/man-pages/man2/close.2.html
|
||||||
|
*/
|
||||||
|
int ev = 0;
|
||||||
if(fd != -1)
|
if(fd != -1)
|
||||||
{
|
{
|
||||||
for(;;)
|
if(::close(fd) != 0)
|
||||||
{
|
ev = errno;
|
||||||
if(::close(fd) == 0)
|
|
||||||
break;
|
|
||||||
int const ev = errno;
|
|
||||||
if(errno != EINTR)
|
|
||||||
return ev;
|
|
||||||
}
|
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_posix::
|
file_posix::
|
||||||
|
Reference in New Issue
Block a user