diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-02-21 12:06:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-02-21 12:06:03 +0200 |
commit | 81c2f16a9826d92cf5b54da71f70943263878d3e (patch) | |
tree | e71b970490eca51a515e4d1f259e543f20b68bb9 /odb/mysql/connection-factory.hxx | |
parent | 6c85f1a50e3b50d18599143e18ee145fc6afdb08 (diff) |
Validate connection in MySQL pool factory
This will help deal with the MySQL server closing connections after
a certain period of inactivity.
Diffstat (limited to 'odb/mysql/connection-factory.hxx')
-rw-r--r-- | odb/mysql/connection-factory.hxx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/odb/mysql/connection-factory.hxx b/odb/mysql/connection-factory.hxx index d9dbf80..43d6f9f 100644 --- a/odb/mysql/connection-factory.hxx +++ b/odb/mysql/connection-factory.hxx @@ -80,10 +80,15 @@ namespace odb // value is 0 then the pool will maintain all the connections // that were ever created. // + // The ping argument specifies whether to ping the connection to + // make sure it is still alive before returning it to the caller. + // connection_pool_factory (std::size_t max_connections = 0, - std::size_t min_connections = 0) + std::size_t min_connections = 0, + bool ping = true) : max_ (max_connections), min_ (min_connections), + ping_ (ping), in_use_ (0), waiters_ (0), db_ (0), @@ -134,6 +139,7 @@ namespace odb private: const std::size_t max_; const std::size_t min_; + const bool ping_; std::size_t in_use_; // Number of connections currently in use. std::size_t waiters_; // Number of threads waiting for a connection. |