tony2001                Mon Oct  2 22:07:58 2006 UTC

  Modified files:              
    /php-src/ext/pdo_mysql      mysql_driver.c 
  Log:
  fix #38996 (PDO_MYSQL doesn't check connections for liveness)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_mysql/mysql_driver.c?r1=1.73&r2=1.74&diff_format=u
Index: php-src/ext/pdo_mysql/mysql_driver.c
diff -u php-src/ext/pdo_mysql/mysql_driver.c:1.73 
php-src/ext/pdo_mysql/mysql_driver.c:1.74
--- php-src/ext/pdo_mysql/mysql_driver.c:1.73   Thu Mar 23 01:37:38 2006
+++ php-src/ext/pdo_mysql/mysql_driver.c        Mon Oct  2 22:07:58 2006
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysql_driver.c,v 1.73 2006/03/23 01:37:38 pajoye Exp $ */
+/* $Id: mysql_driver.c,v 1.74 2006/10/02 22:07:58 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -368,6 +368,34 @@
        return 1;
 }
 
+static int pdo_mysql_check_liveness(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
+{
+       pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
+#if MYSQL_VERSION_ID <= 32230
+       void (*handler) (int);
+       unsigned int my_errno;
+#endif
+
+#if MYSQL_VERSION_ID > 32230
+       if (mysql_ping(H->server)) {
+               return FAILURE;
+       }
+#else /* no mysql_ping() */
+       handler=signal(SIGPIPE, SIG_IGN);
+       mysql_stat(H->server);
+       switch (mysql_errno(H->server)) {
+               case CR_SERVER_GONE_ERROR:
+               /* case CR_SERVER_LOST: I'm not sure this means the same as 
"gone" for us */
+                       signal(SIGPIPE, handler);
+                       return FAILURE;
+               default:
+                       break;
+       }
+       signal(SIGPIPE, handler);
+#endif /* end mysql_ping() */
+       return SUCCESS;
+} 
+/* }}} */
 
 static struct pdo_dbh_methods mysql_methods = {
        mysql_handle_closer,
@@ -381,7 +409,7 @@
        pdo_mysql_last_insert_id,
        pdo_mysql_fetch_error_func,
        pdo_mysql_get_attribute,
-       NULL /* check_liveness: TODO: ping */
+       pdo_mysql_check_liveness
 };
 
 #ifndef PDO_MYSQL_UNIX_ADDR

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to