/*
- * $Id: db_param.c,v 1.7 2009-10-19 05:02:35 didg Exp $
+ * $Id: db_param.c,v 1.8 2009-10-19 05:38:22 didg Exp $
*
* Copyright (C) Joerg Lenneis 2003
* Copyright (c) Frank Lahm 2009
#define MAXKEYLEN 64
#define DEFAULT_LOGFILE_AUTOREMOVE 1
-#define DEFAULT_CACHESIZE 8 * 1024
-#define DEFAULT_FLUSH_FREQUENCY 100
+#define DEFAULT_CACHESIZE (8 * 1024)
+#define DEFAULT_FLUSH_FREQUENCY 1000
#define DEFAULT_FLUSH_INTERVAL 1800
#define DEFAULT_USOCK_FILE "usock"
#define DEFAULT_FD_TABLE_SIZE 512
-#define DEFAULT_IDLE_TIMEOUT 10 * 60
+#define DEFAULT_IDLE_TIMEOUT (10 * 60)
static struct db_param params;
static int parse_err;
}
fclose(fp);
- if (! parse_err)
+ if (! parse_err) {
+ /* sanity checks */
+ if (params.flush_frequency <= 0)
+ params.flush_frequency = 86400;
+
+ if (params.flush_interval <= 0)
+ params.flush_interval = 1000000;
+
+ if (params.fd_table_size <= 2)
+ params.fd_table_size = 32;
+
+ if (params.idle_timeout <= 0)
+ params.idle_timeout = 86400;
+
return ¶ms;
+ }
else
return NULL;
}
/*
- * $Id: main.c,v 1.12 2009-10-18 17:50:13 didg Exp $
+ * $Id: main.c,v 1.13 2009-10-19 05:38:22 didg Exp $
*
* Copyright (C) Joerg Lenneis 2003
* Copyright (c) Frank Lahm 2009
1: Success, if transactions are used commit.
0: Failure, but we continue to serve requests. If transactions are used abort/rollback.
- -1: Fatal error, either from the database or from the socket. Abort the transaction if applicable
+ -1: Fatal error, either from t
+ he database or from the socket. Abort the transaction if applicable
(which might fail as well) and then exit.
We always try to notify the client process about the outcome, the result field
if (exit_sig)
/* Received signal (TERM|INT) */
return 0;
- if (dbp->idle_timeout && comm_nbe() <= 0 && (now - time_last_rqst) > dbp->idle_timeout)
- /* Idle timeout */
- return 0;
+ if (now - time_last_rqst > dbp->idle_timeout) {
+ if (comm_nbe() <= 0) {
+ /* Idle timeout */
+ return 0;
+ }
+ else {
+ /* still active connections, reset time_last_rqst */
+ time_last_rqst = now;
+ }
+ }
} else {
/* We got a request */
time_last_rqst = now;