diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-02-21 10:42:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-02-21 10:42:13 +0200 |
commit | cfc9c1fa3cab07396b38d192da3d0b6bfa36d0f5 (patch) | |
tree | 4070182474950d34f62fe5f2a828e160540753e6 /odb/mysql/error.cxx | |
parent | 4acabe57939ff37bad0a8aabc5164b6d5add449b (diff) |
Don't reuse failed connections
If MySQL API returns an error indicating the connection is no longer
usable, mark it as failed. In connection_pool_factory free failed
connections instead of returning them to the pool.
Diffstat (limited to 'odb/mysql/error.cxx')
-rw-r--r-- | odb/mysql/error.cxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/odb/mysql/error.cxx b/odb/mysql/error.cxx index 460816a..94a41b2 100644 --- a/odb/mysql/error.cxx +++ b/odb/mysql/error.cxx @@ -16,7 +16,7 @@ namespace odb namespace mysql { void - translate_error (connection&, + translate_error (connection& c, unsigned int e, const std::string& sqlstate, const std::string& message) @@ -31,6 +31,15 @@ namespace odb { throw deadlock (); } + case CR_SERVER_LOST: + case CR_SERVER_GONE_ERROR: + case CR_UNKNOWN_ERROR: + { + // This connection is no longer usable. + // + c.mark_failed (); + // Fall through. + } default: { throw database_exception (e, sqlstate, message); |