mirror of
https://github.com/oatpp/oatpp.git
synced 2025-04-18 19:00:23 +08:00
Lockguards around m_connectionProvider->get()
This commit is contained in:
parent
dbab5a7acc
commit
d14dd5be90
@ -50,9 +50,11 @@ void Server::conditionalMainLoop() {
|
||||
|
||||
while (getStatus() == STATUS_RUNNING) {
|
||||
if (m_condition()) {
|
||||
m_spinlock.lock();
|
||||
auto connection = m_connectionProvider->get();
|
||||
m_spinlock.unlock();
|
||||
std::shared_ptr<data::stream::IOStream> connection;
|
||||
{
|
||||
std::lock_guard<oatpp::concurrency::SpinLock> lg(m_spinlock);
|
||||
connection = m_connectionProvider->get();
|
||||
}
|
||||
if (connection) {
|
||||
if (getStatus() == STATUS_RUNNING) {
|
||||
if (m_condition()) {
|
||||
@ -77,9 +79,11 @@ void Server::mainLoop(Server *instance) {
|
||||
std::shared_ptr<const std::unordered_map<oatpp::String, oatpp::String>> params;
|
||||
|
||||
while (instance->getStatus() == STATUS_RUNNING) {
|
||||
instance->m_spinlock.lock();
|
||||
auto connection = instance->m_connectionProvider->get();
|
||||
instance->m_spinlock.unlock();
|
||||
std::shared_ptr<data::stream::IOStream> connection;
|
||||
{
|
||||
std::lock_guard<oatpp::concurrency::SpinLock> lg(instance->m_spinlock);
|
||||
connection = instance->m_connectionProvider->get();
|
||||
}
|
||||
|
||||
if (connection) {
|
||||
if (instance->getStatus() == STATUS_RUNNING) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user