andrey          Tue Jan 29 18:13:12 2008 UTC

  Modified files:              
    /php-src/ext/mysqlnd        php_mysqlnd.c config9.m4 mysqlnd.c mysqlnd.h 
                                mysqlnd_result.c mysqlnd_result.h 
  Log:
  Fix the build, add a missing file
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/php_mysqlnd.c?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mysqlnd/php_mysqlnd.c
diff -u /dev/null php-src/ext/mysqlnd/php_mysqlnd.c:1.2
--- /dev/null   Tue Jan 29 18:13:12 2008
+++ php-src/ext/mysqlnd/php_mysqlnd.c   Tue Jan 29 18:13:12 2008
@@ -0,0 +1,249 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 6                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 2006-2008 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.txt                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Authors: Georg Richter <[EMAIL PROTECTED]>                             |
+  |          Andrey Hristov <[EMAIL PROTECTED]>                           |
+  |          Ulf Wendel <[EMAIL PROTECTED]>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: php_mysqlnd.c,v 1.2 2008/01/29 18:13:12 andrey Exp $ */
+#include "php.h"
+#include "php_ini.h"
+#include "mysqlnd.h"
+#include "mysqlnd_priv.h"
+#include "mysqlnd_debug.h"
+#include "ext/standard/info.h"
+
+/* {{{ mysqlnd_functions[]
+ *
+ * Every user visible function must have an entry in mysqlnd_functions[].
+ */
+static zend_function_entry mysqlnd_functions[] = {
+       {NULL, NULL, NULL}      /* Must be the last line in mysqlnd_functions[] 
*/
+};
+/* }}} */
+
+
+/* {{{ mysqlnd_minfo_print_hash */
+#if PHP_MAJOR_VERSION >= 6
+PHPAPI void mysqlnd_minfo_print_hash(zval *values)
+{
+       zval **values_entry;
+       HashPosition pos_values;
+
+       zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
+       while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values),
+                                                                               
(void **)&values_entry, &pos_values) == SUCCESS) {
+               TSRMLS_FETCH();
+               zstr    string_key;
+               uint    string_key_len;
+               ulong   num_key;
+               char    *s = NULL;
+
+               zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, 
&string_key_len, &num_key, 0, &pos_values);
+
+               convert_to_string(*values_entry);
+
+               if (UG(unicode)) {
+                       int s_len;
+                       if 
(zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)),
+                                                                          &s, 
&s_len, string_key.u, string_key_len TSRMLS_CC) == SUCCESS) {
+                               php_info_print_table_row(2, s, 
Z_STRVAL_PP(values_entry));
+                       }
+                       if (s) {
+                               mnd_efree(s);
+                       }
+               } else {
+                       php_info_print_table_row(2, string_key.s, 
Z_STRVAL_PP(values_entry));
+               }
+
+               zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values);
+       }
+}
+#else
+void mysqlnd_minfo_print_hash(zval *values)
+{
+       zval **values_entry;
+       HashPosition pos_values;
+
+       zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
+       while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void 
**)&values_entry, &pos_values) == SUCCESS) {
+               char    *string_key;
+               uint    string_key_len;
+               ulong   num_key;
+
+               zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, 
&string_key_len, &num_key, 0, &pos_values);
+
+               convert_to_string(*values_entry);
+               php_info_print_table_row(2, string_key, 
Z_STRVAL_PP(values_entry));
+
+               zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values);
+       }
+}
+#endif
+/* }}} */
+
+
+/* {{{ PHP_MINFO_FUNCTION
+ */
+PHP_MINFO_FUNCTION(mysqlnd)
+{
+       char buf[32];
+       zval values;
+
+       php_info_print_table_start();
+       php_info_print_table_header(2, "mysqlnd", "enabled");
+       php_info_print_table_row(2, "Version", mysqlnd_get_client_info());
+
+       /* Print client stats */
+       php_info_print_table_header(2, "Client statistics", "");
+       mysqlnd_get_client_stats(&values);
+       mysqlnd_minfo_print_hash(&values);
+       php_info_print_table_row(2, "Collecting statistics", 
MYSQLND_G(collect_statistics)? "Yes":"No");
+       php_info_print_table_row(2, "Collecting memory statistics", 
MYSQLND_G(collect_memory_statistics)? "Yes":"No");
+
+       snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size));
+       php_info_print_table_row(2, "Command buffer size", buf);
+       snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
+       php_info_print_table_row(2, "Read buffer size", buf);
+
+       zval_dtor(&values);
+       php_info_print_table_end();
+}
+/* }}} */
+
+
+ZEND_DECLARE_MODULE_GLOBALS(mysqlnd);
+
+
+/* {{{ PHP_GINIT_FUNCTION
+ */
+static PHP_GINIT_FUNCTION(mysqlnd)
+{
+       mysqlnd_globals->collect_statistics = TRUE;
+       mysqlnd_globals->collect_memory_statistics = FALSE;
+       mysqlnd_globals->debug = NULL;  /* The actual string */
+       mysqlnd_globals->dbg = NULL;    /* The DBG object*/
+       mysqlnd_globals->net_cmd_buffer_size = 2048;
+       mysqlnd_globals->net_read_buffer_size = 32768;
+}
+/* }}} */
+
+
+/* {{{ PHP_INI_BEGIN
+*/
+PHP_INI_BEGIN()
+       STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics",       "1",    
PHP_INI_ALL, OnUpdateBool,      collect_statistics, zend_mysqlnd_globals, 
mysqlnd_globals)
+       STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics",        "0",    
PHP_INI_SYSTEM, OnUpdateBool,   collect_memory_statistics, 
zend_mysqlnd_globals, mysqlnd_globals)
+       STD_PHP_INI_ENTRY("mysqlnd.debug",                                      
NULL,   PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, 
mysqlnd_globals)
+       STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size",        "2048", 
PHP_INI_ALL,    OnUpdateLong,   net_cmd_buffer_size,    zend_mysqlnd_globals,   
        mysqlnd_globals)
+       STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size",       
"32768",PHP_INI_ALL,    OnUpdateLong,   net_read_buffer_size,   
zend_mysqlnd_globals,           mysqlnd_globals)
+PHP_INI_END()
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION
+ */
+static PHP_MINIT_FUNCTION(mysqlnd)
+{
+       REGISTER_INI_ENTRIES();
+
+       mysqlnd_library_init(TSRMLS_C);
+       return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+ */
+static PHP_MSHUTDOWN_FUNCTION(mysqlnd)
+{
+       mysqlnd_library_end(TSRMLS_C);
+
+       UNREGISTER_INI_ENTRIES();
+       return SUCCESS;
+}
+/* }}} */
+
+
+#ifdef PHP_DEBUG
+/* {{{ PHP_RINIT_FUNCTION
+ */
+static PHP_RINIT_FUNCTION(mysqlnd)
+{
+       if (MYSQLND_G(debug)) {
+               MYSQLND_DEBUG *dbg = mysqlnd_debug_init(TSRMLS_C);
+               if (!dbg) {
+                       return FAILURE;
+               }
+               dbg->m->set_mode(dbg, MYSQLND_G(debug));
+               MYSQLND_G(dbg) = dbg;   
+       }
+       return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_RSHUTDOWN_FUNCTION
+ */
+static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
+{
+       MYSQLND_DEBUG *dbg = MYSQLND_G(dbg);
+       DBG_ENTER("RSHUTDOWN");
+       if (dbg) {
+               dbg->m->close(dbg);
+               dbg->m->free_handle(dbg);
+               MYSQLND_G(dbg) = NULL;
+       }
+       return SUCCESS;
+}
+/* }}} */
+#endif
+
+
+/* {{{ mysqlnd_module_entry
+ */
+zend_module_entry mysqlnd_module_entry = {
+       STANDARD_MODULE_HEADER,
+       "mysqlnd",
+       mysqlnd_functions,
+       PHP_MINIT(mysqlnd),
+       PHP_MSHUTDOWN(mysqlnd),
+#ifdef PHP_DEBUG
+       PHP_RINIT(mysqlnd),
+       PHP_RSHUTDOWN(mysqlnd),
+#else
+       NULL,
+       NULL,
+#endif
+       PHP_MINFO(mysqlnd),
+       MYSQLND_VERSION,
+       PHP_MODULE_GLOBALS(mysqlnd),
+       PHP_GINIT(mysqlnd),
+       NULL,
+       NULL,
+       STANDARD_MODULE_PROPERTIES_EX
+};
+/* }}} */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/config9.m4?r1=1.6&r2=1.7&diff_format=u
Index: php-src/ext/mysqlnd/config9.m4
diff -u php-src/ext/mysqlnd/config9.m4:1.6 php-src/ext/mysqlnd/config9.m4:1.7
--- php-src/ext/mysqlnd/config9.m4:1.6  Mon Jan 28 23:24:05 2008
+++ php-src/ext/mysqlnd/config9.m4      Tue Jan 29 18:13:12 2008
@@ -1,7 +1,12 @@
 dnl
-dnl $Id: config9.m4,v 1.6 2008/01/28 23:24:05 andrey Exp $
+dnl $Id: config9.m4,v 1.7 2008/01/29 18:13:12 andrey Exp $
 dnl config.m4 for mysqlnd driver
 
+
+PHP_ARG_ENABLE(mysqlnd_threading, whether to enable threaded fetch in mysqlnd,
+[  --enable-mysqlnd-threading  mysqlnd: Enable threaded fetch], no, no)
+
+
 dnl If some extension uses mysqlnd it will get compiled in PHP core
 if test "$PHP_MYSQLND_ENABLED" = "yes"; then
   mysqlnd_sources="mysqlnd.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
@@ -16,6 +21,13 @@
   PHP_INSTALL_HEADERS([$ext_builddir/php_mysqlnd_config.h])
   AC_DEFINE([HAVE_MYSQLND], 1, [Whether mysqlnd is enabled])
 
+  dnl Windows uses config.w32 thus this code is safe for now
+  if test "$PHP_MYSQLND_THREADING" = "yes"; then
+    PHP_BUILD_THREAD_SAFE
+    AC_DEFINE([MYSQLND_THREADED], 1, [Whether mysqlnd threading is enabled])
+  fi
+
+
   dnl This creates a file so it has to be after above macros
   PHP_CHECK_TYPES([int8 uint8 int16 uint16 int32 uint32 uchar ulong int8_t 
uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t], [
     $ext_builddir/php_mysqlnd_config.h
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.c?r1=1.15&r2=1.16&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.c
diff -u php-src/ext/mysqlnd/mysqlnd.c:1.15 php-src/ext/mysqlnd/mysqlnd.c:1.16
--- php-src/ext/mysqlnd/mysqlnd.c:1.15  Tue Jan 29 12:00:52 2008
+++ php-src/ext/mysqlnd/mysqlnd.c       Tue Jan 29 18:13:12 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.c,v 1.15 2008/01/29 12:00:52 andrey Exp $ */
+/* $Id: mysqlnd.c,v 1.16 2008/01/29 18:13:12 andrey Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -68,63 +68,6 @@
 
 static enum_func_status mysqlnd_send_close(MYSQLND * conn TSRMLS_DC);
 
-#define MYSQLND_SILENT 1
-
-#ifdef MYSQLND_THREADED
-/* {{{ _mysqlnd_fetch_thread */
-void * _mysqlnd_fetch_thread(void *arg)
-{
-       MYSQLND *conn = (MYSQLND *) arg;
-       MYSQLND_RES * result = NULL;
-       void ***tsrm_ls = conn->tsrm_ls;
-#ifndef MYSQLND_SILENT
-       printf("conn=%p tsrm_ls=%p\n", conn, conn->tsrm_ls);
-#endif
-       do {
-               pthread_mutex_lock(&conn->LOCK_work);
-               while (conn->thread_killed == FALSE /* && there is work */) {
-#ifndef MYSQLND_SILENT
-                       printf("Waiting for work in %s\n", __FUNCTION__);
-#endif
-                       pthread_cond_wait(&conn->COND_work, &conn->LOCK_work);
-               }
-               if (conn->thread_killed == TRUE) {
-#ifndef MYSQLND_SILENT
-                       printf("Thread killed in %s\n", __FUNCTION__);
-#endif
-                       pthread_cond_signal(&conn->COND_thread_ended);
-                       pthread_mutex_unlock(&conn->LOCK_work);
-                       break;
-               }
-#ifndef MYSQLND_SILENT
-               printf("Got work in %s\n", __FUNCTION__);
-#endif
-               CONN_SET_STATE(conn, CONN_FETCHING_DATA);
-               result = conn->current_result;
-               conn->current_result = NULL;
-               pthread_mutex_unlock(&conn->LOCK_work);
-
-               mysqlnd_background_store_result_fetch_data(result TSRMLS_CC);
-
-               /* do fetch the data from the wire */
-
-               pthread_mutex_lock(&conn->LOCK_work);
-               CONN_SET_STATE(conn, CONN_READY);
-               pthread_cond_signal(&conn->COND_work_done);
-#ifndef MYSQLND_SILENT
-               printf("Signaling work done in %s\n", __FUNCTION__);
-#endif
-               pthread_mutex_unlock(&conn->LOCK_work);
-       } while (1);
-
-#ifndef MYSQLND_SILENT
-       printf("Exiting worker thread in %s\n", __FUNCTION__);
-#endif
-       return NULL;
-}
-/* }}} */
-#endif /* MYSQLND_THREADED */
-
 
 /* {{{ mysqlnd_library_init */
 void mysqlnd_library_init(TSRMLS_D)
@@ -839,7 +782,7 @@
                        pthread_attr_setdetachstate(&connection_attrib, 
PTHREAD_CREATE_DETACHED);
 
                        conn->thread_is_running = TRUE;
-                       if (pthread_create(&th, &connection_attrib, 
_mysqlnd_fetch_thread, (void*)conn)) {
+                       if (pthread_create(&th, &connection_attrib, 
mysqlnd_fetch_thread, (void*)conn)) {
                                conn->thread_is_running = FALSE;
                        }
                }
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.h?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.h
diff -u php-src/ext/mysqlnd/mysqlnd.h:1.9 php-src/ext/mysqlnd/mysqlnd.h:1.10
--- php-src/ext/mysqlnd/mysqlnd.h:1.9   Mon Jan 28 23:24:05 2008
+++ php-src/ext/mysqlnd/mysqlnd.h       Tue Jan 29 18:13:12 2008
@@ -18,20 +18,18 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.h,v 1.9 2008/01/28 23:24:05 andrey Exp $ */
+/* $Id: mysqlnd.h,v 1.10 2008/01/29 18:13:12 andrey Exp $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd 5.0.3-dev - 080129 - $Revision: 1.9 $"
+#define MYSQLND_VERSION "mysqlnd 5.0.3-dev - 080129 - $Revision: 1.10 $"
 #define MYSQLND_VERSION_ID 50002
 
 /* This forces inlining of some accessor functions */
 #define MYSQLND_USE_OPTIMISATIONS 0
 
 
-//#define MYSQLND_THREADING
-
 /* #define MYSQLND_STRING_TO_INT_CONVERSION */
 /*
   This force mysqlnd to do a single (or more depending on ammount of data)
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_result.c?r1=1.13&r2=1.14&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_result.c
diff -u php-src/ext/mysqlnd/mysqlnd_result.c:1.13 
php-src/ext/mysqlnd/mysqlnd_result.c:1.14
--- php-src/ext/mysqlnd/mysqlnd_result.c:1.13   Mon Jan 28 22:54:21 2008
+++ php-src/ext/mysqlnd/mysqlnd_result.c        Tue Jan 29 18:13:12 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.c,v 1.13 2008/01/28 22:54:21 andrey Exp $ */
+/* $Id: mysqlnd_result.c,v 1.14 2008/01/29 18:13:12 andrey Exp $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -33,6 +33,62 @@
 
 #define MYSQLND_SILENT
 
+#ifdef MYSQLND_THREADED
+/* {{{ mysqlnd_fetch_thread */
+void * mysqlnd_fetch_thread(void *arg)
+{
+       MYSQLND *conn = (MYSQLND *) arg;
+       MYSQLND_RES * result = NULL;
+       void ***tsrm_ls = conn->tsrm_ls;
+#ifndef MYSQLND_SILENT
+       printf("conn=%p tsrm_ls=%p\n", conn, conn->tsrm_ls);
+#endif
+       do {
+               pthread_mutex_lock(&conn->LOCK_work);
+               while (conn->thread_killed == FALSE /* && there is work */) {
+#ifndef MYSQLND_SILENT
+                       printf("Waiting for work in %s\n", __FUNCTION__);
+#endif
+                       pthread_cond_wait(&conn->COND_work, &conn->LOCK_work);
+               }
+               if (conn->thread_killed == TRUE) {
+#ifndef MYSQLND_SILENT
+                       printf("Thread killed in %s\n", __FUNCTION__);
+#endif
+                       pthread_cond_signal(&conn->COND_thread_ended);
+                       pthread_mutex_unlock(&conn->LOCK_work);
+                       break;
+               }
+#ifndef MYSQLND_SILENT
+               printf("Got work in %s\n", __FUNCTION__);
+#endif
+               CONN_SET_STATE(conn, CONN_FETCHING_DATA);
+               result = conn->current_result;
+               conn->current_result = NULL;
+               pthread_mutex_unlock(&conn->LOCK_work);
+
+               mysqlnd_background_store_result_fetch_data(result TSRMLS_CC);
+
+               /* do fetch the data from the wire */
+
+               pthread_mutex_lock(&conn->LOCK_work);
+               CONN_SET_STATE(conn, CONN_READY);
+               pthread_cond_signal(&conn->COND_work_done);
+#ifndef MYSQLND_SILENT
+               printf("Signaling work done in %s\n", __FUNCTION__);
+#endif
+               pthread_mutex_unlock(&conn->LOCK_work);
+       } while (1);
+
+#ifndef MYSQLND_SILENT
+       printf("Exiting worker thread in %s\n", __FUNCTION__);
+#endif
+       return NULL;
+}
+/* }}} */
+#endif /* MYSQLND_THREADED */
+
+
 /* {{{ mysqlnd_res_initialize_result_set_rest */
 void mysqlnd_res_initialize_result_set_rest(MYSQLND_RES * const result 
TSRMLS_DC)
 {
@@ -1261,8 +1317,8 @@
                        break;
                }
                if (!set->data_cursor || (set->data_cursor - set->data) < 
(set->row_count)) {
-#if HAVE_USLEEP
                        tsrm_mutex_unlock(set->LOCK);
+#if HAVE_USLEEP
                        usleep(2000);
 #else
                        volatile int i = 0;
@@ -1281,6 +1337,7 @@
                /* We don't forget to release the lock */
                tsrm_mutex_unlock(set->LOCK);
 
+               /* If there was no decoding in background, we have to decode 
here */
                if (set->decode_in_foreground == TRUE) {
                        MYSQLND_MEMORY_POOL_CHUNK *current_buffer = 
set->row_buffers[row_num];
                        result->m.row_decoder(current_buffer,
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_result.h?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_result.h
diff -u php-src/ext/mysqlnd/mysqlnd_result.h:1.4 
php-src/ext/mysqlnd/mysqlnd_result.h:1.5
--- php-src/ext/mysqlnd/mysqlnd_result.h:1.4    Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd_result.h        Tue Jan 29 18:13:12 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.h,v 1.4 2008/01/28 18:27:49 andrey Exp $ */
+/* $Id: mysqlnd_result.h,v 1.5 2008/01/29 18:13:12 andrey Exp $ */
 
 #ifndef MYSQLND_RESULT_H
 #define MYSQLND_RESULT_H
@@ -38,6 +38,10 @@
 void mysqlnd_res_initialize_result_set_rest(MYSQLND_RES * const result 
TSRMLS_DC);
 
 
+#ifdef MYSQLND_THREADED
+void * mysqlnd_fetch_thread(void *arg);
+#endif
+
 enum_func_status mysqlnd_background_store_result_fetch_data(MYSQLND_RES 
*result TSRMLS_DC);
 #endif /* MYSQLND_RESULT_H */
 

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

Reply via email to