diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 705dac3d4502e..cc3a3917a1807 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -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,6 +1867,7 @@ 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 @@ -1873,16 +1875,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR 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); } diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index a641a41d2f9ee..7458f76528db6 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -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); } /* }}} */