usec_t last_connect_time;
unsigned last_connect_failed:1;
- unsigned admin:1;
unsigned welcome_msg_ready:1;
};
*/
struct PgDatabase {
List head;
- char name[MAX_DBNAME];
+ char name[MAX_DBNAME]; /* db name for clients */
bool db_paused; /* PAUSE <db>; was issued */
bool db_dead; /* used on RELOAD/SIGHUP to later detect removed dbs */
+ bool admin; /* internal console db */
uint8_t startup_params[256]; /* partial StartupMessage (without user) be sent to server */
unsigned startup_params_len;
int pool_size; /* max server connections in one pool */
- const char *dbname; /* pointer to inside startup_msg */
+ const char *dbname; /* server-side name, pointer to inside startup_msg */
};
/*
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
- if (pool->admin)
+ if (pool->db->admin)
continue;
res = res && show_fds_from_list(admin, &pool->active_client_list);
res = res && show_fds_from_list(admin, &pool->waiting_client_list);
db->addr.port = cf_listen_port;
db->addr.is_unix = 1;
db->pool_size = 2;
+ db->admin = 1;
if (!force_user(db, "pgbouncer", ""))
fatal("no mem on startup - cannot alloc pgbouncer user");
- /* fake pool, tag the it as special */
+ /* fake pool */
pool = get_pool(db, db->forced_user);
if (!pool)
fatal("cannot create admin pool?");
- pool->admin = 1;
admin_pool = pool;
/* fake user, with disabled psw */
if (!decide_startup_pool(client, pkt))
return false;
- if (client->pool->admin) {
+ if (client->pool->db->admin) {
if (!admin_pre_login(client))
return false;
}
client->query_start = get_cached_time();
}
- if (client->pool->admin)
+ if (client->pool->db->admin)
return admin_handle_client(client, pkt);
/* aquire server */
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
- if (pool->admin)
+ if (pool->db->admin)
continue;
resume_socket_list(&pool->active_client_list);
resume_socket_list(&pool->active_server_list);
{
int active = 0;
- if (pool->admin)
+ if (pool->db->admin)
return 0;
close_server_list(&pool->idle_server_list, "pause mode");
{
int active = 0;
- if (pool->admin)
+ if (pool->db->admin)
return 0;
active += suspend_socket_list(&pool->active_client_list, force_suspend);
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
- if (pool->admin)
+ if (pool->db->admin)
continue;
switch (cf_pause_mode) {
case P_NONE:
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
- if (pool->admin)
+ if (pool->db->admin)
continue;
pool_server_maint(pool);
pool_client_maint(pool);
statlist_for_each(item, &database_list) {
db = container_of(item, PgDatabase, head);
- if (strcmp(db->name, "pgbouncer") == 0)
+ if (db->admin)
continue;
db->db_dead = flag;
}
disconnect_client(req, false, "cancel request for idle client");
/* let administrative cancel be handled elsewhere */
- if (main_client->pool->admin) {
+ if (main_client->pool->db->admin) {
admin_handle_cancel(main_client);
return;
}
res = release_server(server);
/* let the takeover process handle it */
- if (res && server->pool->admin)
+ if (res && server->pool->db->admin)
res = takeover_login(server);
break;
SBuf *sbuf = &server->sbuf;
PgSocket *client = server->link;
- Assert(!server->pool->admin);
+ Assert(!server->pool->db->admin);
switch (pkt->type) {
default:
slog_warning(server, "SBUF_EV_PKT_CALLBACK with state=%d", server->state);
break;
}
- if (!res && pool->admin)
+ if (!res && pool->db->admin)
takeover_login_failed();
return res;
}
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
- if (pool->admin)
+ if (pool->db->admin)
continue;
statlist_for_each(item2, &pool->active_client_list) {
client = container_of(item2, PgSocket, head);