From 50bc94cadd854846cab83645dea2de5722bd4340 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 26 Nov 2025 15:40:19 +0100 Subject: [PATCH] MT#62868 Fix order of execution of Option Some options should be defined only before the connection to the database has been established. Change-Id: I91e3f0b2dfe46ac5f309548f33e3843c09f49ef0 --- apps/conference/Conference.cpp | 10 +++++++++- apps/dsm/mods/mod_mysql/ModMysql.cpp | 3 +-- apps/early_announce/EarlyAnnounce.cpp | 10 +++++++++- apps/voicemail/AnswerMachine.cpp | 10 +++++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/apps/conference/Conference.cpp b/apps/conference/Conference.cpp index 2393c9f5..9cde43b2 100644 --- a/apps/conference/Conference.cpp +++ b/apps/conference/Conference.cpp @@ -34,6 +34,8 @@ #include "AmMediaProcessor.h" #include "ampi/MonitoringAPI.h" +#include "DBUtils.h" + #include "sems.h" #include "log.h" @@ -199,7 +201,13 @@ int ConferenceFactory::onLoad() #ifdef VERSION2 Connection.set_option(Connection.opt_reconnect, true); #else - Connection.set_option(new mysqlpp::ReconnectOption(true)); + apply_mysql_options( + Connection, + dbReconnectOption, + dbConnectTimeoutOption(5), + dbReadTimeoutOption(5), + dbWriteTimeoutOption(5) + ); #endif if (!mysql_ca_cert.empty()) Connection.set_option( diff --git a/apps/dsm/mods/mod_mysql/ModMysql.cpp b/apps/dsm/mods/mod_mysql/ModMysql.cpp index 8438074f..f4fb59b0 100644 --- a/apps/dsm/mods/mod_mysql/ModMysql.cpp +++ b/apps/dsm/mods/mod_mysql/ModMysql.cpp @@ -28,7 +28,6 @@ #include "ModMysql.h" #include "log.h" #include "AmUtils.h" -#include "DBUtils.h" #include "DSMSession.h" #include "AmSession.h" @@ -111,7 +110,7 @@ mysqlpp::Connection* getMyDSMSessionConnection(DSMSession* sc_sess) { sc_sess->SET_STRERROR("No connection to database (not mysqlpp::Connection)"); return NULL; } - apply_mysql_options(*res, dbConnectTimeoutOption(5), dbReadTimeoutOption(5), dbWriteTimeoutOption(5)); + return res; } diff --git a/apps/early_announce/EarlyAnnounce.cpp b/apps/early_announce/EarlyAnnounce.cpp index 3ca53d36..6efd246d 100644 --- a/apps/early_announce/EarlyAnnounce.cpp +++ b/apps/early_announce/EarlyAnnounce.cpp @@ -28,6 +28,8 @@ #include "AmConfig.h" #include "AmUtils.h" +#include "DBUtils.h" + #include "sems.h" #include "log.h" @@ -213,7 +215,13 @@ int EarlyAnnounceFactory::onLoad() #ifdef VERSION2 Connection.set_option(Connection.opt_reconnect, true); #else - Connection.set_option(new mysqlpp::ReconnectOption(true)); + apply_mysql_options( + Connection, + dbReconnectOption, + dbConnectTimeoutOption(5), + dbReadTimeoutOption(5), + dbWriteTimeoutOption(5) + ); #endif if (!mysql_ca_cert.empty()) Connection.set_option( diff --git a/apps/voicemail/AnswerMachine.cpp b/apps/voicemail/AnswerMachine.cpp index 5190bb8f..407e7eee 100644 --- a/apps/voicemail/AnswerMachine.cpp +++ b/apps/voicemail/AnswerMachine.cpp @@ -32,6 +32,8 @@ #include "AmPlugIn.h" #include "AmPlaylist.h" +#include "DBUtils.h" + #include "../msg_storage/MsgStorageAPI.h" #include "sems.h" #include "log.h" @@ -413,13 +415,19 @@ int AnswerMachineFactory::onLoad() try { + apply_mysql_options( + Connection, + dbReconnectOption, + dbConnectTimeoutOption(5), + dbReadTimeoutOption(5), + dbWriteTimeoutOption(5) + ); Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { ERROR("Database connection failed: %s\n", Connection.error()); return -1; } - Connection.set_option(mysqlpp::Connection::opt_reconnect, true); } catch (const mysqlpp::Exception& er) {