Skip to content

Commit

Permalink
fixed ReloadConfiguration(): memleak of npc templates, race condition of
Browse files Browse the repository at this point in the history
pol.cfg client settings.
  • Loading branch information
turleypol authored and KevinEady committed Oct 15, 2023
1 parent 6053fed commit cfdbf86
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmake/core_tests_start.cmake
Expand Up @@ -5,7 +5,7 @@ execute_process(
COMMAND_ECHO STDOUT
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE res
TIMEOUT 120
TIMEOUT 600
)
if(NOT "${res}" STREQUAL "0")
message(SEND_ERROR "${res}")
Expand Down
3 changes: 2 additions & 1 deletion pol-core/pol/globals/uvars.h
Expand Up @@ -254,13 +254,14 @@ class GameState
Core::Vec2d update_range; // maximum update range (client view range/multi footprint) used as
// "pre-filtering" of objects

void unload_npc_templates();

private:
void cleanup_vars();
void cleanup_scripts();
void clear_listen_points();
void unload_intrinsic_weapons();
void unload_intrinsic_templates();
void unload_npc_templates();
};
extern GameState gamestate;
} // namespace Core
Expand Down
5 changes: 3 additions & 2 deletions pol-core/pol/loadunld.cpp
Expand Up @@ -254,10 +254,10 @@ void load_data()
read_npc_templates();


//#ifdef _WIN32
// #ifdef _WIN32
checkpoint( "load console commands" );
ConsoleCommand::load_console_commands();
//#endif
// #endif

Module::load_fileaccess_cfg();

Expand All @@ -270,6 +270,7 @@ void reload_configuration()
PolConfig::read_pol_config( false );
ServSpecOpt::read_servspecopt();
Network::read_bannedips_config( false );
gamestate.unload_npc_templates();
load_npc_templates();
read_npc_templates(); // dave 1/12/3 npc template data wasn't actually being read, just names.
ConsoleCommand::load_console_commands();
Expand Down
11 changes: 6 additions & 5 deletions pol-core/pol/polcfg.h
Expand Up @@ -11,6 +11,7 @@
#ifndef POLCFG_H
#define POLCFG_H

#include <atomic>
#include <string>
#include <vector>

Expand All @@ -29,7 +30,7 @@ struct PolConfig
std::string world_data_path;
std::string realm_data_path;
std::string pidfile_path;
bool verbose;
std::atomic<bool> verbose;
unsigned short loglevel; // 0=nothing 10=lots
unsigned short select_timeout_usecs;
unsigned short loginserver_timeout_mins;
Expand All @@ -55,10 +56,10 @@ struct PolConfig
bool enable_secure_trading;
unsigned int runaway_script_threshold;
bool ignore_load_errors;
unsigned short min_cmdlvl_ignore_inactivity;
unsigned short inactivity_warning_timeout;
unsigned short inactivity_disconnect_timeout;
unsigned short min_cmdlevel_to_login;
std::atomic<unsigned short> min_cmdlvl_ignore_inactivity;
std::atomic<unsigned short> inactivity_warning_timeout;
std::atomic<unsigned short> inactivity_disconnect_timeout;
std::atomic<unsigned short> min_cmdlevel_to_login;
unsigned int max_tile_id;
unsigned int max_objtype;

Expand Down

0 comments on commit cfdbf86

Please sign in to comment.