Permalink
Browse files

close the underlying stream as early as possible and so notify the

NET layer
  • Loading branch information...
1 parent ad60e18 commit 2c230fb574fb2b3e17a74b6678ab36b6572a3c7a andrey committed Jun 1, 2012
Showing with 19 additions and 17 deletions.
  1. +6 −7 ext/mysqlnd/mysqlnd.c
  2. +13 −10 ext/mysqlnd/mysqlnd_net.c
View
@@ -1849,8 +1849,9 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR
DBG_INF("Connection clean, sending COM_QUIT");
if (net_stream) {
ret = conn->m->simple_command(conn, COM_QUIT, NULL, 0, PROT_LAST, TRUE, TRUE TSRMLS_CC);
+ net->data->m.close_stream(net, conn->stats, conn->error_info TSRMLS_CC);
}
- /* Do nothing */
+ CONN_SET_STATE(conn, CONN_QUIT_SENT);
break;
case CONN_SENDING_LOAD_DATA:
/*
@@ -1866,23 +1867,21 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR
Do nothing, the connection will be brutally closed
and the server will catch it and free close from its side.
*/
+ /* Fall-through */
case CONN_ALLOCED:
/*
Allocated but not connected or there was failure when trying
to connect with pre-allocated connect.
Fall-through
*/
+ CONN_SET_STATE(conn, CONN_QUIT_SENT);
+ net->data->m.close_stream(net, conn->stats, conn->error_info TSRMLS_CC);
+ /* Fall-through */
case CONN_QUIT_SENT:
/* The user has killed its own connection */
break;
}
- /*
- We hold one reference, and every other object which needs the
- connection does increase it by 1.
- */
- CONN_SET_STATE(conn, CONN_QUIT_SENT);
- net->data->m.close_stream(net, conn->stats, conn->error_info TSRMLS_CC);
DBG_RETURN(ret);
}
View
@@ -239,17 +239,19 @@ MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net,
{
php_stream * net_stream = net->data->m.get_stream(net TSRMLS_CC);
DBG_ENTER("mysqlnd_net::post_connect_set_opt");
- if (net->data->options.timeout_read) {
- struct timeval tv;
- DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read);
- tv.tv_sec = net->data->options.timeout_read;
- tv.tv_usec = 0;
- php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
- }
+ if (net_stream) {
+ if (net->data->options.timeout_read) {
+ struct timeval tv;
+ DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read);
+ tv.tv_sec = net->data->options.timeout_read;
+ tv.tv_usec = 0;
+ php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
+ }
- if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) {
- /* TCP -> Set TCP_NODELAY */
- mysqlnd_set_sock_no_delay(net_stream TSRMLS_CC);
+ if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) {
+ /* TCP -> Set TCP_NODELAY */
+ mysqlnd_set_sock_no_delay(net_stream TSRMLS_CC);
+ }
}
DBG_VOID_RETURN;
@@ -1051,6 +1053,7 @@ static php_stream *
MYSQLND_METHOD(mysqlnd_net, get_stream)(const MYSQLND_NET * const net TSRMLS_DC)
{
DBG_ENTER("mysqlnd_net::get_stream");
+ DBG_INF_FMT("%p", net? net->data->stream:NULL);
DBG_RETURN(net? net->data->stream:NULL);
}
/* }}} */

0 comments on commit 2c230fb

Please sign in to comment.