-#include "connection.h"
-#include "rpc_protocol.h"
+#include "include/rpc/connection.h"
+#include "include/rpc/rpc_protocol.h"
#include <cerrno>
#include <csignal>
#include <netinet/tcp.h>
#include <unistd.h>
-#include "marshall.h"
+#include "include/rpc/marshall.h"
connection_delegate::~connection_delegate() {}
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> connection::to_dst(const sockaddr_in & dst, connection_delegate * delegate, int lossy) {
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()) {
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;
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});