devinus/poolboy — pull request #37 by evnu (2013-10-29 08:18:59+00:00)
Title: Use monitors instead of links and trap_exit

We encountered a problem similar to the one stated in http://stackoverflow.com/questions/19354937/strange-error-message-when-stopping-app-using-lager-and-poolboy. The problem can be described as follows: If poolboy is used in a supervisor tree, shutting down the tree might cause error messages similar to this one:

=SUPERVISOR REPORT==== 22-Oct-2013::17:51:45 ===
Supervisor: {<0.252.0>,poolboy_sup}
Context: shutdown_error
Reason: shutdown
Offender: [{nb_children,1},
{name,our_worker},
{mfargs,
{our_worker,start_link,
[[{name,{local,our_worker_pool_sup}},
{size,5},
{overflow,5},
{worker_module,our_worker}]]}},
{restart_type,temporary},
{shutdown,5000},
{child_type,worker}]

This means that a worker is shutdown by poolboy without using the poolboy supervisor. Such behaviour can occur if the poolboy `gen_server` shuts the workers down through its links to the workers. The attached commits fixes this by substituting the links between the poolboy process and the workers with monitors.