Skip to content

Commit

Permalink
rpc: remove connections from a container during server shutdown
Browse files Browse the repository at this point in the history
Current logic that prevent it is not needed since parallel_for_each runs
on an entire container before relinquish control during server shutdown,
so there is no problem invalidating iterators.
  • Loading branch information
Gleb Natapov committed Jul 21, 2016
1 parent e37e065 commit d6296a9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 0 additions & 2 deletions rpc/rpc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ public:
resource_limits _limits;
semaphore _resources_available;
std::unordered_set<lw_shared_ptr<connection>> _conns;
bool _stopping = false;
promise<> _ss_stopped;
seastar::gate _reply_gate;
server_options _options;
Expand All @@ -314,7 +313,6 @@ public:
server(protocol& proto, server_options opts, server_socket, resource_limits memory_limit = resource_limits());
void accept();
future<> stop() {
_stopping = true; // prevents closed connections to be deleted from _conns
_ss.abort_accept();
_ss = server_socket();
_resources_available.broken();
Expand Down
6 changes: 1 addition & 5 deletions rpc/rpc_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,7 @@ future<> protocol<Serializer, MsgType>::server::connection::process() {
this->_error = true;
return this->stop_send_loop().then_wrapped([this] (future<> f) {
f.ignore_ready_future();
if (!this->_server._stopping) {
// if server is stopping do not remove connection
// since it may invalidate _conns iterators
this->_server._conns.erase(this->shared_from_this());
}
this->_server._conns.erase(this->shared_from_this());
this->_stopped.set_value();
});
}).finally([conn_ptr = this->shared_from_this()] {
Expand Down

0 comments on commit d6296a9

Please sign in to comment.