Am 12.10.2017 um 18:41 schrieb Clinton D Skakun:

On Wed, 11 Oct 2017 13:57:08 -0400, Steven Schveighoffer wrote:

On 10/11/17 1:50 PM, Clinton D Skakun wrote:

void getUser(req, res) {

auto db = pool.lock()

db.query(...)

req.writeBody...

}

What happens when getUser is called but the request is cancelled halfway through before the query finishes?

Is there ever a time when the lock will never be released?

Unlikely. The lock is handled automatically via reference counting. So
the unlock will be done as the destructor for db is called exiting the
scope. This happens even if an exception is thrown.

-Steve

Thanks Steve, do you know if there's a straightforward method to do a writeln once a connection is unlocked?

If it's just for debugging, the easiest approach would be to edit
core/vibe/core/connectionpool.d of the vibe.d package downloaded to
~/.dub/packages/ and put the log message at line 147 (there is already
a commented out logTrace call there).

Apart from this debugging issue, it may also make sense to remember this
as an enhancement request, so that the connection object can get
notified when the connection is locked/unlocked, as that may enable
certain optimizations.