diff options
| author | Andrey Hristov <andrey@php.net> | 2015-12-01 12:52:36 +0100 |
|---|---|---|
| committer | Andrey Hristov <andrey@php.net> | 2015-12-01 12:52:36 +0100 |
| commit | 139af35c2535668283a38283aab4907ebb03d2b5 (patch) | |
| tree | fc36d4bb873f698ddad5e300ecbe7c9b0388b695 /ext/mysqlnd/mysqlnd_vio.c | |
| parent | 671be5b8646ceef5a3555040cb9741cc070110d9 (diff) | |
| download | php-git-139af35c2535668283a38283aab4907ebb03d2b5.tar.gz | |
Add a method for checking if the underlying stream is valid.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_vio.c')
| -rw-r--r-- | ext/mysqlnd/mysqlnd_vio.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/ext/mysqlnd/mysqlnd_vio.c b/ext/mysqlnd/mysqlnd_vio.c index f559ba6c0e..2b28cc6914 100644 --- a/ext/mysqlnd/mysqlnd_vio.c +++ b/ext/mysqlnd/mysqlnd_vio.c @@ -74,7 +74,7 @@ mysqlnd_set_sock_keepalive(php_stream * stream) /* {{{ mysqlnd_vio::network_read */ static enum_func_status MYSQLND_METHOD(mysqlnd_vio, network_read)(MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count, - MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info) + MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info) { enum_func_status return_value = PASS; php_stream * net_stream = vio->data->m.get_stream(vio); @@ -105,7 +105,7 @@ MYSQLND_METHOD(mysqlnd_vio, network_read)(MYSQLND_VIO * const vio, zend_uchar * /* {{{ mysqlnd_vio::network_write */ static size_t MYSQLND_METHOD(mysqlnd_vio, network_write)(MYSQLND_VIO * const vio, const zend_uchar * const buffer, const size_t count, - MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info) + MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info) { size_t ret; DBG_ENTER("mysqlnd_vio::network_write"); @@ -318,8 +318,7 @@ MYSQLND_METHOD(mysqlnd_vio, connect)(MYSQLND_VIO * const vio, const MYSQLND_CSTR open_stream = vio->data->m.get_open_stream(vio, scheme, error_info); if (open_stream) { php_stream * net_stream = open_stream(vio, scheme, persistent, conn_stats, error_info); - if (net_stream) { - (void) vio->data->m.set_stream(vio, net_stream); + if (net_stream && PASS == vio->data->m.set_stream(vio, net_stream)) { vio->data->m.post_connect_set_opt(vio, scheme, conn_stats, error_info); ret = PASS; } @@ -676,7 +675,7 @@ MYSQLND_METHOD(mysqlnd_vio, close_stream)(MYSQLND_VIO * const net, MYSQLND_STATS } else { php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE); } - (void) net->data->m.set_stream(net, NULL); + net->data->m.set_stream(net, NULL); } DBG_VOID_RETURN; @@ -731,16 +730,26 @@ MYSQLND_METHOD(mysqlnd_vio, get_stream)(const MYSQLND_VIO * const net) /* {{{ mysqlnd_vio::set_stream */ -static php_stream * -MYSQLND_METHOD(mysqlnd_vio, set_stream)(MYSQLND_VIO * const net, php_stream * net_stream) +static enum_func_status +MYSQLND_METHOD(mysqlnd_vio, set_stream)(MYSQLND_VIO * const vio, php_stream * net_stream) { - php_stream * ret = NULL; DBG_ENTER("mysqlnd_vio::set_stream"); - if (net) { - net->data->stream = net_stream; - ret = net->data->stream; + if (vio) { + vio->data->stream = net_stream; + DBG_RETURN(PASS); } - DBG_RETURN(ret); + DBG_RETURN(FAIL); +} +/* }}} */ + + +/* {{{ mysqlnd_vio::has_valid_stream */ +static zend_bool +MYSQLND_METHOD(mysqlnd_vio, has_valid_stream)(const MYSQLND_VIO * const vio) +{ + DBG_ENTER("mysqlnd_vio::has_valid_stream"); + DBG_INF_FMT("%p %p", vio, vio? vio->data->stream:NULL); + DBG_RETURN((vio && vio->data->stream)? TRUE: FALSE); } /* }}} */ @@ -757,6 +766,7 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_vio) MYSQLND_METHOD(mysqlnd_vio, get_stream), MYSQLND_METHOD(mysqlnd_vio, set_stream), + MYSQLND_METHOD(mysqlnd_vio, has_valid_stream), MYSQLND_METHOD(mysqlnd_vio, get_open_stream), MYSQLND_METHOD(mysqlnd_vio, set_client_option), |
