On 22/12/2007, Jonathan Wakely <mysql@stripped> wrote:
> 2) When you remove a connection from the pool_ list it seems to be
> leaked. My suggestion is to add a pure-virtual
> ConnectionPool::destroy() which the derived class must implement to
> free the connection.
If I'm right about this, ~ConnectionPool() should call destroy() on
each element of pool_.
Except that it can't, because the derived class destructor will
already have run and the pure virtual destroy() can't be called.
This means the derived destructor is required to destroy everything in
pool_, so this revised patch adds a clear_pool() member which derived
classes must call before the base ~ConnectionPool dtor runs.
This patch also uses STL algorithms to find old/unused connections in grab().
I'm now not sure about if or when last_used should be reset. The only
time you really know the connection is fresh is at creation.
Attachment: [text/x-patch] mysqlpp-cpool-2.patch