diff --git a/shared_memory/base_data.cpp b/shared_memory/base_data.cpp index 086256cda..fae152b8b 100644 --- a/shared_memory/base_data.cpp +++ b/shared_memory/base_data.cpp @@ -24,6 +24,7 @@ #include "../common/eqemu_exception.h" void LoadBaseData(SharedDatabase *database) { + _eqp EQEmu::IPCMutex mutex("base_data"); mutex.Lock(); int records = (database->GetMaxBaseDataLevel() + 1); diff --git a/shared_memory/items.cpp b/shared_memory/items.cpp index 48b81b6fc..41cd63449 100644 --- a/shared_memory/items.cpp +++ b/shared_memory/items.cpp @@ -25,6 +25,7 @@ #include "../common/item_struct.h" void LoadItems(SharedDatabase *database) { + _eqp EQEmu::IPCMutex mutex("items"); mutex.Lock(); diff --git a/shared_memory/loot.cpp b/shared_memory/loot.cpp index 66982c05a..8562d62c7 100644 --- a/shared_memory/loot.cpp +++ b/shared_memory/loot.cpp @@ -26,6 +26,7 @@ #include "../common/loottable.h" void LoadLoot(SharedDatabase *database) { + _eqp EQEmu::IPCMutex mutex("loot"); mutex.Lock(); diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index 2623ccd26..d0b0922a6 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "../common/eqemu_logsys.h" #include "../common/global_define.h" @@ -35,11 +36,43 @@ EQEmuLogSys Log; +void CatchSignal(int sig_num) +{ +#ifdef EQPERF_ENABLED + char time_str[128]; + time_t result = time(nullptr); + strftime(time_str, sizeof(time_str), "%Y_%m_%d__%H_%M_%S", localtime(&result)); + + std::string prof_name = "./profile/shared_memory_"; + prof_name += time_str; + prof_name += ".log"; + + std::ofstream profile_out(prof_name, std::ofstream::out); + if(profile_out.good()) { + _eqp_dump(profile_out, 10); + } +#endif +} + int main(int argc, char **argv) { + _eqp RegisterExecutablePlatform(ExePlatformSharedMemory); Log.LoadLogSettingsDefaults(); set_exception_handler(); + if(signal(SIGINT, CatchSignal) == SIG_ERR) { + Log.Out(Logs::Detail, Logs::Error, "Could not set signal handler"); + return 1; + } + if(signal(SIGTERM, CatchSignal) == SIG_ERR) { + Log.Out(Logs::Detail, Logs::Error, "Could not set signal handler"); + return 1; + } + if(signal(SIGBREAK, CatchSignal) == SIG_ERR) { + Log.Out(Logs::Detail, Logs::Error, "Could not set signal handler"); + return 1; + } + Log.Out(Logs::General, Logs::Status, "Shared Memory Loader Program"); if(!EQEmuConfig::LoadConfig()) { Log.Out(Logs::General, Logs::Error, "Unable to load configuration file."); @@ -175,6 +208,5 @@ int main(int argc, char **argv) { } Log.CloseFileLogs(); - return 0; } diff --git a/shared_memory/npc_faction.cpp b/shared_memory/npc_faction.cpp index df33b7368..9c76605a7 100644 --- a/shared_memory/npc_faction.cpp +++ b/shared_memory/npc_faction.cpp @@ -25,6 +25,7 @@ #include "../common/faction.h" void LoadFactions(SharedDatabase *database) { + _eqp EQEmu::IPCMutex mutex("faction"); mutex.Lock(); diff --git a/shared_memory/skill_caps.cpp b/shared_memory/skill_caps.cpp index 94205ce72..a83304a09 100644 --- a/shared_memory/skill_caps.cpp +++ b/shared_memory/skill_caps.cpp @@ -26,6 +26,7 @@ #include "../common/features.h" void LoadSkillCaps(SharedDatabase *database) { + _eqp EQEmu::IPCMutex mutex("skill_caps"); mutex.Lock(); diff --git a/shared_memory/spells.cpp b/shared_memory/spells.cpp index 444f3b466..3621f79a3 100644 --- a/shared_memory/spells.cpp +++ b/shared_memory/spells.cpp @@ -25,6 +25,7 @@ #include "../common/spdat.h" void LoadSpells(SharedDatabase *database) { + _eqp EQEmu::IPCMutex mutex("spells"); mutex.Lock(); int records = database->GetMaxSpellID() + 1;