diff --git a/src/libpgagroal/pool.c b/src/libpgagroal/pool.c index 87fe5e50..29e0726f 100644 --- a/src/libpgagroal/pool.c +++ b/src/libpgagroal/pool.c @@ -802,14 +802,20 @@ void pgagroal_flush_server(signed char server) { struct configuration* config; - int newPrimary = (int)server; + int primary = -1; + bool prefill = false; pgagroal_start_logging(); pgagroal_memory_init(); config = (struct configuration*)shmem; - pgagroal_log_debug("pgagroal_flush_server %s", config->servers[server].name); + if (!pgagroal_get_primary(&primary)) + prefill = server != (unsigned char)primary && primary != -1; + else + prefill = false; + + pgagroal_log_debug("pgagroal_flush_server %s with%s prefill to %s", config->servers[server].name, prefill ? "" : "out", config->servers[primary].name); for (int i = 0; i < config->max_connections; i++) { if (config->connections[i].server == server) @@ -850,10 +856,7 @@ pgagroal_flush_server(signed char server) { if (!fork()) { - if (!pgagroal_get_primary(&newPrimary)) - pgagroal_prefill(newPrimary != server); - else - pgagroal_prefill(false); + pgagroal_prefill(prefill); } }