From 4c26112c884c7cc4bf38dcfac755100434f78b1f Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Wed, 22 Sep 2010 15:14:04 +0000 Subject: Fix for Request #48082 mysql_connect does not work with named pipes --- ext/mysqlnd/mysqlnd_net.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_net.c') diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 3d25362f82..c4c361bb5d 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -113,23 +113,30 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem struct timeval tv; DBG_ENTER("mysqlnd_net::connect"); - if (persistent) { - hashed_details_len = spprintf(&hashed_details, 0, "%p", net); - DBG_INF_FMT("hashed_details=%s", hashed_details); - } - net->packet_no = net->compressed_envelope_packet_no = 0; - if (net->options.timeout_connect) { - tv.tv_sec = net->options.timeout_connect; - tv.tv_usec = 0; - } + if (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1)) { + if (persistent) { + streams_options |= STREAM_OPEN_PERSISTENT; + } + streams_options |= IGNORE_URL; + net->stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL); + } else { + if (persistent) { + hashed_details_len = spprintf(&hashed_details, 0, "%p", net); + DBG_INF_FMT("hashed_details=%s", hashed_details); + } - DBG_INF_FMT("calling php_stream_xport_create"); - net->stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags, - hashed_details, (net->options.timeout_connect) ? &tv : NULL, - NULL /*ctx*/, errstr, errcode); + if (net->options.timeout_connect) { + tv.tv_sec = net->options.timeout_connect; + tv.tv_usec = 0; + } + DBG_INF_FMT("calling php_stream_xport_create"); + net->stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags, + hashed_details, (net->options.timeout_connect) ? &tv : NULL, + NULL /*ctx*/, errstr, errcode); + } if (*errstr || !net->stream) { if (hashed_details) { efree(hashed_details); /* allocated by spprintf */ -- cgit v1.2.1