summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_driver.c
diff options
context:
space:
mode:
authorandrey <andrey@php.net>2012-04-30 17:01:56 +0200
committerandrey <andrey@php.net>2012-04-30 17:01:56 +0200
commit174bf906f8cf96cf0c1c1719bde9c7a7f1fa7064 (patch)
tree2f5f5908bed578759d0152af283e57b48abcd2ea /ext/mysqlnd/mysqlnd_driver.c
parent743a74a3c5aaffbaa3a5248ca310d6ca8b41015f (diff)
downloadphp-git-174bf906f8cf96cf0c1c1719bde9c7a7f1fa7064.tar.gz
refactor MYSQLND_NET, split it two parts for easy resharing
Diffstat (limited to 'ext/mysqlnd/mysqlnd_driver.c')
-rw-r--r--ext/mysqlnd/mysqlnd_driver.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c
index e645b88935..e55a0bc2ee 100644
--- a/ext/mysqlnd/mysqlnd_driver.c
+++ b/ext/mysqlnd/mysqlnd_driver.c
@@ -249,17 +249,29 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
PHPAPI MYSQLND_NET *
MYSQLND_METHOD(mysqlnd_object_factory, get_io_channel)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC)
{
- size_t alloc_size = sizeof(MYSQLND_NET) + mysqlnd_plugin_count() * sizeof(void *);
- MYSQLND_NET * net = mnd_pecalloc(1, alloc_size, persistent);
+ size_t net_alloc_size = sizeof(MYSQLND_NET) + mysqlnd_plugin_count() * sizeof(void *);
+ size_t net_data_alloc_size = sizeof(MYSQLND_NET_DATA) + mysqlnd_plugin_count() * sizeof(void *);
+ MYSQLND_NET * net = mnd_pecalloc(1, net_alloc_size, persistent);
+ MYSQLND_NET_DATA * net_data = mnd_pecalloc(1, net_data_alloc_size, persistent);
DBG_ENTER("mysqlnd_object_factory::get_io_channel");
DBG_INF_FMT("persistent=%u", persistent);
- if (net) {
- net->persistent = persistent;
- net->m = *mysqlnd_net_get_methods();
+ if (net && net_data) {
+ net->data = net_data;
+ net->persistent = net->data->persistent = persistent;
+ net->data->m = *mysqlnd_net_get_methods();
- if (PASS != net->m.init(net, stats, error_info TSRMLS_CC)) {
- net->m.dtor(net, stats, error_info TSRMLS_CC);
+ if (PASS != net->data->m.init(net, stats, error_info TSRMLS_CC)) {
+ net->data->m.dtor(net, stats, error_info TSRMLS_CC);
+ net = NULL;
+ }
+ } else {
+ if (net_data) {
+ mnd_pefree(net_data, persistent);
+ net_data = NULL;
+ }
+ if (net) {
+ mnd_pefree(net, persistent);
net = NULL;
}
}