summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mysqlnd/mysqlnd.c17
-rw-r--r--ext/mysqlnd/mysqlnd_structs.h2
2 files changed, 11 insertions, 8 deletions
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index a13ea42..a9356da 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -2140,7 +2140,7 @@ MYSQLND_METHOD(mysqlnd_conn, get_connection_stats)(const MYSQLND * const conn,
MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC);
-static void MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC);
+static enum_func_status MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC);
static
MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
@@ -2217,17 +2217,17 @@ MYSQLND_CLASS_METHODS_END;
/* {{{ mysqlnd_conn::init */
-static void
+static enum_func_status
MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC)
{
DBG_ENTER("mysqlnd_conn::init");
- conn->net = mysqlnd_net_init(conn->persistent TSRMLS_CC);
- conn->protocol = mysqlnd_protocol_init(conn->persistent TSRMLS_CC);
mysqlnd_stats_init(&conn->stats, STAT_LAST);
-
SET_ERROR_AFF_ROWS(conn);
- DBG_VOID_RETURN;
+ conn->net = mysqlnd_net_init(conn->persistent TSRMLS_CC);
+ conn->protocol = mysqlnd_protocol_init(conn->persistent TSRMLS_CC);
+
+ DBG_RETURN(conn->net && conn->protocol? PASS:FAIL);
}
/* }}} */
@@ -2249,7 +2249,10 @@ PHPAPI MYSQLND * _mysqlnd_init(zend_bool persistent TSRMLS_DC)
CONN_SET_STATE(ret, CONN_ALLOCED);
ret->m->get_reference(ret TSRMLS_CC);
- ret->m->init(ret TSRMLS_CC);
+ if (PASS != ret->m->init(ret TSRMLS_CC)) {
+ ret->m->dtor(ret TSRMLS_CC);
+ ret = NULL;
+ }
DBG_RETURN(ret);
}
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index 0a2c928..de08a7f 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -334,7 +334,7 @@ struct st_mysqlnd_protocol_methods
-typedef void (*func_mysqlnd_conn__init)(MYSQLND * conn TSRMLS_DC);
+typedef enum_func_status (*func_mysqlnd_conn__init)(MYSQLND * conn TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn__connect)(MYSQLND *conn, const char *host, const char * user, const char * passwd, unsigned int passwd_len, const char * db, unsigned int db_len, unsigned int port, const char * socket, unsigned int mysql_flags TSRMLS_DC);
typedef ulong (*func_mysqlnd_conn__escape_string)(const MYSQLND * const conn, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn__set_charset)(MYSQLND * const conn, const char * const charset TSRMLS_DC);