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.cxx | |
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.cxx')
-rw-r--r-- | odb/mysql/connection-factory.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/odb/mysql/connection-factory.cxx b/odb/mysql/connection-factory.cxx index b9b3d19..2f1b00c 100644 --- a/odb/mysql/connection-factory.cxx +++ b/odb/mysql/connection-factory.cxx @@ -178,8 +178,12 @@ namespace odb if (connections_.size () != 0) { shared_ptr<pooled_connection> c (connections_.back ()); - c->pool_ = this; connections_.pop_back (); + + if (ping_ && !c->ping ()) + continue; + + c->pool_ = this; in_use_++; return c; } |