andrey Tue Jan 29 18:11:46 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/mysqlnd php_mysqlnd.c
Modified files: /php-src/ext/mysqlnd config9.m4 mysqlnd.c mysqlnd.h mysqlnd_result.c mysqlnd_result.h mysqlnd_structs.h Log: Fix the build, add a missing file
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/config9.m4?r1=1.3.2.5&r2=1.3.2.6&diff_format=u Index: php-src/ext/mysqlnd/config9.m4 diff -u php-src/ext/mysqlnd/config9.m4:1.3.2.5 php-src/ext/mysqlnd/config9.m4:1.3.2.6 --- php-src/ext/mysqlnd/config9.m4:1.3.2.5 Mon Jan 28 23:23:08 2008 +++ php-src/ext/mysqlnd/config9.m4 Tue Jan 29 18:11:46 2008 @@ -1,7 +1,12 @@ dnl -dnl $Id: config9.m4,v 1.3.2.5 2008/01/28 23:23:08 andrey Exp $ +dnl $Id: config9.m4,v 1.3.2.6 2008/01/29 18:11:46 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.5.2.12&r2=1.5.2.13&diff_format=u Index: php-src/ext/mysqlnd/mysqlnd.c diff -u php-src/ext/mysqlnd/mysqlnd.c:1.5.2.12 php-src/ext/mysqlnd/mysqlnd.c:1.5.2.13 --- php-src/ext/mysqlnd/mysqlnd.c:1.5.2.12 Tue Jan 29 11:59:53 2008 +++ php-src/ext/mysqlnd/mysqlnd.c Tue Jan 29 18:11:46 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd.c,v 1.5.2.12 2008/01/29 11:59:53 andrey Exp $ */ +/* $Id: mysqlnd.c,v 1.5.2.13 2008/01/29 18:11:46 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.3.2.7&r2=1.3.2.8&diff_format=u Index: php-src/ext/mysqlnd/mysqlnd.h diff -u php-src/ext/mysqlnd/mysqlnd.h:1.3.2.7 php-src/ext/mysqlnd/mysqlnd.h:1.3.2.8 --- php-src/ext/mysqlnd/mysqlnd.h:1.3.2.7 Mon Jan 28 23:23:08 2008 +++ php-src/ext/mysqlnd/mysqlnd.h Tue Jan 29 18:11:46 2008 @@ -18,20 +18,18 @@ +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd.h,v 1.3.2.7 2008/01/28 23:23:08 andrey Exp $ */ +/* $Id: mysqlnd.h,v 1.3.2.8 2008/01/29 18:11:46 andrey Exp $ */ #ifndef MYSQLND_H #define MYSQLND_H -#define MYSQLND_VERSION "mysqlnd 5.0.3-dev - 080129 - $Revision: 1.3.2.7 $" +#define MYSQLND_VERSION "mysqlnd 5.0.3-dev - 080129 - $Revision: 1.3.2.8 $" #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.4.2.9&r2=1.4.2.10&diff_format=u Index: php-src/ext/mysqlnd/mysqlnd_result.c diff -u php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.9 php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.10 --- php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.9 Mon Jan 28 22:50:06 2008 +++ php-src/ext/mysqlnd/mysqlnd_result.c Tue Jan 29 18:11:46 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd_result.c,v 1.4.2.9 2008/01/28 22:50:06 andrey Exp $ */ +/* $Id: mysqlnd_result.c,v 1.4.2.10 2008/01/29 18:11:46 andrey Exp $ */ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" @@ -32,6 +32,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) { @@ -1260,8 +1316,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; @@ -1280,6 +1336,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.2.2.6&r2=1.2.2.7&diff_format=u Index: php-src/ext/mysqlnd/mysqlnd_result.h diff -u php-src/ext/mysqlnd/mysqlnd_result.h:1.2.2.6 php-src/ext/mysqlnd/mysqlnd_result.h:1.2.2.7 --- php-src/ext/mysqlnd/mysqlnd_result.h:1.2.2.6 Mon Jan 28 18:25:50 2008 +++ php-src/ext/mysqlnd/mysqlnd_result.h Tue Jan 29 18:11:46 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd_result.h,v 1.2.2.6 2008/01/28 18:25:50 andrey Exp $ */ +/* $Id: mysqlnd_result.h,v 1.2.2.7 2008/01/29 18:11:46 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 */ http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_structs.h?r1=1.2.2.8&r2=1.2.2.9&diff_format=u Index: php-src/ext/mysqlnd/mysqlnd_structs.h diff -u php-src/ext/mysqlnd/mysqlnd_structs.h:1.2.2.8 php-src/ext/mysqlnd/mysqlnd_structs.h:1.2.2.9 --- php-src/ext/mysqlnd/mysqlnd_structs.h:1.2.2.8 Mon Jan 28 22:50:06 2008 +++ php-src/ext/mysqlnd/mysqlnd_structs.h Tue Jan 29 18:11:46 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd_structs.h,v 1.2.2.8 2008/01/28 22:50:06 andrey Exp $ */ +/* $Id: mysqlnd_structs.h,v 1.2.2.9 2008/01/29 18:11:46 andrey Exp $ */ #ifndef MYSQLND_STRUCTS_H #define MYSQLND_STRUCTS_H @@ -448,7 +448,7 @@ /* stats */ MYSQLND_STATS stats; -#ifdef ZTS +#ifdef MYSQLND_THREADED MUTEX_T LOCK_state; pthread_cond_t COND_work_done; http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/php_mysqlnd.c?view=markup&rev=1.1 Index: php-src/ext/mysqlnd/php_mysqlnd.c +++ php-src/ext/mysqlnd/php_mysqlnd.c
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php