@@ -62,7 +62,7 @@ struct db_instance {
unsigned char backlog_full;
struct llist_head backlog;
};
-#define TIME_ERR ((time_t)-1) /* Be paranoid */
+
#define RECONNECT_DEFAULT 2
#define MAX_ONESHOT_REQUEST 10
#define RING_BUFFER_DEFAULT_SIZE 0
@@ -37,7 +37,6 @@ struct dbi_instance {
dbi_conn dbh;
dbi_result result;
};
-#define TIME_ERR ((time_t)-1)
/* our configuration directives */
static struct config_keyset dbi_kset = {
@@ -34,7 +34,6 @@ struct pgsql_instance {
PGresult *pgres;
unsigned char pgsql_have_schemas;
};
-#define TIME_ERR ((time_t)-1)
/* our configuration directives */
static struct config_keyset pgsql_kset = {
@@ -302,14 +302,12 @@ static int _init_reconnect(struct ulogd_pluginstance *upi)
if (time(NULL) < di->reconnect)
return -1;
di->reconnect = time(NULL);
- if (di->reconnect != TIME_ERR) {
- ulogd_log(ULOGD_ERROR, "no connection to database, "
- "attempting to reconnect after %u seconds\n",
- reconnect_ce(upi->config_kset).u.value);
- di->reconnect += reconnect_ce(upi->config_kset).u.value;
- di->interp = &_init_db;
- return -1;
- }
+ ulogd_log(ULOGD_ERROR,
+ "no connection to database, attempting to reconnect after %u seconds\n",
+ reconnect_ce(upi->config_kset).u.value);
+ di->reconnect += reconnect_ce(upi->config_kset).u.value;
+ di->interp = &_init_db;
+ return -1;
}
/* Disable plugin permanently */
The `TIME_ERR` macro is used to check the return value of time(2). However, two of the definitions of it are never used. The third is used to check the return value of `time(NULL)`. However, time(2) with a `NULL` argument can never fail, so we don't need to perform the check. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> --- include/ulogd/db.h | 2 +- output/dbi/ulogd_output_DBI.c | 1 - output/pgsql/ulogd_output_PGSQL.c | 1 - util/db.c | 14 ++++++-------- 4 files changed, 7 insertions(+), 11 deletions(-)