diff options
Diffstat (limited to 'src/dbrw.h')
-rw-r--r-- | src/dbrw.h | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,8 +1,8 @@ /* This file is part of vmod-dbrw - Copyright (C) 2013-2017 Sergey Poznyakoff + Copyright (C) 2013-2018 Sergey Poznyakoff Vmod-dbrw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -40,12 +40,13 @@ struct dbrw_backend { int (*sql_query) (struct dbrw_connection *, const char *); unsigned (*sql_num_tuples) (struct dbrw_connection *); unsigned (*sql_num_fields) (struct dbrw_connection *); int (*sql_free_result) (struct dbrw_connection *); const char *(*sql_get_column)(struct dbrw_connection *, unsigned, unsigned); + int (*sql_idle_timeout)(struct dbrw_connection *); }; enum { state_init, state_connected, state_result, @@ -63,24 +64,26 @@ struct dbrw_config { char **param; char *param_str; char *query; int qdisp; int regflags; char status[HTTP_STATUS_LEN+1]; + int idle_timeout; VTAILQ_ENTRY(dbrw_config) list; }; struct dbrw_connection { unsigned magic; #define DBRW_CONNECTION_MAGIC 0x6773716c int state; /* Connection state */ int busy:1; struct dbrw_config *conf; /* Pointer to the configuration data */ regmatch_t *matches; /* Match map */ size_t matchsize; /* Total number of entries in match map */ - void *data; /* Backend-specific data */ + time_t timestamp; /* Last used at */ + void *data; /* Backend-specific data */ VTAILQ_ENTRY(dbrw_connection) list; }; void dbrw_debug(const char *fmt, ...); void dbrw_error(const char *fmt, ...); @@ -102,9 +105,10 @@ char *sql_escape(struct dbrw_connection *pd, const char *input); int sql_query(struct dbrw_connection *pd, const char *input); unsigned sql_num_tuples(struct dbrw_connection *pd); unsigned sql_num_fields(struct dbrw_connection *pd); void sql_free_result(struct dbrw_connection *pd); void sql_destroy(struct dbrw_connection *pd); const char *sql_get_column(struct dbrw_connection *pd, unsigned row, unsigned col); +int sql_idle_timeout(struct dbrw_connection *conn); char *findparam(char **params, char *name); |