Adding timeout to deamon
git-svn-id: file:///home/jan/tmp/wetterstation/trunk@72 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
parent
8a06a29dea
commit
5df78b3c4e
|
|
@ -59,6 +59,8 @@ static const struct config_keyword keywords[] = {
|
||||||
{"pg_user", read_str, &(global_opts.pg_user), DEFAULT_PG_USER},
|
{"pg_user", read_str, &(global_opts.pg_user), DEFAULT_PG_USER},
|
||||||
{"pg_pass", read_str, &(global_opts.pg_pass), DEFAULT_PG_PASS},
|
{"pg_pass", read_str, &(global_opts.pg_pass), DEFAULT_PG_PASS},
|
||||||
{"pg_database", read_str, &(global_opts.pg_database), DEFAULT_PG_DATABASE},
|
{"pg_database", read_str, &(global_opts.pg_database), DEFAULT_PG_DATABASE},
|
||||||
|
{"pg_timeout", read_str, &(global_opts.pg_timeout), DEFAULT_PG_TIMEOUT},
|
||||||
|
|
||||||
{"", NULL, NULL, ""}
|
{"", NULL, NULL, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#define DEFAULT_PG_USER "localuser" /* Postgres-Username */
|
#define DEFAULT_PG_USER "localuser" /* Postgres-Username */
|
||||||
#define DEFAULT_PG_PASS "" /* Postgres-Passwort */
|
#define DEFAULT_PG_PASS "" /* Postgres-Passwort */
|
||||||
#define DEFAULT_PG_DATABASE "localbase" /* Postgres-Datenbank */
|
#define DEFAULT_PG_DATABASE "localbase" /* Postgres-Datenbank */
|
||||||
|
#define DEFAULT_PG_TIMEOUT "20" /* Postgres-Timeout */
|
||||||
#define DEFAULT_CONFIG_FILE "./weather.conf" /* Standart-Configdatei */
|
#define DEFAULT_CONFIG_FILE "./weather.conf" /* Standart-Configdatei */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ typedef struct {
|
||||||
char *pg_user; /* Postgres-Username */
|
char *pg_user; /* Postgres-Username */
|
||||||
char *pg_pass; /* Postgres-Password */
|
char *pg_pass; /* Postgres-Password */
|
||||||
char *pg_database; /* Postgres-Datenbank */
|
char *pg_database; /* Postgres-Datenbank */
|
||||||
|
char *pg_timeout; /* Postgres-Timeout */
|
||||||
#ifndef NO_LOGING
|
#ifndef NO_LOGING
|
||||||
char *data_log; /* Das Daten-Logfile */
|
char *data_log; /* Das Daten-Logfile */
|
||||||
char *error_log; /* Das Fehler-Logfile */
|
char *error_log; /* Das Fehler-Logfile */
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,4 @@ pg_host 141.30.228.39
|
||||||
pg_user losinshi
|
pg_user losinshi
|
||||||
#pg_pass
|
#pg_pass
|
||||||
pg_database wetter
|
pg_database wetter
|
||||||
|
pg_timeout 30
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,8 @@ static int pg_connect(){
|
||||||
if(PQstatus(connection) != CONNECTION_OK){
|
if(PQstatus(connection) != CONNECTION_OK){
|
||||||
if (connection == NULL){
|
if (connection == NULL){
|
||||||
if(conn_string == NULL){
|
if(conn_string == NULL){
|
||||||
conn_string = malloc(sizeof(char)*255);
|
conn_string = malloc(sizeof(char)*512);
|
||||||
snprintf(conn_string, 255, "host=%s dbname=%s user=%s password=%s", global_opts.pg_host, global_opts.pg_database, global_opts.pg_user, global_opts.pg_pass);
|
snprintf(conn_string, 512, "host=%s dbname=%s user=%s password=%s connect_timeout=%s", global_opts.pg_host, global_opts.pg_database, global_opts.pg_user, global_opts.pg_pass, global_opts.pg_timeout);
|
||||||
}
|
}
|
||||||
connection = PQconnectdb(conn_string); /* Connection aufbauen */
|
connection = PQconnectdb(conn_string); /* Connection aufbauen */
|
||||||
add_clean(clean_write, connection); /* Callbackfunktion zum Aufräumen registrieren */
|
add_clean(clean_write, connection); /* Callbackfunktion zum Aufräumen registrieren */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue