Remove some usages of io_handle.

GitOrigin-RevId: 5e09106583dd25590606fb68ae00a3f99dfe6a6b
This commit is contained in:
levlam 2018-09-11 15:49:59 +03:00
parent 11ccf8f4c8
commit db228c09c4
3 changed files with 20 additions and 20 deletions

View File

@ -40,7 +40,7 @@ namespace detail {
class ServerSocketFdImpl : private IOCP::Callback {
public:
ServerSocketFdImpl(NativeFd fd, int socket_family) : info_(std::move(fd)), socket_family_(socket_family) {
VLOG(fd) << get_native_fd().io_handle() << " create ServerSocketFd";
VLOG(fd) << get_native_fd().socket() << " create ServerSocketFd";
IOCP::get()->subscribe(get_native_fd(), this);
notify_iocp_read();
}
@ -105,11 +105,11 @@ class ServerSocketFdImpl : private IOCP::Callback {
info_.set_native_fd({});
}
void on_read() {
VLOG(fd) << get_native_fd().io_handle() << " on_read";
VLOG(fd) << get_native_fd().socket() << " on_read";
if (is_read_active_) {
is_read_active_ = false;
auto r_socket = SocketFd::from_native_fd(std::move(accept_socket_));
VLOG(fd) << get_native_fd().io_handle() << " finish accept";
VLOG(fd) << get_native_fd().socket() << " finish accept";
if (r_socket.is_error()) {
return on_error(r_socket.move_as_error());
}
@ -125,7 +125,7 @@ class ServerSocketFdImpl : private IOCP::Callback {
CHECK(!is_read_active_);
accept_socket_ = NativeFd(socket(socket_family_, SOCK_STREAM, 0));
std::memset(&read_overlapped_, 0, sizeof(read_overlapped_));
VLOG(fd) << get_native_fd().io_handle() << " start accept";
VLOG(fd) << get_native_fd().socket() << " start accept";
BOOL status = AcceptEx(get_native_fd().socket(), accept_socket_.socket(), addr_buf_, 0, MAX_ADDR_SIZE,
MAX_ADDR_SIZE, nullptr, &read_overlapped_);
if (status == TRUE || check_status("Failed to accept connection")) {
@ -183,12 +183,12 @@ class ServerSocketFdImpl : private IOCP::Callback {
UNREACHABLE();
}
void notify_iocp_read() {
VLOG(fd) << get_native_fd().io_handle() << " notify_read";
VLOG(fd) << get_native_fd().socket() << " notify_read";
inc_refcnt();
IOCP::get()->post(0, this, nullptr);
}
void notify_iocp_close() {
VLOG(fd) << get_native_fd().io_handle() << " notify_close";
VLOG(fd) << get_native_fd().socket() << " notify_close";
IOCP::get()->post(0, this, reinterpret_cast<WSAOVERLAPPED *>(&close_overlapped_));
}
};

View File

@ -36,7 +36,7 @@ namespace detail {
class SocketFdImpl : private IOCP::Callback {
public:
explicit SocketFdImpl(NativeFd native_fd) : info(std::move(native_fd)) {
VLOG(fd) << get_native_fd().io_handle() << " create from native_fd";
VLOG(fd) << get_native_fd().socket() << " create from native_fd";
get_poll_info().add_flags(PollFlags::Write());
IOCP::get()->subscribe(get_native_fd(), this);
is_read_active_ = true;
@ -44,7 +44,7 @@ class SocketFdImpl : private IOCP::Callback {
}
SocketFdImpl(NativeFd native_fd, const IPAddress &addr) : info(std::move(native_fd)) {
VLOG(fd) << get_native_fd().io_handle() << " create from native_fd and connect";
VLOG(fd) << get_native_fd().socket() << " create from native_fd and connect";
get_poll_info().add_flags(PollFlags::Write());
IOCP::get()->subscribe(get_native_fd(), this);
LPFN_CONNECTEX ConnectExPtr = nullptr;
@ -232,7 +232,7 @@ class SocketFdImpl : private IOCP::Callback {
}
void on_error(Status status) {
VLOG(fd) << get_native_fd().io_handle() << " on error " << status;
VLOG(fd) << get_native_fd().socket() << " on error " << status;
{
auto lock = lock_.lock();
pending_errors_.push(std::move(status));
@ -241,7 +241,7 @@ class SocketFdImpl : private IOCP::Callback {
}
void on_connected() {
VLOG(fd) << get_native_fd().io_handle() << " on connected";
VLOG(fd) << get_native_fd().socket() << " on connected";
CHECK(!is_connected_);
CHECK(is_read_active_);
is_connected_ = true;
@ -251,7 +251,7 @@ class SocketFdImpl : private IOCP::Callback {
}
void on_read(size_t size) {
VLOG(fd) << get_native_fd().io_handle() << " on read " << size;
VLOG(fd) << get_native_fd().socket() << " on read " << size;
CHECK(is_read_active_);
is_read_active_ = false;
input_writer_.confirm_append(size);
@ -260,7 +260,7 @@ class SocketFdImpl : private IOCP::Callback {
}
void on_write(size_t size) {
VLOG(fd) << get_native_fd().io_handle() << " on write " << size;
VLOG(fd) << get_native_fd().socket() << " on write " << size;
if (size == 0) {
if (is_write_active_) {
return;
@ -274,12 +274,12 @@ class SocketFdImpl : private IOCP::Callback {
}
void on_close() {
VLOG(fd) << get_native_fd().io_handle() << " on close";
VLOG(fd) << get_native_fd().socket() << " on close";
close_flag_ = true;
info.set_native_fd({});
}
bool dec_refcnt() {
VLOG(fd) << get_native_fd().io_handle() << " dec_refcnt from " << refcnt_;
VLOG(fd) << get_native_fd().socket() << " dec_refcnt from " << refcnt_;
if (--refcnt_ == 0) {
delete this;
return true;
@ -289,7 +289,7 @@ class SocketFdImpl : private IOCP::Callback {
void inc_refcnt() {
CHECK(refcnt_ != 0);
refcnt_++;
VLOG(fd) << get_native_fd().io_handle() << " inc_refcnt to " << refcnt_;
VLOG(fd) << get_native_fd().socket() << " inc_refcnt to " << refcnt_;
}
void notify_iocp_write() {

View File

@ -272,7 +272,7 @@ class UdpSocketFdImpl : private IOCP::Callback {
}
void on_error(Status status) {
VLOG(fd) << get_native_fd().io_handle() << " on error " << status;
VLOG(fd) << get_native_fd().socket() << " on error " << status;
{
auto lock = lock_.lock();
pending_errors_.push(std::move(status));
@ -281,7 +281,7 @@ class UdpSocketFdImpl : private IOCP::Callback {
}
void on_connected() {
VLOG(fd) << get_native_fd().io_handle() << " on connected";
VLOG(fd) << get_native_fd().socket() << " on connected";
CHECK(!is_connected_);
CHECK(is_receive_active_);
is_connected_ = true;
@ -291,7 +291,7 @@ class UdpSocketFdImpl : private IOCP::Callback {
}
void on_receive(size_t size) {
VLOG(fd) << get_native_fd().io_handle() << " on receive " << size;
VLOG(fd) << get_native_fd().socket() << " on receive " << size;
CHECK(is_receive_active_);
is_receive_active_ = false;
receive_helper_.from_native(receive_message_, size, to_receive_);
@ -306,7 +306,7 @@ class UdpSocketFdImpl : private IOCP::Callback {
}
void on_send(size_t size) {
VLOG(fd) << get_native_fd().io_handle() << " on send " << size;
VLOG(fd) << get_native_fd().socket() << " on send " << size;
if (size == 0) {
if (is_send_active_) {
return;
@ -319,7 +319,7 @@ class UdpSocketFdImpl : private IOCP::Callback {
}
void on_close() {
VLOG(fd) << get_native_fd().io_handle() << " on close";
VLOG(fd) << get_native_fd().socket() << " on close";
close_flag_ = true;
info_.set_native_fd({});
}