diff options
author | Determinant <[email protected]> | 2019-06-30 17:02:36 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-30 17:02:36 -0400 |
commit | 624550d7e1c032a4d3896ba002aa3ecb895f447c (patch) | |
tree | b33237e20176a03c8963b2185226e05838a62fab | |
parent | a53ae6b6ff2faa7fa1d54b3eb662dcfb3591d8ef (diff) |
...
-rw-r--r-- | include/salticidae/network.h | 1 | ||||
-rw-r--r-- | src/netaddr.cpp | 1 | ||||
-rw-r--r-- | src/network.cpp | 4 | ||||
-rw-r--r-- | test/bench_network.cpp | 7 | ||||
-rw-r--r-- | test/bench_network_tls.cpp | 7 |
5 files changed, 10 insertions, 10 deletions
diff --git a/include/salticidae/network.h b/include/salticidae/network.h index d83e7f1..467fe6a 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -1241,6 +1241,7 @@ msgnetwork_t *msgnetwork_conn_get_net(const msgnetwork_conn_t *conn); msgnetwork_conn_mode_t msgnetwork_conn_get_mode(const msgnetwork_conn_t *conn); const netaddr_t *msgnetwork_conn_get_addr(const msgnetwork_conn_t *conn); const x509_t *msgnetwork_conn_get_peer_cert(const msgnetwork_conn_t *conn); +bool msgnetwork_conn_is_terminated(const msgnetwork_conn_t *conn); /* PeerNetwork */ diff --git a/src/netaddr.cpp b/src/netaddr.cpp index 736d606..96bdaf9 100644 --- a/src/netaddr.cpp +++ b/src/netaddr.cpp @@ -48,6 +48,7 @@ uint16_t netaddr_get_port(const netaddr_t *self) { return self->port; } netaddr_array_t *netaddr_array_new() { return new netaddr_array_t(); } netaddr_array_t *netaddr_array_new_from_addrs(const netaddr_t * const *addrs, size_t naddrs) { auto res = new netaddr_array_t(); + res->resize(naddrs); for (size_t i = 0; i < naddrs; i++) (*res)[i] = *addrs[i]; return res; diff --git a/src/network.cpp b/src/network.cpp index e604eaa..05e7b50 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -155,6 +155,10 @@ const x509_t *msgnetwork_conn_get_peer_cert(const msgnetwork_conn_t *conn) { return (*conn)->get_peer_cert(); } +bool msgnetwork_conn_is_terminated(const msgnetwork_conn_t *conn) { + return (*conn)->is_terminated(); +} + // PeerNetwork peernetwork_config_t *peernetwork_config_new() { diff --git a/test/bench_network.cpp b/test/bench_network.cpp index ed2642a..82c6268 100644 --- a/test/bench_network.cpp +++ b/test/bench_network.cpp @@ -71,7 +71,6 @@ using MsgNetworkByteOp = MsgNetwork<opcode_t>; struct MyNet: public MsgNetworkByteOp { const std::string name; - const NetAddr peer; TimerEvent ev_period_stat; ThreadCall tcall; size_t nrecv; @@ -79,12 +78,10 @@ struct MyNet: public MsgNetworkByteOp { MyNet(const salticidae::EventContext &ec, const std::string name, - const NetAddr &peer, double stat_timeout = -1): MsgNetworkByteOp(ec, MsgNetworkByteOp::Config( ConnPool::Config().queue_capacity(65536)).burst_size(1000)), name(name), - peer(peer), ev_period_stat(ec, [this, stat_timeout](TimerEvent &) { SALTICIDAE_LOG_INFO("%.2f mps", nrecv / (double)stat_timeout); fflush(stderr); @@ -134,13 +131,13 @@ NetAddr alice_addr("127.0.0.1:1234"); NetAddr bob_addr("127.0.0.1:1235"); int main() { - salticidae::BoxObj<MyNet> alice = new MyNet(ec, "Alice", bob_addr, 10); + salticidae::BoxObj<MyNet> alice = new MyNet(ec, "Alice", 10); alice->start(); alice->listen(alice_addr); salticidae::EventContext tec; salticidae::BoxObj<ThreadCall> tcall = new ThreadCall(tec); std::thread bob_thread([&tec]() { - MyNet bob(tec, "Bob", alice_addr); + MyNet bob(tec, "Bob"); bob.start(); bob.connect(alice_addr); try { diff --git a/test/bench_network_tls.cpp b/test/bench_network_tls.cpp index 89e39a8..2827a99 100644 --- a/test/bench_network_tls.cpp +++ b/test/bench_network_tls.cpp @@ -71,7 +71,6 @@ using MsgNetworkByteOp = MsgNetwork<opcode_t>; struct MyNet: public MsgNetworkByteOp { const std::string name; - const NetAddr peer; TimerEvent ev_period_stat; ThreadCall tcall; size_t nrecv; @@ -79,7 +78,6 @@ struct MyNet: public MsgNetworkByteOp { MyNet(const salticidae::EventContext &ec, const std::string name, - const NetAddr &peer, double stat_timeout = -1): MsgNetworkByteOp(ec, MsgNetworkByteOp::Config( ConnPool::Config() @@ -88,7 +86,6 @@ struct MyNet: public MsgNetworkByteOp { .tls_cert_file("alice.pem") .tls_key_file("alice.pem")).burst_size(1000)), name(name), - peer(peer), ev_period_stat(ec, [this, stat_timeout](TimerEvent &) { SALTICIDAE_LOG_INFO("%.2f mps", nrecv / (double)stat_timeout); fflush(stderr); @@ -138,13 +135,13 @@ NetAddr alice_addr("127.0.0.1:1234"); NetAddr bob_addr("127.0.0.1:1235"); int main() { - salticidae::BoxObj<MyNet> alice = new MyNet(ec, "Alice", bob_addr, 10); + salticidae::BoxObj<MyNet> alice = new MyNet(ec, "Alice", 10); alice->start(); alice->listen(alice_addr); salticidae::EventContext tec; salticidae::BoxObj<ThreadCall> tcall = new ThreadCall(tec); std::thread bob_thread([&tec]() { - MyNet bob(tec, "Bob", alice_addr); + MyNet bob(tec, "Bob"); bob.start(); bob.connect(alice_addr); try { |