proxy: Deal with close() failures (and EINTR errnos) comprehensively

This commit is contained in:
nick
2013-03-15 12:07:16 +00:00
parent f89352aa28
commit 21ac3cd0ed
4 changed files with 42 additions and 11 deletions

View File

@@ -216,3 +216,24 @@ out:
return result;
}
int sock_try_close( int fd )
{
int result;
do {
result = close( fd );
if ( result == -1 ) {
if ( EINTR == errno ) {
continue; /* retry EINTR */
} else {
warn( SHOW_ERRNO( "Failed to close() fd %i", fd ) );
break; /* Other errors get reported */
}
}
} while( 0 );
return result;
}