Skip to content

Commit

Permalink
Remove the socket file when CTRL-C the vineyardd instance (#1643)
Browse files Browse the repository at this point in the history
Fixes #1625

Signed-off-by: Tao He <[email protected]>
  • Loading branch information
sighingnow authored Dec 12, 2023
1 parent 067235c commit 528ca69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/server/async/socket_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1720,14 +1720,19 @@ void SocketServer::Stop() {
if (stopped_.exchange(true)) {
return;
}
// stop accepting further connections
this->Close();

std::lock_guard<std::recursive_mutex> scope_lock(this->connections_mutex_);
std::vector<int> connection_ids_;
for (auto& pair : connections_) {
pair.second->Stop();
}
connections_.clear();
}

void SocketServer::Close() { closable_.store(true); }

bool SocketServer::ExistsConnection(int conn_id) const {
std::lock_guard<std::recursive_mutex> scope_lock(this->connections_mutex_);
return connections_.find(conn_id) != connections_.end();
Expand Down
2 changes: 1 addition & 1 deletion src/server/async/socket_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class SocketServer {
* Cancel the "async_accept" action on the acceptor to stop accepting
* further connections.
*/
virtual void Close() { closable_.store(true); }
virtual void Close();

/**
* Check if @conn_id@ exists in the connection pool.
Expand Down

0 comments on commit 528ca69

Please sign in to comment.