]> granicus.if.org Git - php/commitdiff
close the underlying stream as early as possible and so notify the
authorandrey <andrey@php.net>
Fri, 1 Jun 2012 19:12:08 +0000 (22:12 +0300)
committerandrey <andrey@php.net>
Fri, 1 Jun 2012 19:12:08 +0000 (22:12 +0300)
NET layer

ext/mysqlnd/mysqlnd.c
ext/mysqlnd/mysqlnd_net.c

index 705dac3d4502efa8aaab10d5d382747f2255d69c..cc3a3917a18074f87fdff8d79e7adc6246a9c554 100644 (file)
@@ -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);
 }
index a641a41d2f9ee1268a0bc5065c7b9317abe12466..7458f76528db6b42fcfdf49d4c2fdf2c7fa5825f 100644 (file)
@@ -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);
 }
 /* }}} */