MXS-2710: Move client_count handling into client DCB
Due to the fact that both client connections and listeners use sessions in 2.3, the client_count tracking must be done inside the client DCB. In addition to this, the max_connections check didn't take the current pending connection into account which caused an off-by-one error. This commit fixes the connection_limit test failure that was introduced by commit 6306519e5e75575ba083ee2f0edfe7e624da5d26.
This commit is contained in:
@ -336,23 +336,6 @@ void session_close(MXS_SESSION* session)
|
||||
}
|
||||
}
|
||||
|
||||
class ServiceDestroyTask : public Worker::DisposableTask
|
||||
{
|
||||
public:
|
||||
ServiceDestroyTask(Service* service)
|
||||
: m_service(service)
|
||||
{
|
||||
}
|
||||
|
||||
void execute(Worker& worker) override
|
||||
{
|
||||
service_free(m_service);
|
||||
}
|
||||
|
||||
private:
|
||||
Service* m_service;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deallocate the specified session
|
||||
*
|
||||
@ -1253,7 +1236,6 @@ Session::Session(SERVICE* service)
|
||||
|
||||
mxb::atomic::add(&service->stats.n_current, 1, mxb::atomic::RELAXED);
|
||||
mxb_assert(service->stats.n_current >= 0);
|
||||
mxb::atomic::add(&service->client_count, 1, mxb::atomic::RELAXED);
|
||||
}
|
||||
|
||||
Session::~Session()
|
||||
@ -1271,17 +1253,6 @@ Session::~Session()
|
||||
|
||||
mxb::atomic::add(&service->stats.n_current, -1, mxb::atomic::RELAXED);
|
||||
mxb_assert(service->stats.n_current >= 0);
|
||||
|
||||
bool should_destroy = !mxb::atomic::load(&service->active);
|
||||
|
||||
if (mxb::atomic::add(&service->client_count, -1) == 1 && should_destroy)
|
||||
{
|
||||
// Destroy the service in the main routing worker thread
|
||||
mxs::RoutingWorker* main_worker = mxs::RoutingWorker::get(mxs::RoutingWorker::MAIN);
|
||||
main_worker->execute(
|
||||
std::unique_ptr<ServiceDestroyTask>(new ServiceDestroyTask(static_cast<Service*>(service))),
|
||||
Worker::EXECUTE_AUTO);
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
|
Reference in New Issue
Block a user