X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/02967a43024ce81912cd1ec96a800397457f8066..refs/heads/iannucci:/rpc/connection.cc diff --git a/rpc/connection.cc b/rpc/connection.cc index 8966cc2..7a6371a 100644 --- a/rpc/connection.cc +++ b/rpc/connection.cc @@ -1,10 +1,10 @@ -#include "connection.h" -#include "rpc_protocol.h" +#include "include/rpc/connection.h" +#include "include/rpc/rpc_protocol.h" #include #include #include #include -#include "marshall.h" +#include "include/rpc/marshall.h" connection_delegate::~connection_delegate() {} @@ -24,13 +24,12 @@ connection::~connection() { if (dead_) return; dead_ = true; - shutdown(fd,SHUT_RDWR); + fd.shutdown(SHUT_RDWR); } // after block_remove_fd, select will never wait on fd and no callbacks // will be active global->shared_mgr.block_remove_fd(fd); - VERIFY(dead_); - VERIFY(wpdu_.status == unused); + VERIFY(dead_ && wpdu_.status == unused); } shared_ptr connection::to_dst(const sockaddr_in & dst, connection_delegate * delegate, int lossy) { @@ -58,7 +57,7 @@ bool connection::send(const string & b) { if (std::bernoulli_distribution(lossy_*.01)(global->random_generator)) { IF_LEVEL(1) LOG << "send LOSSY TEST shutdown fd " << fd; - shutdown(fd,SHUT_RDWR); + fd.shutdown(SHUT_RDWR); } if (!writepdu()) { @@ -103,7 +102,7 @@ bool connection::writepdu() { if (wpdu_.cursor == wpdu_.buf.size()) return true; - ssize_t n = write(fd, &wpdu_.buf[wpdu_.cursor], (wpdu_.buf.size()-wpdu_.cursor)); + ssize_t n = fd.write(&wpdu_.buf[wpdu_.cursor], (wpdu_.buf.size()-wpdu_.cursor)); if (n < 0) { if (errno != EAGAIN) { IF_LEVEL(1) LOG << "writepdu fd " << fd << " failure errno=" << errno; @@ -189,8 +188,8 @@ bool connection::readpdu() { connection_listener::connection_listener(connection_delegate * delegate, in_port_t port, int lossytest) : tcp_(socket(AF_INET, SOCK_STREAM, 0)), delegate_(delegate), lossy_(lossytest) { - tcp_.setsockopt(SOL_SOCKET, SO_REUSEADDR, (int)1); - tcp_.setsockopt(IPPROTO_TCP, TCP_NODELAY, (int)1); + tcp_.setsockopt(SOL_SOCKET, SO_REUSEADDR, int{1}); + tcp_.setsockopt(IPPROTO_TCP, TCP_NODELAY, int{1}); tcp_.setsockopt(SOL_SOCKET, SO_RCVTIMEO, timeval{0, 50000}); tcp_.setsockopt(SOL_SOCKET, SO_SNDTIMEO, timeval{0, 50000});