--- /dev/null
+<?php
+function shutdown_mysql_close() {
+ // NOTE: fix things like this :
+ // Warning: mysql_select_db(): 2 is not a valid MySQL-Link resource in test.php
+ // which is likely due to php5-fpm not correctly destroying all PHP variables ;
+ // uses auto_prepend_file in php.ini :
+ // - works when script ends or exit() is called;
+ // - works when mysql.so is loaded or not;
+ // - not sure if this works with multiple MySQL connexions.
+ if(function_exists('mysql_close'))
+ @mysql_close();
+ }
+register_shutdown_function('shutdown_mysql_close');
+?>