[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2010-12-15 Thread Andrey Hristov
andrey   Wed, 15 Dec 2010 14:14:58 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=306386

Log:
count preciser in case of error

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-12-15 
13:47:14 UTC (rev 306385)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-12-15 
14:14:58 UTC (rev 306386)
@@ -64,6 +64,7 @@
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_net, network_read)(MYSQLND * conn, zend_uchar * buffer, 
size_t count TSRMLS_DC)
 {
+   enum_func_status return_value = PASS;
size_t to_read = count, ret;
size_t old_chunk_size = conn-net-stream-chunk_size;
DBG_ENTER(mysqlnd_net::network_read);
@@ -72,14 +73,15 @@
while (to_read) {
if (!(ret = php_stream_read(conn-net-stream, (char *) buffer, 
to_read))) {
DBG_ERR_FMT(Error while reading header from socket);
-   DBG_RETURN(FAIL);
+   return_value = FAIL;
+   break;
}
buffer += ret;
to_read -= ret;
}
-   MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn-stats, STAT_BYTES_RECEIVED, 
count);
+   MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn-stats, STAT_BYTES_RECEIVED, 
count - to_read);
conn-net-stream-chunk_size = old_chunk_size;
-   DBG_RETURN(PASS);
+   DBG_RETURN(return_value);
 }
 /* }}} */


Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-12-15 13:47:14 UTC (rev 
306385)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-12-15 14:14:58 UTC (rev 
306386)
@@ -64,6 +64,7 @@
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_net, network_read)(MYSQLND * conn, zend_uchar * buffer, 
size_t count TSRMLS_DC)
 {
+   enum_func_status return_value = PASS;
size_t to_read = count, ret;
size_t old_chunk_size = conn-net-stream-chunk_size;
DBG_ENTER(mysqlnd_net::network_read);
@@ -72,14 +73,15 @@
while (to_read) {
if (!(ret = php_stream_read(conn-net-stream, (char *) buffer, 
to_read))) {
DBG_ERR_FMT(Error while reading header from socket);
-   DBG_RETURN(FAIL);
+   return_value = FAIL;
+   break;
}
buffer += ret;
to_read -= ret;
}
-   MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn-stats, STAT_BYTES_RECEIVED, 
count);
+   MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn-stats, STAT_BYTES_RECEIVED, 
count - to_read);
conn-net-stream-chunk_size = old_chunk_size;
-   DBG_RETURN(PASS);
+   DBG_RETURN(return_value);
 }
 /* }}} */


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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2010-10-05 Thread Andrey Hristov
andrey   Tue, 05 Oct 2010 08:17:33 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=304065

Log:
fix recent TSRM build break, with --enable-debug

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-10-05 
03:33:46 UTC (rev 304064)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-10-05 
08:17:33 UTC (rev 304065)
@@ -41,7 +41,7 @@

 /* {{{ mysqlnd_set_sock_no_delay */
 static int
-mysqlnd_set_sock_no_delay(php_stream * stream)
+mysqlnd_set_sock_no_delay(php_stream * stream TSRMLS_DC)
 {

int socketd = ((php_netstream_data_t*)stream-abstract)-socket;
@@ -183,7 +183,7 @@

if (!memcmp(scheme, tcp://, sizeof(tcp://) - 1)) {
/* TCP - Set TCP_NODELAY */
-   mysqlnd_set_sock_no_delay(net-stream);
+   mysqlnd_set_sock_no_delay(net-stream TSRMLS_CC);
}

{

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-10-05 03:33:46 UTC (rev 
304064)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-10-05 08:17:33 UTC (rev 
304065)
@@ -41,7 +41,7 @@

 /* {{{ mysqlnd_set_sock_no_delay */
 static int
-mysqlnd_set_sock_no_delay(php_stream * stream)
+mysqlnd_set_sock_no_delay(php_stream * stream TSRMLS_DC)
 {

int socketd = ((php_netstream_data_t*)stream-abstract)-socket;
@@ -190,7 +190,7 @@

if (!memcmp(scheme, tcp://, sizeof(tcp://) - 1)) {
/* TCP - Set TCP_NODELAY */
-   mysqlnd_set_sock_no_delay(net-stream);
+   mysqlnd_set_sock_no_delay(net-stream TSRMLS_CC);
}

{

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2010-10-04 Thread Kalle Sommer Nielsen
kalleMon, 04 Oct 2010 21:04:25 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=304038

Log:
We do not need this TSRMLS_FETCH() call as we do not use any TSRM stuff in 
here, so we can get
a minor boost here in ZTS mode.

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-10-04 
20:33:58 UTC (rev 304037)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-10-04 
21:04:25 UTC (rev 304038)
@@ -48,7 +48,6 @@
int ret = SUCCESS;
int flag = 1;
int result = setsockopt(socketd, IPPROTO_TCP,  TCP_NODELAY, (char *) 
flag, sizeof(int));
-   TSRMLS_FETCH();

DBG_ENTER(mysqlnd_set_sock_no_delay);


Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-10-04 20:33:58 UTC (rev 
304037)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-10-04 21:04:25 UTC (rev 
304038)
@@ -48,7 +48,6 @@
int ret = SUCCESS;
int flag = 1;
int result = setsockopt(socketd, IPPROTO_TCP,  TCP_NODELAY, (char *) 
flag, sizeof(int));
-   TSRMLS_FETCH();

DBG_ENTER(mysqlnd_set_sock_no_delay);


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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2010-05-25 Thread Andrey Hristov
andrey   Tue, 25 May 2010 22:36:33 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=299759

Log:
Use only memory that has been allocated

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-05-25 
22:34:47 UTC (rev 299758)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-05-25 
22:36:33 UTC (rev 299759)
@@ -885,13 +885,14 @@

DBG_ENTER(mysqlnd_net_init);
DBG_INF_FMT(persistent=%d, persistent);
-   net-persistent = persistent;
+   if (net) {
+   net-persistent = persistent;
+   net-m = mysqlnd_mysqlnd_net_methods;

-   net-m = mysqlnd_mysqlnd_net_methods;
-
-   {
-   unsigned int buf_size = MYSQLND_G(net_cmd_buffer_size); /* this 
is long, cast to unsigned int*/
-   net-m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, 
(char *) buf_size TSRMLS_CC);
+   {
+   unsigned int buf_size = MYSQLND_G(net_cmd_buffer_size); 
/* this is long, cast to unsigned int*/
+   net-m.set_client_option(net, 
MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) buf_size TSRMLS_CC);
+   }
}
DBG_RETURN(net);
 }

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-05-25 22:34:47 UTC (rev 
299758)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-05-25 22:36:33 UTC (rev 
299759)
@@ -885,13 +885,14 @@

DBG_ENTER(mysqlnd_net_init);
DBG_INF_FMT(persistent=%d, persistent);
-   net-persistent = persistent;
+   if (net) {
+   net-persistent = persistent;
+   net-m = mysqlnd_mysqlnd_net_methods;

-   net-m = mysqlnd_mysqlnd_net_methods;
-
-   {
-   unsigned int buf_size = MYSQLND_G(net_cmd_buffer_size); /* this 
is long, cast to unsigned int*/
-   net-m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, 
(char *) buf_size TSRMLS_CC);
+   {
+   unsigned int buf_size = MYSQLND_G(net_cmd_buffer_size); 
/* this is long, cast to unsigned int*/
+   net-m.set_client_option(net, 
MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) buf_size TSRMLS_CC);
+   }
}
DBG_RETURN(net);
 }

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2010-04-01 Thread Andrey Hristov
andrey   Thu, 01 Apr 2010 12:46:21 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=297274

Log:
Better fix for bug #51347 mysqli_close / connection memory leak

Bug: http://bugs.php.net/51347 (Open) mysqli_close / connection memory leak
  
Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-04-01 
12:08:55 UTC (rev 297273)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-04-01 
12:46:21 UTC (rev 297274)
@@ -159,6 +159,14 @@
 #endif
efree(hashed_details);
}
+   /*
+ Streams are not meant for C extensions! Thus we need a hack. Every 
connected stream will
+ be registered as resource (in EG(regular_list). So far, so good. 
However, it won't be
+ unregistered till the script ends. So, we need to take care of that.
+   */
+   net-stream-in_free = 1;
+   zend_hash_index_del(EG(regular_list), net-stream-rsrc_id);
+   net-stream-in_free = 0;

if (!net-options.timeout_read) {
/* should always happen because read_timeout cannot be set via 
API */
@@ -703,15 +711,6 @@
mnd_pefree(net-cmd_buffer.buffer, pers);
net-cmd_buffer.buffer = NULL;
}
-   /*
- Streams are not meant for C extensions! Thus we need a hack. 
Every connected stream will
- be registered as resource (in EG(regular_list). So far, so 
good. However, it won't be
- unregistered till the script ends. So, we need to take care 
of that.
- */
-   net-stream-in_free = 1;
-   zend_hash_index_del(EG(regular_list), net-stream-rsrc_id);
-   net-stream-in_free = 0;
-
if (net-stream) {
DBG_INF_FMT(Freeing stream. abstract=%p, 
net-stream-abstract);
if (pers) {

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-04-01 12:08:55 UTC (rev 
297273)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-04-01 12:46:21 UTC (rev 
297274)
@@ -159,6 +159,14 @@
 #endif
efree(hashed_details);
}
+   /*
+ Streams are not meant for C extensions! Thus we need a hack. Every 
connected stream will
+ be registered as resource (in EG(regular_list). So far, so good. 
However, it won't be
+ unregistered till the script ends. So, we need to take care of that.
+   */
+   net-stream-in_free = 1;
+   zend_hash_index_del(EG(regular_list), net-stream-rsrc_id);
+   net-stream-in_free = 0;

if (!net-options.timeout_read) {
/* should always happen because read_timeout cannot be set via 
API */
@@ -703,15 +711,6 @@
mnd_pefree(net-cmd_buffer.buffer, pers);
net-cmd_buffer.buffer = NULL;
}
-   /*
- Streams are not meant for C extensions! Thus we need a hack. 
Every connected stream will
- be registered as resource (in EG(regular_list). So far, so 
good. However, it won't be
- unregistered till the script ends. So, we need to take care 
of that.
- */
-   net-stream-in_free = 1;
-   zend_hash_index_del(EG(regular_list), net-stream-rsrc_id);
-   net-stream-in_free = 0;
-
if (net-stream) {
DBG_INF_FMT(Freeing stream. abstract=%p, 
net-stream-abstract);
if (pers) {

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2010-01-14 Thread Andrey Hristov
andrey   Thu, 14 Jan 2010 12:31:29 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=293542

Log:
Fix compiler warning, copypaste error

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-01-14 
12:30:30 UTC (rev 293541)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2010-01-14 
12:31:29 UTC (rev 293542)
@@ -475,7 +475,7 @@


 /* {{{ mysqlnd_net::receive */
-static enum_func_status
+static size_t
 MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, 
size_t count TSRMLS_DC)
 {
size_t to_read = count;

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-01-14 12:30:30 UTC (rev 
293541)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-01-14 12:31:29 UTC (rev 
293542)
@@ -475,7 +475,7 @@


 /* {{{ mysqlnd_net::receive */
-static enum_func_status
+static size_t
 MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, 
size_t count TSRMLS_DC)
 {
size_t to_read = count;

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c trunk/ext/mysqlnd/mysqlnd_net.c

2009-12-16 Thread Andrey Hristov
andrey   Wed, 16 Dec 2009 14:38:30 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=292212

Log:
call free_contents in every case, in case something is not freed
by the calling code

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2009-12-16 
14:06:09 UTC (rev 292211)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c  2009-12-16 
14:38:30 UTC (rev 292212)
@@ -287,6 +287,7 @@
DBG_ENTER(mysqlnd_net_free);

if (net) {
+   net-m.free_contents(net TSRMLS_CC);
if (net-cmd_buffer.buffer) {
DBG_INF(Freeing cmd buffer);
mnd_pefree(net-cmd_buffer.buffer, pers);

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2009-12-16 14:06:09 UTC (rev 
292211)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2009-12-16 14:38:30 UTC (rev 
292212)
@@ -287,6 +287,7 @@
DBG_ENTER(mysqlnd_net_free);

if (net) {
+   net-m.free_contents(net TSRMLS_CC);
if (net-cmd_buffer.buffer) {
DBG_INF(Freeing cmd buffer);
mnd_pefree(net-cmd_buffer.buffer, pers);

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