Fix closing of SocketFd by other side.

GitOrigin-RevId: adc39e4f4cd1d8938cf73e4ff5a4c532bcd3d9e9
This commit is contained in:
levlam 2018-09-11 19:31:15 +03:00
parent c4b18325b9
commit a80bd978e8

View File

@ -99,7 +99,7 @@ class SocketFdImpl : private Iocp::Callback {
TRY_STATUS(get_pending_error()); TRY_STATUS(get_pending_error());
} }
input_reader_.sync_with_writer(); input_reader_.sync_with_writer();
auto res = input_reader_.advance(min(slice.size(), input_reader_.size()), slice); auto res = input_reader_.advance(td::min(slice.size(), input_reader_.size()), slice);
if (res == 0) { if (res == 0) {
get_poll_info().clear_flags(PollFlags::Read()); get_poll_info().clear_flags(PollFlags::Read());
} }
@ -254,6 +254,10 @@ class SocketFdImpl : private Iocp::Callback {
VLOG(fd) << get_native_fd().socket() << " on read " << size; VLOG(fd) << get_native_fd().socket() << " on read " << size;
CHECK(is_read_active_); CHECK(is_read_active_);
is_read_active_ = false; is_read_active_ = false;
if (size == 0) {
get_poll_info().add_flags_from_poll(PollFlags::Close());
return;
}
input_writer_.confirm_append(size); input_writer_.confirm_append(size);
get_poll_info().add_flags_from_poll(PollFlags::Read()); get_poll_info().add_flags_from_poll(PollFlags::Read());
loop_read(); loop_read();