brianmario/mysql2 — pull request #444 by rlineweaver (2013-11-13 21:08:43+00:00)
Title: Close MySQL connection on result GC

Since upgrading to 0.3.13/0.2.20, we have experienced MySQL connections that are left open after Ruby is done using them and has garbage collected the object. This change fixes this issue for us.

It appears that when the GC triggers `xfree()` on the client_wrapper in `rb_mysql_result_free()` in `result.c` it was not properly closing the MySQL connection like it does in `rb_mysql_client_free()` in `client.c` (see https://github.com/brianmario/mysql2/commit/ec9b61cbe32f53f59fe581823b7a34f34020a49a#diff-3b04aa8aa3de9a18e251b4a95981f3dfR190).

This refactor allows both garbage collection operations to call a shared method that closes and then frees the client.