mnd_pefree(conn->unix_socket, pers);
conn->unix_socket = NULL;
}
- DBG_INF_FMT("scheme=%s", conn->scheme);
- if (conn->scheme) {
- mnd_pefree(conn->scheme, pers);
- conn->scheme = NULL;
+ DBG_INF_FMT("scheme=%s", conn->scheme.s);
+ if (conn->scheme.s) {
+ mnd_pefree(conn->scheme.s, pers);
+ conn->scheme.s = NULL;
}
if (conn->server_version) {
mnd_pefree(conn->server_version, pers);
DBG_RETURN(FAIL); /* OOM */
}
- if (FAIL == net->data->m.connect_ex(conn->net, conn->scheme, conn->scheme_len, conn->persistent,
+ if (FAIL == net->data->m.connect_ex(conn->net, conn->scheme, conn->persistent,
conn->stats, conn->error_info))
{
goto err;
SET_OOM_ERROR(conn->error_info);
goto err; /* OOM */
}
- DBG_INF_FMT("transport=%s conn->scheme=%s", transport, conn->scheme);
- conn->scheme = mnd_pestrndup(transport, transport_len, conn->persistent);
- conn->scheme_len = transport_len;
+ DBG_INF_FMT("transport=%s conn->scheme=%s", transport, conn->scheme.s);
+ conn->scheme.s = mnd_pestrndup(transport, transport_len, conn->persistent);
+ conn->scheme.l = transport_len;
mnd_sprintf_free(transport);
transport = NULL;
- if (!conn->scheme) {
+ if (!conn->scheme.s) {
goto err; /* OOM */
}
}
}
err:
- DBG_ERR_FMT("[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, conn->scheme);
+ DBG_ERR_FMT("[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, conn->scheme.s);
if (!conn->error_info->error_no) {
SET_CLIENT_ERROR(conn->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, conn->error_info->error? conn->error_info->error:"Unknown error");
- php_error_docref(NULL, E_WARNING, "[%u] %.128s (trying to connect via %s)",
- conn->error_info->error_no, conn->error_info->error, conn->scheme);
+ php_error_docref(NULL, E_WARNING, "[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, conn->scheme.s);
}
conn->m->free_contents(conn);
case CONN_QUERY_SENT:
case CONN_FETCHING_DATA:
MYSQLND_INC_GLOBAL_STATISTIC(STAT_CLOSE_IN_MIDDLE);
- DBG_ERR_FMT("Brutally closing connection [%p][%s]", conn, conn->scheme);
+ DBG_ERR_FMT("Brutally closing connection [%p][%s]", conn, conn->scheme.s);
/*
Do nothing, the connection will be brutally closed
and the server will catch it and free close from its side.
/* {{{ mysqlnd_net::open_pipe */
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_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
#if PHP_API_VERSION < 20100412
streams_options |= STREAM_OPEN_PERSISTENT;
}
streams_options |= IGNORE_URL;
- net_stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL);
+ net_stream = php_stream_open_wrapper(scheme.s + 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(NULL);
/* {{{ mysqlnd_net::open_tcp_or_unix */
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_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
#if PHP_API_VERSION < 20100412
}
DBG_INF_FMT("calling php_stream_xport_create");
- net_stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags,
+ net_stream = php_stream_xport_create(scheme.s, scheme.l, streams_options, streams_flags,
hashed_details, (net->data->options.timeout_connect) ? &tv : NULL,
NULL /*ctx*/, &errstr, &errcode);
if (errstr || !net_stream) {
/* {{{ mysqlnd_net::post_connect_set_opt */
static void
-MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net,
- const char * const scheme, const size_t scheme_len,
+MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net, const MYSQLND_STRING scheme,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
php_stream * net_stream = net->data->m.get_stream(net);
php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
}
- if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) {
+ if (!memcmp(scheme.s, "tcp://", sizeof("tcp://") - 1)) {
/* TCP -> Set TCP_NODELAY */
mysqlnd_set_sock_no_delay(net_stream);
/* TCP -> Set SO_KEEPALIVE */
/* {{{ mysqlnd_net::get_open_stream */
static func_mysqlnd_net__open_stream
-MYSQLND_METHOD(mysqlnd_net, get_open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
+MYSQLND_METHOD(mysqlnd_net, get_open_stream)(MYSQLND_NET * const net, const MYSQLND_STRING scheme,
MYSQLND_ERROR_INFO * const error_info)
{
func_mysqlnd_net__open_stream ret = NULL;
DBG_ENTER("mysqlnd_net::get_open_stream");
- if (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1)) {
+ if (scheme.l > (sizeof("pipe://") - 1) && !memcmp(scheme.s, "pipe://", sizeof("pipe://") - 1)) {
ret = net->data->m.open_pipe;
- } else if ((scheme_len > (sizeof("tcp://") - 1) && !memcmp(scheme, "tcp://", sizeof("tcp://") - 1))
+ } else if ((scheme.l > (sizeof("tcp://") - 1) && !memcmp(scheme.s, "tcp://", sizeof("tcp://") - 1))
||
- (scheme_len > (sizeof("unix://") - 1) && !memcmp(scheme, "unix://", sizeof("unix://") - 1)))
+ (scheme.l > (sizeof("unix://") - 1) && !memcmp(scheme.s, "unix://", sizeof("unix://") - 1)))
{
ret = net->data->m.open_tcp_or_unix;
}
/* {{{ mysqlnd_net::connect_ex */
static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
- const zend_bool persistent,
+MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
enum_func_status ret = FAIL;
net->data->m.close_stream(net, conn_stats, error_info);
- open_stream = net->data->m.get_open_stream(net, scheme, scheme_len, error_info);
+ open_stream = net->data->m.get_open_stream(net, scheme, error_info);
if (open_stream) {
- php_stream * net_stream = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info);
+ php_stream * net_stream = open_stream(net, scheme, persistent, conn_stats, error_info);
if (net_stream) {
(void) net->data->m.set_stream(net, net_stream);
- net->data->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info);
+ net->data->m.post_connect_set_opt(net, scheme, conn_stats, error_info);
ret = PASS;
}
}
typedef enum_func_status (*func_mysqlnd_net__receive_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
typedef enum_func_status (*func_mysqlnd_net__init)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
typedef void (*func_mysqlnd_net__dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
-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);
+typedef enum_func_status (*func_mysqlnd_net__connect_ex)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
typedef void (*func_mysqlnd_net__close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
-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);
+typedef php_stream * (*func_mysqlnd_net__open_stream)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
typedef php_stream * (*func_mysqlnd_net__get_stream)(const MYSQLND_NET * const net);
typedef php_stream * (*func_mysqlnd_net__set_stream)(MYSQLND_NET * const net, php_stream * net_stream);
-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);
-typedef void (*func_mysqlnd_net__post_connect_set_opt)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
+typedef func_mysqlnd_net__open_stream (*func_mysqlnd_net__get_open_stream)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, MYSQLND_ERROR_INFO * const error_info);
+typedef void (*func_mysqlnd_net__post_connect_set_opt)(MYSQLND_NET * const net, const MYSQLND_STRING scheme, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
typedef enum_func_status (*func_mysqlnd_net__read_compressed_packet_from_stream_and_fill_read_buffer)(MYSQLND_NET * net, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info);
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_net)
unsigned int user_len;
char *passwd;
unsigned int passwd_len;
- char *scheme;
- unsigned int scheme_len;
+ MYSQLND_STRING scheme;
uint64_t thread_id;
char *server_version;
char *host_info;