Adding timeout to deamon

git-svn-id: file:///home/jan/tmp/wetterstation/trunk@72 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
losinshi 2006-09-08 15:05:55 +00:00
parent 8a06a29dea
commit 5df78b3c4e
5 changed files with 7 additions and 2 deletions

View File

@ -59,6 +59,8 @@ static const struct config_keyword keywords[] = {
{"pg_user", read_str, &(global_opts.pg_user), DEFAULT_PG_USER},
{"pg_pass", read_str, &(global_opts.pg_pass), DEFAULT_PG_PASS},
{"pg_database", read_str, &(global_opts.pg_database), DEFAULT_PG_DATABASE},
{"pg_timeout", read_str, &(global_opts.pg_timeout), DEFAULT_PG_TIMEOUT},
{"", NULL, NULL, ""}
};

View File

@ -31,6 +31,7 @@
#define DEFAULT_PG_USER "localuser" /* Postgres-Username */
#define DEFAULT_PG_PASS "" /* Postgres-Passwort */
#define DEFAULT_PG_DATABASE "localbase" /* Postgres-Datenbank */
#define DEFAULT_PG_TIMEOUT "20" /* Postgres-Timeout */
#define DEFAULT_CONFIG_FILE "./weather.conf" /* Standart-Configdatei */

View File

@ -34,6 +34,7 @@ typedef struct {
char *pg_user; /* Postgres-Username */
char *pg_pass; /* Postgres-Password */
char *pg_database; /* Postgres-Datenbank */
char *pg_timeout; /* Postgres-Timeout */
#ifndef NO_LOGING
char *data_log; /* Das Daten-Logfile */
char *error_log; /* Das Fehler-Logfile */

View File

@ -24,3 +24,4 @@ pg_host 141.30.228.39
pg_user losinshi
#pg_pass
pg_database wetter
pg_timeout 30

View File

@ -116,8 +116,8 @@ static int pg_connect(){
if(PQstatus(connection) != CONNECTION_OK){
if (connection == NULL){
if(conn_string == NULL){
conn_string = malloc(sizeof(char)*255);
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);
conn_string = malloc(sizeof(char)*512);
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 */
add_clean(clean_write, connection); /* Callbackfunktion zum Aufräumen registrieren */