You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i have an endpoint that calls the bellow function, if a don't use the mutex, the service stops, all subsequent calls to the database freezes (the rest works). If i do multiple calls to the database inside the same methods they are not thread-safe ?
I tested using Apache benchmark using two connections (ab -n 300 -c2 .....).
oatpp::Object<AdminRoomsProgrammingDto> AdminServices::getRoomProgrammingById(const oatpp::UInt32 &whitelabelid,
const oatpp::UInt32 &roomid,
const oatpp::UInt32 &id, int &error)
{
std::lock_guard<std::mutex> lock(dbMutex); <==
auto programming = oatpp::Object<AdminRoomsProgrammingDto>::createShared();
error = 0;
try {
auto dbResult = m_database->getRoomProgrammingById(whitelabelid, roomid, id);
if (dbResult != nullptr && dbResult->isSuccess())
{
auto items = dbResult->fetch<oatpp::Vector<oatpp::Object<AdminRoomsProgrammingDto>>>();
if (items != nullptr && !items->empty())
{
programming = items[0];
auto dbItem = m_database->getAdminRoomProgrammingDetail(whitelabelid, roomid, programming->programmingid);
if (dbItem->isSuccess())
{
auto dbItems = dbItem->fetch<oatpp::Vector<oatpp::Object<AdminRoomDetailDto>>>();
programming->matchprizes = dbItems;
}
auto dbAc = m_database->getRoomProgrammingAc(whitelabelid, roomid, programming->programmingid);
if (dbAc->isSuccess())
{
auto dbAcItems = dbAc->fetch<oatpp::Vector<oatpp::Object<AcItemDto>>>();
if (dbAcItems->size() > 0)
{
programming->acitem = dbAcItems[0];
}
}
}
} else {
error = -2;
}
} catch (const std::exception &e) {
error = -1;
OATPP_LOGD("SERVICES", "%s", e.what());
} catch (...) {
error = -1;
OATPP_LOGD("SERVICES","Unknow exception");
}
return programming;
}
The text was updated successfully, but these errors were encountered:
Hi, i have an endpoint that calls the bellow function, if a don't use the mutex, the service stops, all subsequent calls to the database freezes (the rest works). If i do multiple calls to the database inside the same methods they are not thread-safe ?
I tested using Apache benchmark using two connections (ab -n 300 -c2 .....).
The text was updated successfully, but these errors were encountered: