summaryrefslogtreecommitdiff
path: root/src/network.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-01-18 21:46:03 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-01-19 21:44:22 +0100
commitec8ec7eb2a0b677f80f89834d955d1f0aa614538 (patch)
tree0c2a987f07bf89b2366e21b7fb081c110bd62cd2 /src/network.cpp
parent2abd6593c8b047d3fd579aa6cc0058bbebe266f8 (diff)
Shutdown server socket to terminate listener
Diffstat (limited to 'src/network.cpp')
-rw-r--r--src/network.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/network.cpp b/src/network.cpp
index bd64e07..eab0f67 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -189,6 +189,9 @@ Server::Priv::~Priv()
finish = true;
}
+ if (sock >= 0)
+ shutdown(sock, SHUT_RDWR);
+
announceCondvar.notify_all();
threadListen.join();
threadAnnounce.join();
@@ -212,6 +215,8 @@ void Server::Priv::doListen()
(sockaddr *) &paddr, &addrlen);
if (ret < 0)
throw std::system_error(errno, std::generic_category());
+ if (ret == 0)
+ break;
buf.resize(ret);
auto & peer = getPeer(paddr);