diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-01-30 23:00:05 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-01-30 23:06:11 +0200 |
commit | 4fef83230e851189fd3541f095c47a952968a411 (patch) | |
tree | 021413ec3602ca4d0e0a0ee0f588d0a2782155ae /src/sql.c | |
parent | e946449ccf15a0f44f402b03812d31d5f8ef4f7b (diff) | |
download | vmod-dbrw-4fef83230e851189fd3541f095c47a952968a411.tar.gz vmod-dbrw-4fef83230e851189fd3541f095c47a952968a411.tar.bz2 |
Introduce connection idle timeout.
* NEWS: Updated.
* configure.ac: Version 2.2.90
* doc/vmod-dbrw.3: Document connection idle timeout.
* doc/vmod-dbrw.texi: Likewise.
* src/dbrw.h (dbrw_backend) <sql_idle_timeout>: New method.
(dbrw_config)<idle_timeout>: New member.
(dbrw_connection)<timestamp>: New member.
(sql_idle_timeout): New proto.
* src/mysql.c (vmod_mysql_data) <mysql>: Change storage.
All uses changed.
(s_mysql_idle_timeout): New function.
* src/sql.c (sql_idle_timeout): New function.
(sql_query): Update connection timestamp.
(sql_idle_timeout): New function.
* src/vmod_dbrw.c (dbrw_connection_get): Force disconnect if connection
remained idle for too long. Initialize cfg->idle_timeout.
(vmod_config): New parameter 'timeout='
Diffstat (limited to 'src/sql.c')
-rw-r--r-- | src/sql.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,5 +1,5 @@ /* This file is part of vmod-dbrw - Copyright (C) 2013-2014 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 @@ -143,6 +143,7 @@ sql_query(struct dbrw_connection *conn, const char *input) return 1; } } while (conn->state != state_connected); + conn->timestamp = time(NULL); if (conn->conf->backend->sql_query(conn, input) == 0) return 0; return 1; @@ -185,3 +186,11 @@ sql_get_column(struct dbrw_connection *conn, unsigned row, unsigned col) return conn->conf->backend->sql_get_column(conn, row, col); } +int +sql_idle_timeout(struct dbrw_connection *conn) +{ + CONN_ASSERT_VAL(conn, -1); + if (!conn->conf->backend->sql_idle_timeout) + return -1; + return conn->conf->backend->sql_idle_timeout(conn); +} |