]> granicus.if.org Git - php/commitdiff
these methods should return a stream. This makes it easier to intercept
authorandrey <andrey@php.net>
Mon, 7 May 2012 13:32:00 +0000 (15:32 +0200)
committerandrey <andrey@php.net>
Mon, 7 May 2012 13:32:00 +0000 (15:32 +0200)
the return value

ext/mysqlnd/mysqlnd_net.c
ext/mysqlnd/mysqlnd_structs.h

index b2fe662bbf261786416bed70477788ea905bc420..a641a41d2f9ee1268a0bc5065c7b9317abe12466 100644 (file)
@@ -105,7 +105,7 @@ MYSQLND_METHOD(mysqlnd_net, network_write_ex)(MYSQLND_NET * const net, const zen
 /* }}} */
 
 /* {{{ mysqlnd_net::open_pipe */
-static enum_func_status
+static php_stream *
 MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
                                                                           const zend_bool persistent,
                                                                           MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
@@ -125,7 +125,7 @@ MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * con
        net_stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL);
        if (!net_stream) {
                SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "Unknown errror while connecting");
-               DBG_RETURN(FAIL);
+               DBG_RETURN(NULL);
        }
        /*
          Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
@@ -136,15 +136,14 @@ MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * con
        zend_hash_index_del(&EG(regular_list), net_stream->rsrc_id);
        net_stream->in_free = 0;
 
-       (void) net->data->m.set_stream(net, net_stream TSRMLS_CC);
 
-       DBG_RETURN(PASS);
+       DBG_RETURN(net_stream);
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_net::open_tcp_or_unix */
-static enum_func_status
+static php_stream *
 MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
                                                                                          const zend_bool persistent,
                                                                                          MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
@@ -191,7 +190,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha
                        /* no mnd_ since we don't allocate it */
                        efree(errstr);
                }
-               DBG_RETURN(FAIL);
+               DBG_RETURN(NULL);
        }
        if (hashed_details) {
                /*
@@ -227,8 +226,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha
        zend_hash_index_del(&EG(regular_list), net_stream->rsrc_id);
        net_stream->in_free = 0;
 
-       (void) net->data->m.set_stream(net, net_stream TSRMLS_CC);
-       DBG_RETURN(PASS);
+       DBG_RETURN(net_stream);
 }
 /* }}} */
 
@@ -300,8 +298,11 @@ MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * co
 
        open_stream = net->data->m.get_open_stream(net, scheme, scheme_len, error_info TSRMLS_CC);
        if (open_stream) {
-               if (PASS == (ret = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info TSRMLS_CC))) {
+               php_stream * net_stream = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info TSRMLS_CC);
+               if (net_stream) {
+                       (void) net->data->m.set_stream(net, net_stream TSRMLS_CC);
                        net->data->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info TSRMLS_CC);
+                       ret = PASS;
                }
        }
 
index 6dcb8b36dd31c0822feb83e8a8bfb56258c1458b..b355a0d5f628676113a5165de7780ac30ea3db17 100644 (file)
@@ -283,7 +283,7 @@ typedef enum_func_status    (*func_mysqlnd_net__init)(MYSQLND_NET * const net, MYSQ
 typedef void                           (*func_mysqlnd_net__dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
 typedef enum_func_status       (*func_mysqlnd_net__connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
 typedef void                           (*func_mysqlnd_net__close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
-typedef enum_func_status       (*func_mysqlnd_net__open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
+typedef php_stream *           (*func_mysqlnd_net__open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
 typedef php_stream *           (*func_mysqlnd_net__get_stream)(const MYSQLND_NET * const net TSRMLS_DC);
 typedef php_stream *           (*func_mysqlnd_net__set_stream)(MYSQLND_NET * const net, php_stream * net_stream TSRMLS_DC);
 typedef func_mysqlnd_net__open_stream (*func_mysqlnd_net__get_open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);