projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactoring
[invirt/third/libt4.git]
/
rpc
/
connection.h
diff --git
a/rpc/connection.h
b/rpc/connection.h
index
b1df8a1
..
97bacbb
100644
(file)
--- a/
rpc/connection.h
+++ b/
rpc/connection.h
@@
-4,7
+4,7
@@
#include "types.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include "types.h"
#include <arpa/inet.h>
#include <netinet/in.h>
-#include "pollmgr.h"
+#include "poll_mgr.h"
#include "file.h"
constexpr size_t size_t_max = numeric_limits<size_t>::max();
#include "file.h"
constexpr size_t size_t_max = numeric_limits<size_t>::max();
@@
-13,10
+13,10
@@
class thread_exit_exception : exception {};
class connection;
class connection;
-class chanmgr {
+class connection_delegate {
public:
virtual bool got_pdu(const shared_ptr<connection> & c, const string & b) = 0;
public:
virtual bool got_pdu(const shared_ptr<connection> & c, const string & b) = 0;
- virtual ~chanmgr() {}
+ virtual ~connection_delegate() {}
};
class connection : public aio_callback, public enable_shared_from_this<connection> {
};
class connection : public aio_callback, public enable_shared_from_this<connection> {
@@
-26,7
+26,7
@@
class connection : public aio_callback, public enable_shared_from_this<connectio
size_t solong = 0; // number of bytes written or read so far
};
size_t solong = 0; // number of bytes written or read so far
};
- connection(chanmgr *m1, int f1, int lossytest=0);
+ connection(connection_delegate *m1, socket_t && f1, int lossytest=0);
~connection();
int channo() { return fd_; }
~connection();
int channo() { return fd_; }
@@
-39,12
+39,14
@@
class connection : public aio_callback, public enable_shared_from_this<connectio
time_point<steady_clock> create_time() const { return create_time_; }
time_point<steady_clock> create_time() const { return create_time_; }
+ static shared_ptr<connection> to_dst(const sockaddr_in &dst, connection_delegate *mgr, int lossy=0);
+
private:
bool readpdu();
bool writepdu();
private:
bool readpdu();
bool writepdu();
- chanmgr *mgr_;
+ connection_delegate *mgr_;
const file_t fd_;
bool dead_ = false;
const file_t fd_;
bool dead_ = false;
@@
-63,7
+65,7
@@
class connection : public aio_callback, public enable_shared_from_this<connectio
class tcpsconn {
public:
class tcpsconn {
public:
- tcpsconn(chanmgr *m1, in_port_t port, int lossytest=0);
+ tcpsconn(connection_delegate *m1, in_port_t port, int lossytest=0);
~tcpsconn();
inline in_port_t port() { return port_; }
void accept_conn();
~tcpsconn();
inline in_port_t port() { return port_; }
void accept_conn();
@@
-74,19
+76,10
@@
class tcpsconn {
file_t pipe_[2];
socket_t tcp_; // listens for connections
file_t pipe_[2];
socket_t tcp_; // listens for connections
- chanmgr *mgr_;
+ connection_delegate *mgr_;
int lossy_;
map<int, shared_ptr<connection>> conns_;
void process_accept();
};
int lossy_;
map<int, shared_ptr<connection>> conns_;
void process_accept();
};
-
-struct bundle {
- bundle(chanmgr *m, int s, int l):mgr(m),tcp(s),lossy(l) {}
- chanmgr *mgr;
- int tcp;
- int lossy;
-};
-
-shared_ptr<connection> connect_to_dst(const sockaddr_in &dst, chanmgr *mgr, int lossy=0);
#endif
#endif