cleanup_client_logins();
- if (cf_shutdown && get_active_server_count() == 0) {
+ if (cf_shutdown == 1 && get_active_server_count() == 0) {
log_info("server connections dropped, exiting");
- exit(0);
+ cf_shutdown = 2;
+ event_loopbreak();
+ return;
}
if (cf_auth_type >= AUTH_TRUST)
int cf_verbose = 0;
int cf_daemon = 0;
int cf_pause_mode = P_NONE;
-int cf_shutdown = 0;
+int cf_shutdown = 0; /* 1 - wait for queries to finish, 2 - shutdown immediately */
int cf_reboot = 0;
int cf_syslog = 0;
static char *cf_username = "";
char *cf_syslog_facility = "daemon";
-static char *cf_config_file;
+char *cf_config_file = "";
char *cf_listen_addr = NULL;
int cf_listen_port = 6432;
char *cf_ignore_startup_params = "";
-char *cf_autodb_connstr = NULL;
+char *cf_autodb_connstr = NULL; /* here is "" different from NULL */
+
usec_t cf_autodb_idle_timeout = 3600*USEC;
usec_t cf_server_lifetime = 60*60*USEC;
usec_t g_suspend_start = 0;
-char *cf_logfile = NULL;
-char *cf_pidfile = NULL;
+char *cf_logfile = "";
+char *cf_pidfile = "";
char *cf_jobname = "pgbouncer";
char *cf_admin_users = "";
{
int pid, fd;
- if (!cf_pidfile)
+ if (!cf_pidfile[0])
fatal("daemon needs pidfile configured");
/* dont log to stdout anymore */
static void remove_pidfile(void)
{
- if (!cf_pidfile)
+ if (!cf_pidfile[0])
return;
unlink(cf_pidfile);
}
pid_t pid = 0;
int fd, res;
- if (!cf_pidfile)
+ if (!cf_pidfile[0])
return;
/* check if pidfile exists */
pid_t pid;
int res, fd;
- if (!cf_pidfile)
+ if (!cf_pidfile[0])
return;
pid = getpid();
write_pidfile();
/* main loop */
- while (1)
+ while (cf_shutdown < 2)
main_loop_once();
+
+ return 0;
}
len = snprintf(buf, sizeof(buf), "%s %u %s %s\n",
tbuf, (unsigned)getpid(), pfx, msg);
- if (cf_logfile)
+ if (cf_logfile[0])
write_logfile(buf, len);
if (cf_syslog)