Check so_error early in sendfile() call. Prior to this patch, if a

connection was reset by the remote end, sendfile() would just report
ENOTCONN instead of ECONNRESET.

Submitted by:	Jason Eggleston <jason@eggnet.com>
Reviewed by:	glebius
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D12575
This commit is contained in:
Sean Bruno 2017-10-07 23:30:57 +00:00
parent 095db7e6e7
commit 75c8dfb6ae

View File

@ -514,6 +514,11 @@ sendfile_getsock(struct thread *td, int s, struct file **sock_fp,
*so = (*sock_fp)->f_data;
if ((*so)->so_type != SOCK_STREAM)
return (EINVAL);
if ((*so)->so_error) {
error = (*so)->so_error;
(*so)->so_error = 0;
return (error);
}
if (((*so)->so_state & SS_ISCONNECTED) == 0)
return (ENOTCONN);
return (0);