diff --git a/.gitignore b/.gitignore index 6500b0cb..68783d7a 100755 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 +m4/pkg.m4 diff --git a/src/fs/dfsrm.cc b/src/fs/dfsrm.cc index 9e8a10da..014a8167 100644 --- a/src/fs/dfsrm.cc +++ b/src/fs/dfsrm.cc @@ -98,6 +98,8 @@ int main(int argc, char* argv[]) send_message(socket, &fr); auto fd = read_fd(socket); + socket->close(); + delete socket; unsigned int block_seq = 0; for (auto block_name : fd->nodes) { @@ -110,19 +112,29 @@ int main(int argc, char* argv[]) auto msg = read_reply(tmp_socket); if (msg->message != "OK") { cerr << "[ERROR]: block " << block_name << "doesn't exist" << endl; + delete msg; return EXIT_FAILURE; } + delete msg; + tmp_socket->close(); + delete tmp_socket; } + delete fd; FileDel file_del; file_del.file_name = file_name; + socket = connect(file_hash_key); send_message(socket, &file_del); auto reply = read_reply(socket); if (reply->message != "OK") { cerr << "[ERROR]: file " << file_name << " does not exist" << endl; + delete reply; return EXIT_FAILURE; } + delete reply; + socket->close(); + delete socket; /* if (reply->message != "OK") { { diff --git a/src/network/server.cc b/src/network/server.cc index 1b58ca56..fbd19bed 100644 --- a/src/network/server.cc +++ b/src/network/server.cc @@ -24,6 +24,7 @@ void Server::do_connect () { // }}} // on_accept {{{ void Server::on_accept (tcp::socket* sock) { + if (server != nullptr) delete server; server = sock; do_read(); } @@ -89,6 +90,8 @@ void Server::read_coroutine (yield_context yield) { if (ec == boost::asio::error::eof) { logger->info ("Closing server socket to client"); server->close(); + delete server; + server = nullptr; node->on_disconnect(); } else { logger->info ("Message arrived error=%s", diff --git a/src/network/server.hh b/src/network/server.hh index 2196a2a1..2698d4e1 100644 --- a/src/network/server.hh +++ b/src/network/server.hh @@ -26,7 +26,7 @@ class Server: public AsyncChannel { void do_read (); void read_coroutine (boost::asio::yield_context); - tcp::socket *server; + tcp::socket *server = nullptr; tcp::endpoint* endpoint = nullptr; };