X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/ebd5aef6dc92accb509b1cc67eaf72159f35cdfa..eb3d5c6416c0f0d1cad35e52af3231de7866fea8:/rpc/connection.cc diff --git a/rpc/connection.cc b/rpc/connection.cc index c4edbf6..c2635ef 100644 --- a/rpc/connection.cc +++ b/rpc/connection.cc @@ -37,11 +37,11 @@ shared_ptr connection::to_dst(const sockaddr_in & dst, connection_de socket_t s = socket(AF_INET, SOCK_STREAM, 0); s.setsockopt(IPPROTO_TCP, TCP_NODELAY, (int)1); if (connect(s, (sockaddr*)&dst, sizeof(dst)) < 0) { - IF_LEVEL(1) LOG_NONMEMBER("failed to " << inet_ntoa(dst.sin_addr) << ":" << ntoh(dst.sin_port)); + IF_LEVEL(1) LOG_NONMEMBER << "failed to " << inet_ntoa(dst.sin_addr) << ":" << ntoh(dst.sin_port); close(s); return nullptr; } - IF_LEVEL(2) LOG_NONMEMBER("connection::to_dst fd=" << s << " to dst " << inet_ntoa(dst.sin_addr) << ":" << ntoh(dst.sin_port)); + IF_LEVEL(2) LOG_NONMEMBER << "connection::to_dst fd=" << s << " to dst " << inet_ntoa(dst.sin_addr) << ":" << ntoh(dst.sin_port); return make_shared(delegate, move(s), lossy); } @@ -61,7 +61,7 @@ bool connection::send(const string & b) { if (lossy_) { if ((random()%100) < lossy_) { - IF_LEVEL(1) LOG("send LOSSY TEST shutdown fd " << fd); + IF_LEVEL(1) LOG << "send LOSSY TEST shutdown fd " << fd; shutdown(fd,SHUT_RDWR); } } @@ -113,11 +113,11 @@ void connection::read_cb(int s) { if (dead_) return; - IF_LEVEL(5) LOG("got data on fd " << s); + IF_LEVEL(5) LOG << "got data on fd " << s; if (!rpdu_.buf.size() || rpdu_.solong < rpdu_.buf.size()) { if (!readpdu()) { - IF_LEVEL(5) LOG("readpdu on fd " << s << " failed; dying"); + IF_LEVEL(5) LOG << "readpdu on fd " << s << " failed; dying"; poll_mgr::shared_mgr.del_callback(fd, CB_RDWR); dead_ = true; send_complete_.notify_one(); @@ -141,7 +141,7 @@ bool connection::writepdu() { ssize_t n = write(fd, &wpdu_.buf[wpdu_.solong], (wpdu_.buf.size()-wpdu_.solong)); if (n < 0) { if (errno != EAGAIN) { - IF_LEVEL(1) LOG("writepdu fd " << fd << " failure errno=" << errno); + IF_LEVEL(1) LOG << "writepdu fd " << fd << " failure errno=" << errno; wpdu_.solong = size_t_max; wpdu_.buf.clear(); } @@ -152,7 +152,7 @@ bool connection::writepdu() { } bool connection::readpdu() { - IF_LEVEL(5) LOG("the receive buffer has length " << rpdu_.buf.size()); + IF_LEVEL(5) LOG << "the receive buffer has length " << rpdu_.buf.size(); if (!rpdu_.buf.size()) { rpc_protocol::rpc_sz_t sz1; ssize_t n = fd.read(sz1); @@ -166,18 +166,18 @@ bool connection::readpdu() { } if (n > 0 && n != sizeof(sz1)) { - IF_LEVEL(0) LOG("short read of sz"); + IF_LEVEL(0) LOG << "short read of sz"; return false; } size_t sz = ntoh(sz1); if (sz > rpc_protocol::MAX_PDU) { - IF_LEVEL(2) LOG("read pdu TOO BIG " << sz << " network order=" << hex << sz1); + IF_LEVEL(2) LOG << "read pdu TOO BIG " << sz << " network order=" << hex << sz1; return false; } - IF_LEVEL(5) LOG("read size of datagram = " << sz); + IF_LEVEL(5) LOG << "read size of datagram = " << sz; rpdu_.buf.assign(sz+sizeof(sz1), 0); rpdu_.solong = sizeof(sz1); @@ -185,7 +185,7 @@ bool connection::readpdu() { ssize_t n = fd.read(&rpdu_.buf[rpdu_.solong], rpdu_.buf.size() - rpdu_.solong); - IF_LEVEL(5) LOG("read " << n << " bytes"); + IF_LEVEL(5) LOG << "read " << n << " bytes"; if (n <= 0) { if (errno == EAGAIN) @@ -224,7 +224,7 @@ connection_listener::connection_listener(connection_delegate * delegate, in_port VERIFY(getsockname(tcp_, (sockaddr *)&sin, &addrlen) == 0); port_ = ntoh(sin.sin_port); - IF_LEVEL(2) LOG("listen on " << port_ << " " << sin.sin_port); + IF_LEVEL(2) LOG << "listen on " << port_ << " " << sin.sin_port; poll_mgr::shared_mgr.add_callback(tcp_, CB_RDONLY, this); } @@ -242,7 +242,7 @@ void connection_listener::read_cb(int) { throw runtime_error("connection listener failure"); } - IF_LEVEL(2) LOG("accept_loop got connection fd=" << s1 << " " << inet_ntoa(sin.sin_addr) << ":" << ntoh(sin.sin_port)); + IF_LEVEL(2) LOG << "accept_loop got connection fd=" << s1 << " " << inet_ntoa(sin.sin_addr) << ":" << ntoh(sin.sin_port); auto ch = make_shared(delegate_, s1, lossy_); // garbage collect dead connections