From b84b00cb9d17a51b2667716229dd3ecde756b709 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 21 Nov 2018 23:34:31 -0500 Subject: fix minor bugs --- include/salticidae/network.h | 10 ++++------ src/util.cpp | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/salticidae/network.h b/include/salticidae/network.h index 0a0ccb9..0f7ed7d 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -505,7 +505,7 @@ void PeerNetwork::Conn::on_teardown() { if (this != p->conn.get()) return; p->ev_ping_timer.del(); p->connected = false; - p->conn = nullptr; + //p->conn = nullptr; SALTICIDAE_LOG_INFO("connection lost: %s", std::string(*this).c_str()); // try to reconnect p->ev_retry_timer = TimerEvent(pn->disp_ec, @@ -603,7 +603,7 @@ void PeerNetwork::start_active_conn(const NetAddr &addr) { auto p = id2peer.find(addr)->second.get(); if (p->connected) return; auto conn = static_pointer_cast(MsgNet::_connect(addr)); - assert(p->conn == nullptr); + //assert(p->conn == nullptr); p->conn = conn; conn->peer_id = addr; if (id_mode == IP_BASED) @@ -714,7 +714,6 @@ void ClientNetwork::Conn::on_setup() { template void ClientNetwork::Conn::on_teardown() { MsgNet::Conn::on_teardown(); - assert(this->get_mode() == Conn::PASSIVE); get_net()->addr2conn.erase(this->get_addr()); } @@ -724,9 +723,8 @@ void ClientNetwork::send_msg(MsgType &&msg, const NetAddr &addr) { this->disp_tcall->async_call( [this, addr, msg=std::forward(msg)](ThreadCall::Handle &) { auto it = addr2conn.find(addr); - if (it == addr2conn.end()) - throw PeerNetworkError("client does not exist"); - send_msg(msg, it->second); + if (it != addr2conn.end()) + send_msg(msg, it->second); }); } diff --git a/src/util.cpp b/src/util.cpp index 2a6a381..a0d5044 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -236,6 +236,7 @@ bool Config::load(const std::string &fname) { } update(optname, optval.c_str()); } + fclose(conf_f); return true; } else -- cgit v1.2.3-70-g09d2