bos / pool

A high-performance striped resource pooling implementation for Haskell
Other
112 stars 59 forks source link

Prevent the finalizer to run early #15

Closed kim closed 10 years ago

kim commented 10 years ago

According to the documentation, using addFinalizer on an "ordinary non-primitive Haskell type" may cause the finalizer to run earlier than expected, due to the compiler being "free to optimise away or duplicate the underlying data structure".

This is reproducibly happening in our code, which uses resource-pool in snap-based web applications (both directly and transitively eg. by using hedis). The result is that the reaper thread gets killed immediately and idle resources never get freed.

I haven't been able to track down why exactly this is happening only in this context (using resource-pool "standalone" seems to work fine), but the attached patch fixes the issue.

bos commented 10 years ago

Applied, thanks.