-
-
Notifications
You must be signed in to change notification settings - Fork 122
Description
In PooledConnection's Drop impl, it seems that unless the connection has been extracted via take
, the connection is unconditionally returned to the queue. This concerns me, as the Drop
may have been invoked during unwinding, and the connection itself may have initiated the panic, and as such may contain broken invariants, which has_broken
and is_valid
may not be appropriate to detect.
I considered wrapping my connection type in a type that detects panics on drop, but, of course, the inner connection type does not get dropped if it's returned to the pool. It might be possible to wrap the connection type after (I tried the outer wrapper approach, but .get()
ing it from the pool in a type that extracts and drops it on drop if the thread is panicking, but that seems awkward and error-prone.take()
isn't public.)
Is there currently an intended way to handle panics? If there isn't, then if my concern is valid, might it be reasonable to (maybe based on a flag) check std::thread::panicking
in the Drop
implementation, and drop the connection instead of returning it to the pool if it's true
?