Prior to this patch, if a connection was reset
by the remote end, sendfile() would just report
ENOTCONN instead of ECONNRESET.
Details
Details
- Reviewers
glebius jtl - Group Reviewers
transport - Commits
- rS324405: Check so_error early in sendfile() call. Prior to this patch, if a
Diff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
Using packetdrill with this https://github.com/nplab/packetdrill/pull/137
This review fixes the following behavior:
# ./packetdrill/gtests/net/packetdrill/packetdrill -v sendfile_rst.pkt inbound injected packet: 0.100038 S 0:0(0) win 65535 <mss 1460,sackOK,eol,eol> outbound sniffed packet: 0.100145 S. 29914850:29914850(0) ack 1 win 65535 <mss 1460,sackOK,eol,eol> inbound injected packet: 0.150243 . 1:1(0) ack 29914851 win 65535 inbound injected packet: 0.250286 R 1:1(0) win 65535 sendfile_rst.pkt:11: runtime error in sendfile call: Expected errno 54 (Connection reset by peer) but got 57 (Socket is not connected)
# cat sendfile_rst.pkt 0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0.000 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 +0.000 bind(3, ..., ...) = 0 +0.000 listen(3, 3) = 0 +0.100 < S 0:0(0) win 65535 <mss 1460,sackOK,eol,eol> +0.000 > S. 0:0(0) ack 1 win 65535 <mss 1460,sackOK,eol,eol> +0.050 < . 1:1(0) ack 1 win 65535 +0.050 accept(3, ..., ...) = 4 +0.050 < R 1:1(0) ack 1 win 65535 +0.050 open("testfile", O_RDONLY) = 5 +0.050 sendfile(5, 4, 0, 0, {headers(0)=[], trailers(0)=[]}, [0], 0) = -1 ECONNRESET (Connection reset by peer) +0.050 close(4) = 0
After the patch:
# ./packetdrill/gtests/net/packetdrill/packetdrill -v sendfilerst.pkt inbound injected packet: 0.100370 S 0:0(0) win 65535 <mss 1460,sackOK,eol,eol> outbound sniffed packet: 0.100907 S. 3047891798:3047891798(0) ack 1 win 65535 <mss 1460,sackOK,eol,eol> inbound injected packet: 0.151481 . 1:1(0) ack 3047891799 win 65535 inbound injected packet: 0.252850 R 1:1(0) win 65535