Only perform the leave/enter loop when gamemode is already active/has clients

This commit is contained in:
Marc Di Luzio
2019-05-15 18:38:36 +01:00
parent ec55bda3b2
commit 5d0a413035

View File

@ -642,25 +642,29 @@ static void game_mode_reload_config_internal(GameModeContext *self)
{
LOG_MSG("Reloading config...\n");
/* Remove current client optimisations */
pthread_rwlock_rdlock(&self->rwlock);
for (GameModeClient *cl = self->client; cl; cl = cl->next)
game_mode_remove_client_optimisations(self, cl->pid);
pthread_rwlock_unlock(&self->rwlock);
/* Make sure we have a readwrite lock on ourselves */
pthread_rwlock_wrlock(&self->rwlock);
/* Shut down the global context */
game_mode_context_leave(self);
/* Remove current optimisations when we're already active */
if (game_mode_context_num_clients(self)) {
for (GameModeClient *cl = self->client; cl; cl = cl->next)
game_mode_remove_client_optimisations(self, cl->pid);
game_mode_context_leave(self);
}
/* Reload the config */
config_reload(self->config);
/* Start the global context back up */
game_mode_context_enter(self);
/* Re-apply all current optimisations */
pthread_rwlock_rdlock(&self->rwlock);
for (GameModeClient *cl = self->client; cl; cl = cl->next)
game_mode_apply_client_optimisations(self, cl->pid);
if (game_mode_context_num_clients(self)) {
/* Start the global context back up */
game_mode_context_enter(self);
for (GameModeClient *cl = self->client; cl; cl = cl->next)
game_mode_apply_client_optimisations(self, cl->pid);
}
pthread_rwlock_unlock(&self->rwlock);
LOG_MSG("Config reload complete\n");