mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
MNDR:
- better name for MYSQLND_PPEC - MYSQLND_PFC (protocol frame codec)
This commit is contained in:
parent
654d1a7caf
commit
a530ecff97
18 changed files with 725 additions and 693 deletions
|
@ -16,13 +16,14 @@ if (PHP_MYSQLND != "no") {
|
||||||
"mysqlnd_ext_plugin.c " +
|
"mysqlnd_ext_plugin.c " +
|
||||||
"mysqlnd_loaddata.c " +
|
"mysqlnd_loaddata.c " +
|
||||||
"mysqlnd_reverse_api.c " +
|
"mysqlnd_reverse_api.c " +
|
||||||
"mysqlnd_vio.c " +
|
|
||||||
"mysqlnd_plugin.c " +
|
"mysqlnd_plugin.c " +
|
||||||
|
"mysqlnd_protocol_frame_codec.c " +
|
||||||
"mysqlnd_ps.c " +
|
"mysqlnd_ps.c " +
|
||||||
"mysqlnd_ps_codec.c " +
|
"mysqlnd_ps_codec.c " +
|
||||||
"mysqlnd_result.c " +
|
"mysqlnd_result.c " +
|
||||||
"mysqlnd_result_meta.c " +
|
"mysqlnd_result_meta.c " +
|
||||||
"mysqlnd_statistics.c " +
|
"mysqlnd_statistics.c " +
|
||||||
|
"mysqlnd_vio.c " +
|
||||||
"mysqlnd_wireprotocol.c " +
|
"mysqlnd_wireprotocol.c " +
|
||||||
"php_mysqlnd.c ";
|
"php_mysqlnd.c ";
|
||||||
EXTENSION("mysqlnd", mysqlnd_source, false, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
|
EXTENSION("mysqlnd", mysqlnd_source, false, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
|
||||||
|
|
|
@ -19,7 +19,7 @@ dnl If some extension uses mysqlnd it will get compiled in PHP core
|
||||||
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
|
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
|
||||||
mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
|
mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
|
||||||
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
|
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
|
||||||
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_vio.c \
|
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_vio.c mysqlnd_protocol_frame_codec.c \
|
||||||
mysqlnd_statistics.c mysqlnd_driver.c mysqlnd_ext_plugin.c mysqlnd_auth.c \
|
mysqlnd_statistics.c mysqlnd_driver.c mysqlnd_ext_plugin.c mysqlnd_auth.c \
|
||||||
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
|
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
|
||||||
mysqlnd_block_alloc.c mysqlnd_plugin.c php_mysqlnd.c"
|
mysqlnd_block_alloc.c mysqlnd_plugin.c php_mysqlnd.c"
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
#include "mysqlnd_vio.h"
|
#include "mysqlnd_vio.h"
|
||||||
|
#include "mysqlnd_protocol_frame_codec.h"
|
||||||
#include "mysqlnd_wireprotocol.h"
|
#include "mysqlnd_wireprotocol.h"
|
||||||
#include "mysqlnd_priv.h"
|
#include "mysqlnd_priv.h"
|
||||||
#include "mysqlnd_result.h"
|
#include "mysqlnd_result.h"
|
||||||
|
@ -267,8 +267,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn)
|
||||||
conn->current_result = NULL;
|
conn->current_result = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->net) {
|
if (conn->protocol_frame_codec) {
|
||||||
conn->net->data->m.free_contents(conn->net);
|
conn->protocol_frame_codec->data->m.free_contents(conn->protocol_frame_codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->vio) {
|
if (conn->vio) {
|
||||||
|
@ -341,9 +341,9 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, dtor)(MYSQLND_CONN_DATA * conn)
|
||||||
conn->m->free_contents(conn);
|
conn->m->free_contents(conn);
|
||||||
conn->m->free_options(conn);
|
conn->m->free_options(conn);
|
||||||
|
|
||||||
if (conn->net) {
|
if (conn->protocol_frame_codec) {
|
||||||
mysqlnd_ppec_free(conn->net, conn->stats, conn->error_info);
|
mysqlnd_pfc_free(conn->protocol_frame_codec, conn->stats, conn->error_info);
|
||||||
conn->net = NULL;
|
conn->protocol_frame_codec = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->vio) {
|
if (conn->vio) {
|
||||||
|
@ -540,7 +540,7 @@ mysqlnd_run_authentication(
|
||||||
scrambled_data =
|
scrambled_data =
|
||||||
auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
|
auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
|
||||||
plugin_data, plugin_data_len, session_options,
|
plugin_data, plugin_data_len, session_options,
|
||||||
&conn->net->data->options, mysql_flags);
|
&conn->protocol_frame_codec->data->options, mysql_flags);
|
||||||
if (conn->error_info->error_no) {
|
if (conn->error_info->error_no) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, execute_init_commands)(MYSQLND_CONN_DATA * con
|
||||||
static unsigned int
|
static unsigned int
|
||||||
MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA * conn, unsigned int mysql_flags)
|
MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA * conn, unsigned int mysql_flags)
|
||||||
{
|
{
|
||||||
MYSQLND_PPEC * net = conn->net;
|
MYSQLND_PFC * pfc = conn->protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = conn->vio;
|
MYSQLND_VIO * vio = conn->vio;
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_conn_data::get_updated_connect_flags");
|
DBG_ENTER("mysqlnd_conn_data::get_updated_connect_flags");
|
||||||
|
@ -682,7 +682,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA *
|
||||||
mysql_flags &= ~CLIENT_COMPRESS;
|
mysql_flags &= ~CLIENT_COMPRESS;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (net && net->data->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) {
|
if (pfc && pfc->data->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) {
|
||||||
mysql_flags |= CLIENT_COMPRESS;
|
mysql_flags |= CLIENT_COMPRESS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -713,12 +713,12 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn,
|
||||||
const unsigned int mysql_flags)
|
const unsigned int mysql_flags)
|
||||||
{
|
{
|
||||||
enum_func_status ret = FAIL;
|
enum_func_status ret = FAIL;
|
||||||
size_t client_flags = mysql_flags;
|
|
||||||
DBG_ENTER("mysqlnd_conn_data::connect_handshake");
|
DBG_ENTER("mysqlnd_conn_data::connect_handshake");
|
||||||
|
|
||||||
if (FAIL == conn->vio->data->m.connect(conn->vio, *scheme, conn->persistent, conn->stats, conn->error_info)) {
|
if (PASS == conn->vio->data->m.connect(conn->vio, *scheme, conn->persistent, conn->stats, conn->error_info) &&
|
||||||
DBG_RETURN(FAIL);
|
PASS == conn->protocol_frame_codec->data->m.reset(conn->protocol_frame_codec, conn->stats, conn->error_info))
|
||||||
} else if (PASS == conn->net->data->m.connect(conn->net, *scheme, conn->persistent, conn->stats, conn->error_info)) {
|
{
|
||||||
|
size_t client_flags = mysql_flags;
|
||||||
struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_HANDSHAKE, conn, username, password, database, client_flags);
|
struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_HANDSHAKE, conn, username, password, database, client_flags);
|
||||||
if (command) {
|
if (command) {
|
||||||
ret = command->run(command);
|
ret = command->run(command);
|
||||||
|
@ -784,7 +784,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
|
||||||
zend_bool reconnect = FALSE;
|
zend_bool reconnect = FALSE;
|
||||||
zend_bool saved_compression = FALSE;
|
zend_bool saved_compression = FALSE;
|
||||||
zend_bool local_tx_started = FALSE;
|
zend_bool local_tx_started = FALSE;
|
||||||
MYSQLND_PPEC * net = conn->net;
|
MYSQLND_PFC * pfc = conn->protocol_frame_codec;
|
||||||
MYSQLND_STRING transport = { NULL, 0 };
|
MYSQLND_STRING transport = { NULL, 0 };
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_conn_data::connect");
|
DBG_ENTER("mysqlnd_conn_data::connect");
|
||||||
|
@ -813,17 +813,17 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
|
||||||
|
|
||||||
conn->m->free_contents(conn);
|
conn->m->free_contents(conn);
|
||||||
/* Now reconnect using the same handle */
|
/* Now reconnect using the same handle */
|
||||||
if (net->data->compressed) {
|
if (pfc->data->compressed) {
|
||||||
/*
|
/*
|
||||||
we need to save the state. As we will re-connect, net->compressed should be off, or
|
we need to save the state. As we will re-connect, pfc->compressed should be off, or
|
||||||
we will look for a compression header as part of the greet message, but there will
|
we will look for a compression header as part of the greet message, but there will
|
||||||
be none.
|
be none.
|
||||||
*/
|
*/
|
||||||
saved_compression = TRUE;
|
saved_compression = TRUE;
|
||||||
net->data->compressed = FALSE;
|
pfc->data->compressed = FALSE;
|
||||||
}
|
}
|
||||||
if (net->data->ssl) {
|
if (pfc->data->ssl) {
|
||||||
net->data->ssl = FALSE;
|
pfc->data->ssl = FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned int max_allowed_size = MYSQLND_ASSEMBLED_PACKET_MAX_SIZE;
|
unsigned int max_allowed_size = MYSQLND_ASSEMBLED_PACKET_MAX_SIZE;
|
||||||
|
@ -867,14 +867,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
|
||||||
SET_CONNECTION_STATE(&conn->state, CONN_READY);
|
SET_CONNECTION_STATE(&conn->state, CONN_READY);
|
||||||
|
|
||||||
if (saved_compression) {
|
if (saved_compression) {
|
||||||
net->data->compressed = TRUE;
|
pfc->data->compressed = TRUE;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
If a connect on a existing handle is performed and mysql_flags is
|
If a connect on a existing handle is performed and mysql_flags is
|
||||||
passed which doesn't CLIENT_COMPRESS, then we need to overwrite the value
|
passed which doesn't CLIENT_COMPRESS, then we need to overwrite the value
|
||||||
which we set based on saved_compression.
|
which we set based on saved_compression.
|
||||||
*/
|
*/
|
||||||
net->data->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE;
|
pfc->data->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE;
|
||||||
|
|
||||||
|
|
||||||
conn->scheme.s = mnd_pestrndup(transport.s, transport.l, conn->persistent);
|
conn->scheme.s = mnd_pestrndup(transport.s, transport.l, conn->persistent);
|
||||||
|
@ -1435,15 +1435,15 @@ MYSQLND_METHOD(mysqlnd_conn_data, ssl_set)(MYSQLND_CONN_DATA * const conn, const
|
||||||
{
|
{
|
||||||
const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), ssl_set);
|
const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), ssl_set);
|
||||||
enum_func_status ret = FAIL;
|
enum_func_status ret = FAIL;
|
||||||
MYSQLND_VIO * net = conn->vio;
|
MYSQLND_VIO * vio = conn->vio;
|
||||||
DBG_ENTER("mysqlnd_conn_data::ssl_set");
|
DBG_ENTER("mysqlnd_conn_data::ssl_set");
|
||||||
|
|
||||||
if (PASS == conn->m->local_tx_start(conn, this_func)) {
|
if (PASS == conn->m->local_tx_start(conn, this_func)) {
|
||||||
ret = (PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_KEY, key) &&
|
ret = (PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_KEY, key) &&
|
||||||
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CERT, cert) &&
|
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CERT, cert) &&
|
||||||
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CA, ca) &&
|
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CA, ca) &&
|
||||||
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CAPATH, capath) &&
|
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CAPATH, capath) &&
|
||||||
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CIPHER, cipher)) ? PASS : FAIL;
|
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CIPHER, cipher)) ? PASS : FAIL;
|
||||||
|
|
||||||
conn->m->local_tx_end(conn, this_func, ret);
|
conn->m->local_tx_end(conn, this_func, ret);
|
||||||
}
|
}
|
||||||
|
@ -1688,12 +1688,10 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn)
|
||||||
enum_func_status ret = PASS;
|
enum_func_status ret = PASS;
|
||||||
MYSQLND_VIO * vio = conn->vio;
|
MYSQLND_VIO * vio = conn->vio;
|
||||||
php_stream * net_stream = vio->data->m.get_stream(vio);
|
php_stream * net_stream = vio->data->m.get_stream(vio);
|
||||||
enum mysqlnd_connection_state state;
|
enum mysqlnd_connection_state state = GET_CONNECTION_STATE(&conn->state);
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_send_close");
|
DBG_ENTER("mysqlnd_send_close");
|
||||||
DBG_INF_FMT("conn=%llu net->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->abstract:NULL);
|
DBG_INF_FMT("conn=%llu vio->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->abstract:NULL);
|
||||||
|
|
||||||
state = GET_CONNECTION_STATE(&conn->state);
|
|
||||||
DBG_INF_FMT("state=%u", state);
|
DBG_INF_FMT("state=%u", state);
|
||||||
|
|
||||||
if (state >= CONN_READY) {
|
if (state >= CONN_READY) {
|
||||||
|
@ -2116,7 +2114,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c
|
||||||
ret = conn->vio->data->m.set_client_option(conn->vio, option, value);
|
ret = conn->vio->data->m.set_client_option(conn->vio, option, value);
|
||||||
break;
|
break;
|
||||||
case MYSQL_SERVER_PUBLIC_KEY:
|
case MYSQL_SERVER_PUBLIC_KEY:
|
||||||
ret = conn->net->data->m.set_client_option(conn->net, option, value);
|
ret = conn->protocol_frame_codec->data->m.set_client_option(conn->protocol_frame_codec, option, value);
|
||||||
break;
|
break;
|
||||||
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
|
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
|
||||||
case MYSQLND_OPT_INT_AND_FLOAT_NATIVE:
|
case MYSQLND_OPT_INT_AND_FLOAT_NATIVE:
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: mysqlnd.c 307377 2011-01-11 13:02:57Z andrey $ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
#include "mysqlnd_structs.h"
|
#include "mysqlnd_structs.h"
|
||||||
|
@ -360,7 +359,7 @@ mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
|
||||||
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
||||||
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
||||||
const MYSQLND_SESSION_OPTIONS * const session_options,
|
const MYSQLND_SESSION_OPTIONS * const session_options,
|
||||||
const MYSQLND_PPEC_OPTIONS * const ppec_options,
|
const MYSQLND_PFC_OPTIONS * const ppec_options,
|
||||||
zend_ulong mysql_flags
|
zend_ulong mysql_flags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -420,7 +419,7 @@ mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
|
||||||
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
||||||
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
||||||
const MYSQLND_SESSION_OPTIONS * const session_options,
|
const MYSQLND_SESSION_OPTIONS * const session_options,
|
||||||
const MYSQLND_PPEC_OPTIONS * const ppec_options,
|
const MYSQLND_PFC_OPTIONS * const ppec_options,
|
||||||
zend_ulong mysql_flags
|
zend_ulong mysql_flags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -481,7 +480,7 @@ mysqlnd_xor_string(char * dst, const size_t dst_len, const char * xor_str, const
|
||||||
static RSA *
|
static RSA *
|
||||||
mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
|
mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
|
||||||
const MYSQLND_SESSION_OPTIONS * const session_options,
|
const MYSQLND_SESSION_OPTIONS * const session_options,
|
||||||
const MYSQLND_PPEC_OPTIONS * const io_options
|
const MYSQLND_PFC_OPTIONS * const io_options
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RSA * ret = NULL;
|
RSA * ret = NULL;
|
||||||
|
@ -570,7 +569,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
|
||||||
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
||||||
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
||||||
const MYSQLND_SESSION_OPTIONS * const session_options,
|
const MYSQLND_SESSION_OPTIONS * const session_options,
|
||||||
const MYSQLND_PPEC_OPTIONS * const ppec_options,
|
const MYSQLND_PFC_OPTIONS * const ppec_options,
|
||||||
zend_ulong mysql_flags
|
zend_ulong mysql_flags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -580,7 +579,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
|
||||||
DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
|
DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
|
||||||
|
|
||||||
|
|
||||||
if (conn->net->data->ssl) {
|
if (conn->protocol_frame_codec->data->ssl) {
|
||||||
DBG_INF("simple clear text under SSL");
|
DBG_INF("simple clear text under SSL");
|
||||||
/* clear text under SSL */
|
/* clear text under SSL */
|
||||||
*auth_data_len = passwd_len;
|
*auth_data_len = passwd_len;
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: mysqlnd.c 317989 2011-10-10 20:49:28Z andrey $ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
#include "mysqlnd_vio.h"
|
#include "mysqlnd_vio.h"
|
||||||
|
#include "mysqlnd_protocol_frame_codec.h"
|
||||||
#include "mysqlnd_wireprotocol.h"
|
#include "mysqlnd_wireprotocol.h"
|
||||||
#include "mysqlnd_priv.h"
|
#include "mysqlnd_priv.h"
|
||||||
#include "mysqlnd_result.h"
|
#include "mysqlnd_result.h"
|
||||||
|
@ -140,12 +140,12 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(struct st_mysqlnd_object_
|
||||||
|
|
||||||
mysqlnd_stats_init(&data->stats, STAT_LAST, persistent);
|
mysqlnd_stats_init(&data->stats, STAT_LAST, persistent);
|
||||||
|
|
||||||
data->net = mysqlnd_ppec_init(persistent, data->stats, data->error_info);
|
data->protocol_frame_codec = mysqlnd_pfc_init(persistent, data->stats, data->error_info);
|
||||||
data->vio = mysqlnd_vio_init(persistent, data->stats, data->error_info);
|
data->vio = mysqlnd_vio_init(persistent, data->stats, data->error_info);
|
||||||
data->payload_decoder_factory = mysqlnd_protocol_payload_decoder_factory_init(data, persistent);
|
data->payload_decoder_factory = mysqlnd_protocol_payload_decoder_factory_init(data, persistent);
|
||||||
data->command_factory = mysqlnd_command_factory_get();
|
data->command_factory = mysqlnd_command_factory_get();
|
||||||
|
|
||||||
if (!data->net || !data->payload_decoder_factory) {
|
if (!data->protocol_frame_codec || !data->vio || !data->payload_decoder_factory || !data->command_factory) {
|
||||||
new_object->m->dtor(new_object);
|
new_object->m->dtor(new_object);
|
||||||
DBG_RETURN(NULL);
|
DBG_RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
@ -244,20 +244,20 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_object_factory::get_ppec */
|
/* {{{ mysqlnd_object_factory::get_ppec */
|
||||||
static MYSQLND_PPEC *
|
static MYSQLND_PFC *
|
||||||
MYSQLND_METHOD(mysqlnd_object_factory, get_ppec)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
|
MYSQLND_METHOD(mysqlnd_object_factory, get_ppec)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
|
||||||
{
|
{
|
||||||
size_t ppec_alloc_size = sizeof(MYSQLND_PPEC) + mysqlnd_plugin_count() * sizeof(void *);
|
size_t ppec_alloc_size = sizeof(MYSQLND_PFC) + mysqlnd_plugin_count() * sizeof(void *);
|
||||||
size_t ppec_data_alloc_size = sizeof(MYSQLND_PPEC_DATA) + mysqlnd_plugin_count() * sizeof(void *);
|
size_t ppec_data_alloc_size = sizeof(MYSQLND_PFC_DATA) + mysqlnd_plugin_count() * sizeof(void *);
|
||||||
MYSQLND_PPEC * ppec = mnd_pecalloc(1, ppec_alloc_size, persistent);
|
MYSQLND_PFC * ppec = mnd_pecalloc(1, ppec_alloc_size, persistent);
|
||||||
MYSQLND_PPEC_DATA * ppec_data = mnd_pecalloc(1, ppec_data_alloc_size, persistent);
|
MYSQLND_PFC_DATA * ppec_data = mnd_pecalloc(1, ppec_data_alloc_size, persistent);
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_object_factory::get_ppec");
|
DBG_ENTER("mysqlnd_object_factory::get_ppec");
|
||||||
DBG_INF_FMT("persistent=%u", persistent);
|
DBG_INF_FMT("persistent=%u", persistent);
|
||||||
if (ppec && ppec_data) {
|
if (ppec && ppec_data) {
|
||||||
ppec->data = ppec_data;
|
ppec->data = ppec_data;
|
||||||
ppec->persistent = ppec->data->persistent = persistent;
|
ppec->persistent = ppec->data->persistent = persistent;
|
||||||
ppec->data->m = *mysqlnd_ppec_get_methods();
|
ppec->data->m = *mysqlnd_pfc_get_methods();
|
||||||
|
|
||||||
if (PASS != ppec->data->m.init(ppec, stats, error_info)) {
|
if (PASS != ppec->data->m.init(ppec, stats, error_info)) {
|
||||||
ppec->data->m.dtor(ppec, stats, error_info);
|
ppec->data->m.dtor(ppec, stats, error_info);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
#ifndef MYSQLND_ENUM_N_DEF_H
|
#ifndef MYSQLND_ENUM_N_DEF_H
|
||||||
#define MYSQLND_ENUM_N_DEF_H
|
#define MYSQLND_ENUM_N_DEF_H
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
| Ulf Wendel <uwendel@mysql.com> |
|
| Ulf Wendel <uwendel@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: mysqlnd.c 318221 2011-10-19 15:04:12Z andrey $ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
#include "mysqlnd_priv.h"
|
#include "mysqlnd_priv.h"
|
||||||
|
@ -142,14 +140,14 @@ mysqlnd_plugin__get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plu
|
||||||
|
|
||||||
/* {{{ mysqlnd_plugin__get_plugin_ppec_data */
|
/* {{{ mysqlnd_plugin__get_plugin_ppec_data */
|
||||||
static void **
|
static void **
|
||||||
mysqlnd_plugin__get_plugin_ppec_data(const MYSQLND_PPEC * ppec, unsigned int plugin_id)
|
mysqlnd_plugin__get_plugin_ppec_data(const MYSQLND_PFC * ppec, unsigned int plugin_id)
|
||||||
{
|
{
|
||||||
DBG_ENTER("mysqlnd_plugin__get_plugin_ppec_data");
|
DBG_ENTER("mysqlnd_plugin__get_plugin_ppec_data");
|
||||||
DBG_INF_FMT("plugin_id=%u", plugin_id);
|
DBG_INF_FMT("plugin_id=%u", plugin_id);
|
||||||
if (!ppec || plugin_id >= mysqlnd_plugin_count()) {
|
if (!ppec || plugin_id >= mysqlnd_plugin_count()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
DBG_RETURN((void *)((char *)ppec + sizeof(MYSQLND_PPEC) + plugin_id * sizeof(void *)));
|
DBG_RETURN((void *)((char *)ppec + sizeof(MYSQLND_PFC) + plugin_id * sizeof(void *)));
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -324,18 +322,18 @@ _mysqlnd_protocol_payload_decoder_factory_set_methods(MYSQLND_CLASS_METHODS_TYPE
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
/* {{{ _mysqlnd_ppec_get_methods */
|
/* {{{ _mysqlnd_pfc_get_methods */
|
||||||
static MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) *
|
static MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) *
|
||||||
_mysqlnd_ppec_get_methods()
|
_mysqlnd_pfc_get_methods()
|
||||||
{
|
{
|
||||||
return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol_packet_envelope_codec);
|
return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol_packet_envelope_codec);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
/* {{{ _mysqlnd_ppec_set_methods */
|
/* {{{ _mysqlnd_pfc_set_methods */
|
||||||
static void
|
static void
|
||||||
_mysqlnd_ppec_set_methods(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) * methods)
|
_mysqlnd_pfc_set_methods(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) * methods)
|
||||||
{
|
{
|
||||||
MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol_packet_envelope_codec) = *methods;
|
MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol_packet_envelope_codec) = *methods;
|
||||||
}
|
}
|
||||||
|
@ -431,8 +429,8 @@ struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters =
|
||||||
_mysqlnd_protocol_payload_decoder_factory_set_methods,
|
_mysqlnd_protocol_payload_decoder_factory_set_methods,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_mysqlnd_ppec_get_methods,
|
_mysqlnd_pfc_get_methods,
|
||||||
_mysqlnd_ppec_set_methods,
|
_mysqlnd_pfc_set_methods,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_mysqlnd_vio_get_methods,
|
_mysqlnd_vio_get_methods,
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
| Ulf Wendel <uwendel@mysql.com> |
|
| Ulf Wendel <uwendel@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
/* $Id: mysqlnd.h 318221 2011-10-19 15:04:12Z andrey $ */
|
|
||||||
|
|
||||||
#ifndef MYSQLND_EXT_PLUGIN_H
|
#ifndef MYSQLND_EXT_PLUGIN_H
|
||||||
#define MYSQLND_EXT_PLUGIN_H
|
#define MYSQLND_EXT_PLUGIN_H
|
||||||
|
|
||||||
|
@ -31,7 +29,7 @@ struct st_mysqlnd_plugin__plugin_area_getters
|
||||||
void ** (*get_result_buffered_aread_c)(const MYSQLND_RES_BUFFERED_C * result, unsigned int plugin_id);
|
void ** (*get_result_buffered_aread_c)(const MYSQLND_RES_BUFFERED_C * result, unsigned int plugin_id);
|
||||||
void ** (*get_stmt_area)(const MYSQLND_STMT * stmt, unsigned int plugin_id);
|
void ** (*get_stmt_area)(const MYSQLND_STMT * stmt, unsigned int plugin_id);
|
||||||
void ** (*get_protocol_decoder_area)(const MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * factory, unsigned int plugin_id);
|
void ** (*get_protocol_decoder_area)(const MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * factory, unsigned int plugin_id);
|
||||||
void ** (*get_ppec_area)(const MYSQLND_PPEC * ppec, unsigned int plugin_id);
|
void ** (*get_ppec_area)(const MYSQLND_PFC * ppec, unsigned int plugin_id);
|
||||||
void ** (*get_vio_area)(const MYSQLND_VIO * vio, unsigned int plugin_id);
|
void ** (*get_vio_area)(const MYSQLND_VIO * vio, unsigned int plugin_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -151,8 +149,8 @@ extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters;
|
||||||
#define mysqlnd_protocol_get_methods() mysqlnd_plugin_methods_xetters.protocol.get()
|
#define mysqlnd_protocol_get_methods() mysqlnd_plugin_methods_xetters.protocol.get()
|
||||||
#define mysqlnd_protocol_set_methods(m) mysqlnd_plugin_methods_xetters.protocol.set((m))
|
#define mysqlnd_protocol_set_methods(m) mysqlnd_plugin_methods_xetters.protocol.set((m))
|
||||||
|
|
||||||
#define mysqlnd_ppec_get_methods() mysqlnd_plugin_methods_xetters.ppec.get()
|
#define mysqlnd_pfc_get_methods() mysqlnd_plugin_methods_xetters.ppec.get()
|
||||||
#define mysqlnd_ppec_set_methods(m) mysqlnd_plugin_methods_xetters.ppec.set((m))
|
#define mysqlnd_pfc_set_methods(m) mysqlnd_plugin_methods_xetters.ppec.set((m))
|
||||||
|
|
||||||
#define mysqlnd_vio_get_methods() mysqlnd_plugin_methods_xetters.vio.get()
|
#define mysqlnd_vio_get_methods() mysqlnd_plugin_methods_xetters.vio.get()
|
||||||
#define mysqlnd_vio_set_methods(m) mysqlnd_plugin_methods_xetters.vio.set((m))
|
#define mysqlnd_vio_set_methods(m) mysqlnd_plugin_methods_xetters.vio.set((m))
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
| Georg Richter <georg@mysql.com> |
|
| Georg Richter <georg@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_globals.h"
|
#include "php_globals.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
|
@ -151,7 +150,7 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * const filenam
|
||||||
int bufsize;
|
int bufsize;
|
||||||
size_t ret;
|
size_t ret;
|
||||||
MYSQLND_INFILE infile;
|
MYSQLND_INFILE infile;
|
||||||
MYSQLND_PPEC * net = conn->net;
|
MYSQLND_PFC * net = conn->protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = conn->vio;
|
MYSQLND_VIO * vio = conn->vio;
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_handle_local_infile");
|
DBG_ENTER("mysqlnd_handle_local_infile");
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
| Georg Richter <georg@mysql.com> |
|
| Georg Richter <georg@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef MYSQLND_PRIV_H
|
#ifndef MYSQLND_PRIV_H
|
||||||
#define MYSQLND_PRIV_H
|
#define MYSQLND_PRIV_H
|
||||||
|
|
||||||
|
|
538
ext/mysqlnd/mysqlnd_protocol_frame_codec.c
Normal file
538
ext/mysqlnd/mysqlnd_protocol_frame_codec.c
Normal file
|
@ -0,0 +1,538 @@
|
||||||
|
/*
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| PHP Version 7 |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| Copyright (c) 2006-2015 The PHP Group |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| This source file is subject to version 3.01 of the PHP license, |
|
||||||
|
| that is bundled with this package in the file LICENSE, and is |
|
||||||
|
| available through the world-wide-web at the following url: |
|
||||||
|
| http://www.php.net/license/3_01.txt |
|
||||||
|
| If you did not receive a copy of the PHP license and are unable to |
|
||||||
|
| obtain it through the world-wide-web, please send a note to |
|
||||||
|
| license@php.net so we can mail you a copy immediately. |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| Authors: Andrey Hristov <andrey@mysql.com> |
|
||||||
|
| Ulf Wendel <uwendel@mysql.com> |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
#include "php.h"
|
||||||
|
#include "php_globals.h"
|
||||||
|
#include "mysqlnd.h"
|
||||||
|
#include "mysqlnd_priv.h"
|
||||||
|
#include "mysqlnd_wireprotocol.h"
|
||||||
|
#include "mysqlnd_statistics.h"
|
||||||
|
#include "mysqlnd_debug.h"
|
||||||
|
#include "mysqlnd_ext_plugin.h"
|
||||||
|
#include "php_network.h"
|
||||||
|
#include "zend_ini.h"
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::reset */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, reset)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
|
||||||
|
{
|
||||||
|
DBG_ENTER("mysqlnd_pfc::reset");
|
||||||
|
pfc->packet_no = pfc->compressed_envelope_packet_no = 0;
|
||||||
|
DBG_RETURN(PASS);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */
|
||||||
|
#define COPY_HEADER(T,A) do { \
|
||||||
|
*(((char *)(T))) = *(((char *)(A)));\
|
||||||
|
*(((char *)(T))+1) = *(((char *)(A))+1);\
|
||||||
|
*(((char *)(T))+2) = *(((char *)(A))+2);\
|
||||||
|
*(((char *)(T))+3) = *(((char *)(A))+3); } while (0)
|
||||||
|
#define STORE_HEADER_SIZE(safe_storage, buffer) COPY_HEADER((safe_storage), (buffer))
|
||||||
|
#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::send */
|
||||||
|
/*
|
||||||
|
IMPORTANT : It's expected that buffer has place in the beginning for MYSQLND_HEADER_SIZE !!!!
|
||||||
|
This is done for performance reasons in the caller of this function.
|
||||||
|
Otherwise we will have to do send two TCP packets, or do new alloc and memcpy.
|
||||||
|
Neither are quick, thus the clients of this function are obligated to do
|
||||||
|
what they are asked for.
|
||||||
|
|
||||||
|
`count` is actually the length of the payload data. Thus :
|
||||||
|
count + MYSQLND_HEADER_SIZE = sizeof(buffer) (not the pointer but the actual buffer)
|
||||||
|
*/
|
||||||
|
static size_t
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count,
|
||||||
|
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
|
||||||
|
{
|
||||||
|
zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
|
||||||
|
zend_uchar * safe_storage = safe_buf;
|
||||||
|
size_t bytes_sent, packets_sent = 1;
|
||||||
|
size_t left = count;
|
||||||
|
zend_uchar * p = (zend_uchar *) buffer;
|
||||||
|
zend_uchar * compress_buf = NULL;
|
||||||
|
size_t to_be_sent;
|
||||||
|
|
||||||
|
DBG_ENTER("mysqlnd_pfc::send");
|
||||||
|
DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, pfc->data->compressed);
|
||||||
|
|
||||||
|
if (pfc->data->compressed == TRUE) {
|
||||||
|
size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE);
|
||||||
|
DBG_INF_FMT("compress_buf_size="MYSQLND_SZ_T_SPEC, comp_buf_size);
|
||||||
|
compress_buf = mnd_emalloc(comp_buf_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
to_be_sent = MIN(left, MYSQLND_MAX_PACKET_SIZE);
|
||||||
|
DBG_INF_FMT("to_be_sent=%u", to_be_sent);
|
||||||
|
DBG_INF_FMT("packets_sent=%u", packets_sent);
|
||||||
|
DBG_INF_FMT("compressed_envelope_packet_no=%u", pfc->compressed_envelope_packet_no);
|
||||||
|
DBG_INF_FMT("packet_no=%u", pfc->packet_no);
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
if (pfc->data->compressed == TRUE) {
|
||||||
|
/* here we need to compress the data and then write it, first comes the compressed header */
|
||||||
|
size_t tmp_complen = to_be_sent;
|
||||||
|
size_t payload_size;
|
||||||
|
zend_uchar * uncompressed_payload = p; /* should include the header */
|
||||||
|
|
||||||
|
STORE_HEADER_SIZE(safe_storage, uncompressed_payload);
|
||||||
|
int3store(uncompressed_payload, to_be_sent);
|
||||||
|
int1store(uncompressed_payload + 3, pfc->packet_no);
|
||||||
|
if (PASS == pfc->data->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen,
|
||||||
|
uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE))
|
||||||
|
{
|
||||||
|
int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent + MYSQLND_HEADER_SIZE);
|
||||||
|
payload_size = tmp_complen;
|
||||||
|
} else {
|
||||||
|
int3store(compress_buf + MYSQLND_HEADER_SIZE, 0);
|
||||||
|
memcpy(compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE);
|
||||||
|
payload_size = to_be_sent + MYSQLND_HEADER_SIZE;
|
||||||
|
}
|
||||||
|
RESTORE_HEADER_SIZE(uncompressed_payload, safe_storage);
|
||||||
|
|
||||||
|
int3store(compress_buf, payload_size);
|
||||||
|
int1store(compress_buf + 3, pfc->packet_no);
|
||||||
|
DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
|
||||||
|
bytes_sent = vio->data->m.network_write(vio, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, conn_stats, error_info);
|
||||||
|
pfc->compressed_envelope_packet_no++;
|
||||||
|
#if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
|
||||||
|
if (res == Z_OK) {
|
||||||
|
size_t decompressed_size = left + MYSQLND_HEADER_SIZE;
|
||||||
|
zend_uchar * decompressed_data = mnd_malloc(decompressed_size);
|
||||||
|
int error = pfc->data->m.decode(decompressed_data, decompressed_size,
|
||||||
|
compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size);
|
||||||
|
if (error == Z_OK) {
|
||||||
|
int i;
|
||||||
|
DBG_INF("success decompressing");
|
||||||
|
for (i = 0 ; i < decompressed_size; i++) {
|
||||||
|
if (i && (i % 30 == 0)) {
|
||||||
|
printf("\n\t\t");
|
||||||
|
}
|
||||||
|
printf("%.2X ", (int)*((char*)&(decompressed_data[i])));
|
||||||
|
DBG_INF_FMT("%.2X ", (int)*((char*)&(decompressed_data[i])));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_INF("error decompressing");
|
||||||
|
}
|
||||||
|
mnd_free(decompressed_data);
|
||||||
|
}
|
||||||
|
#endif /* WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY */
|
||||||
|
} else
|
||||||
|
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
||||||
|
{
|
||||||
|
DBG_INF("no compression");
|
||||||
|
STORE_HEADER_SIZE(safe_storage, p);
|
||||||
|
int3store(p, to_be_sent);
|
||||||
|
int1store(p + 3, pfc->packet_no);
|
||||||
|
bytes_sent = vio->data->m.network_write(vio, p, to_be_sent + MYSQLND_HEADER_SIZE, conn_stats, error_info);
|
||||||
|
RESTORE_HEADER_SIZE(p, safe_storage);
|
||||||
|
pfc->compressed_envelope_packet_no++;
|
||||||
|
}
|
||||||
|
pfc->packet_no++;
|
||||||
|
|
||||||
|
p += to_be_sent;
|
||||||
|
left -= to_be_sent;
|
||||||
|
packets_sent++;
|
||||||
|
/*
|
||||||
|
if left is 0 then there is nothing more to send, but if the last packet was exactly
|
||||||
|
with the size MYSQLND_MAX_PACKET_SIZE we need to send additional packet, which has
|
||||||
|
empty payload. Thus if left == 0 we check for to_be_sent being the max size. If it is
|
||||||
|
indeed it then loop once more, then to_be_sent will become 0, left will stay 0. Empty
|
||||||
|
packet will be sent and this loop will end.
|
||||||
|
*/
|
||||||
|
} while (bytes_sent && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
|
||||||
|
|
||||||
|
DBG_INF_FMT("packet_size="MYSQLND_SZ_T_SPEC" packet_no=%u", left, pfc->packet_no);
|
||||||
|
|
||||||
|
MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats,
|
||||||
|
STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
|
||||||
|
STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE,
|
||||||
|
STAT_PACKETS_SENT, packets_sent);
|
||||||
|
|
||||||
|
if (compress_buf) {
|
||||||
|
mnd_efree(compress_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Even for zero size payload we have to send a packet */
|
||||||
|
if (!bytes_sent) {
|
||||||
|
DBG_ERR_FMT("Can't %u send bytes", count);
|
||||||
|
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||||
|
}
|
||||||
|
DBG_RETURN(bytes_sent);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
/* {{{ php_mysqlnd_read_buffer_is_empty */
|
||||||
|
static zend_bool
|
||||||
|
php_mysqlnd_read_buffer_is_empty(MYSQLND_READ_BUFFER * buffer)
|
||||||
|
{
|
||||||
|
return buffer->len? FALSE:TRUE;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ php_mysqlnd_read_buffer_read */
|
||||||
|
static void
|
||||||
|
php_mysqlnd_read_buffer_read(MYSQLND_READ_BUFFER * buffer, size_t count, zend_uchar * dest)
|
||||||
|
{
|
||||||
|
if (buffer->len >= count) {
|
||||||
|
memcpy(dest, buffer->data + buffer->offset, count);
|
||||||
|
buffer->offset += count;
|
||||||
|
buffer->len -= count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ php_mysqlnd_read_buffer_bytes_left */
|
||||||
|
static size_t
|
||||||
|
php_mysqlnd_read_buffer_bytes_left(MYSQLND_READ_BUFFER * buffer)
|
||||||
|
{
|
||||||
|
return buffer->len;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ php_mysqlnd_read_buffer_free */
|
||||||
|
static void
|
||||||
|
php_mysqlnd_read_buffer_free(MYSQLND_READ_BUFFER ** buffer)
|
||||||
|
{
|
||||||
|
DBG_ENTER("php_mysqlnd_read_buffer_free");
|
||||||
|
if (*buffer) {
|
||||||
|
mnd_efree((*buffer)->data);
|
||||||
|
mnd_efree(*buffer);
|
||||||
|
*buffer = NULL;
|
||||||
|
}
|
||||||
|
DBG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ php_mysqlnd_create_read_buffer */
|
||||||
|
static MYSQLND_READ_BUFFER *
|
||||||
|
mysqlnd_create_read_buffer(size_t count)
|
||||||
|
{
|
||||||
|
MYSQLND_READ_BUFFER * ret = mnd_emalloc(sizeof(MYSQLND_READ_BUFFER));
|
||||||
|
DBG_ENTER("mysqlnd_create_read_buffer");
|
||||||
|
ret->is_empty = php_mysqlnd_read_buffer_is_empty;
|
||||||
|
ret->read = php_mysqlnd_read_buffer_read;
|
||||||
|
ret->bytes_left = php_mysqlnd_read_buffer_bytes_left;
|
||||||
|
ret->free_buffer = php_mysqlnd_read_buffer_free;
|
||||||
|
ret->data = mnd_emalloc(count);
|
||||||
|
ret->size = ret->len = count;
|
||||||
|
ret->offset = 0;
|
||||||
|
DBG_RETURN(ret);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::read_compressed_packet_from_stream_and_fill_read_buffer */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, read_compressed_packet_from_stream_and_fill_read_buffer)
|
||||||
|
(MYSQLND_PFC * pfc, MYSQLND_VIO * vio, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info)
|
||||||
|
{
|
||||||
|
size_t decompressed_size;
|
||||||
|
enum_func_status retval = PASS;
|
||||||
|
zend_uchar * compressed_data = NULL;
|
||||||
|
zend_uchar comp_header[COMPRESSED_HEADER_SIZE];
|
||||||
|
DBG_ENTER("mysqlnd_pfc::read_compressed_packet_from_stream_and_fill_read_buffer");
|
||||||
|
|
||||||
|
/* Read the compressed header */
|
||||||
|
if (FAIL == vio->data->m.network_read(vio, comp_header, COMPRESSED_HEADER_SIZE, conn_stats, error_info)) {
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
}
|
||||||
|
decompressed_size = uint3korr(comp_header);
|
||||||
|
|
||||||
|
/* When decompressed_size is 0, then the data is not compressed, and we have wasted 3 bytes */
|
||||||
|
/* we need to decompress the data */
|
||||||
|
|
||||||
|
if (decompressed_size) {
|
||||||
|
compressed_data = mnd_emalloc(net_payload_size);
|
||||||
|
if (FAIL == vio->data->m.network_read(vio, compressed_data, net_payload_size, conn_stats, error_info)) {
|
||||||
|
retval = FAIL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
pfc->uncompressed_data = mysqlnd_create_read_buffer(decompressed_size);
|
||||||
|
retval = pfc->data->m.decode(pfc->uncompressed_data->data, decompressed_size, compressed_data, net_payload_size);
|
||||||
|
if (FAIL == retval) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_INF_FMT("The server decided not to compress the data. Our job is easy. Copying %u bytes", net_payload_size);
|
||||||
|
pfc->uncompressed_data = mysqlnd_create_read_buffer(net_payload_size);
|
||||||
|
if (FAIL == vio->data->m.network_read(vio, pfc->uncompressed_data->data, net_payload_size, conn_stats, error_info)) {
|
||||||
|
retval = FAIL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end:
|
||||||
|
if (compressed_data) {
|
||||||
|
mnd_efree(compressed_data);
|
||||||
|
}
|
||||||
|
DBG_RETURN(retval);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::decode */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len,
|
||||||
|
const zend_uchar * const compressed_data, const size_t compressed_data_len)
|
||||||
|
{
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
int error;
|
||||||
|
uLongf tmp_complen = uncompressed_data_len;
|
||||||
|
DBG_ENTER("mysqlnd_pfc::decode");
|
||||||
|
error = uncompress(uncompressed_data, &tmp_complen, compressed_data, compressed_data_len);
|
||||||
|
|
||||||
|
DBG_INF_FMT("compressed data: decomp_len=%lu compressed_size="MYSQLND_SZ_T_SPEC, tmp_complen, compressed_data_len);
|
||||||
|
if (error != Z_OK) {
|
||||||
|
DBG_INF_FMT("decompression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
|
||||||
|
}
|
||||||
|
DBG_RETURN(error == Z_OK? PASS:FAIL);
|
||||||
|
#else
|
||||||
|
DBG_ENTER("mysqlnd_pfc::decode");
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::encode */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len,
|
||||||
|
const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len)
|
||||||
|
{
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
int error;
|
||||||
|
uLongf tmp_complen = *compress_buffer_len;
|
||||||
|
DBG_ENTER("mysqlnd_pfc::encode");
|
||||||
|
error = compress(compress_buffer, &tmp_complen, uncompressed_data, uncompressed_data_len);
|
||||||
|
|
||||||
|
if (error != Z_OK) {
|
||||||
|
DBG_INF_FMT("compression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
|
||||||
|
} else {
|
||||||
|
*compress_buffer_len = tmp_complen;
|
||||||
|
DBG_INF_FMT("compression successful. compressed size=%lu", tmp_complen);
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_RETURN(error == Z_OK? PASS:FAIL);
|
||||||
|
#else
|
||||||
|
DBG_ENTER("mysqlnd_pfc::encode");
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::receive */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, receive)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count,
|
||||||
|
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
|
||||||
|
{
|
||||||
|
size_t to_read = count;
|
||||||
|
zend_uchar * p = buffer;
|
||||||
|
|
||||||
|
DBG_ENTER("mysqlnd_pfc::receive");
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
if (pfc->data->compressed) {
|
||||||
|
if (pfc->uncompressed_data) {
|
||||||
|
size_t to_read_from_buffer = MIN(pfc->uncompressed_data->bytes_left(pfc->uncompressed_data), to_read);
|
||||||
|
DBG_INF_FMT("reading "MYSQLND_SZ_T_SPEC" from uncompressed_data buffer", to_read_from_buffer);
|
||||||
|
if (to_read_from_buffer) {
|
||||||
|
pfc->uncompressed_data->read(pfc->uncompressed_data, to_read_from_buffer, (zend_uchar *) p);
|
||||||
|
p += to_read_from_buffer;
|
||||||
|
to_read -= to_read_from_buffer;
|
||||||
|
}
|
||||||
|
DBG_INF_FMT("left "MYSQLND_SZ_T_SPEC" to read", to_read);
|
||||||
|
if (TRUE == pfc->uncompressed_data->is_empty(pfc->uncompressed_data)) {
|
||||||
|
/* Everything was consumed. This should never happen here, but for security */
|
||||||
|
pfc->uncompressed_data->free_buffer(&pfc->uncompressed_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (to_read) {
|
||||||
|
zend_uchar net_header[MYSQLND_HEADER_SIZE];
|
||||||
|
size_t net_payload_size;
|
||||||
|
zend_uchar packet_no;
|
||||||
|
|
||||||
|
if (FAIL == vio->data->m.network_read(vio, net_header, MYSQLND_HEADER_SIZE, conn_stats, error_info)) {
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
}
|
||||||
|
net_payload_size = uint3korr(net_header);
|
||||||
|
packet_no = uint1korr(net_header + 3);
|
||||||
|
if (pfc->compressed_envelope_packet_no != packet_no) {
|
||||||
|
DBG_ERR_FMT("Transport level: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
||||||
|
pfc->compressed_envelope_packet_no, packet_no, net_payload_size);
|
||||||
|
|
||||||
|
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
||||||
|
pfc->compressed_envelope_packet_no, packet_no, net_payload_size);
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
}
|
||||||
|
pfc->compressed_envelope_packet_no++;
|
||||||
|
#ifdef MYSQLND_DUMP_HEADER_N_BODY
|
||||||
|
DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (zend_ulong) net_payload_size);
|
||||||
|
#endif
|
||||||
|
/* Now let's read from the wire, decompress it and fill the read buffer */
|
||||||
|
pfc->data->m.read_compressed_packet_from_stream_and_fill_read_buffer(pfc, vio, net_payload_size, conn_stats, error_info);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Now a bit of recursion - read from the read buffer,
|
||||||
|
if the data which we have just read from the wire
|
||||||
|
is not enough, then the recursive call will try to
|
||||||
|
satisfy it until it is satisfied.
|
||||||
|
*/
|
||||||
|
DBG_RETURN(pfc->data->m.receive(pfc, vio, p, to_read, conn_stats, error_info));
|
||||||
|
}
|
||||||
|
DBG_RETURN(PASS);
|
||||||
|
}
|
||||||
|
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
||||||
|
DBG_RETURN(vio->data->m.network_read(vio, p, to_read, conn_stats, error_info));
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::set_client_option */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, set_client_option)(MYSQLND_PFC * const pfc, enum_mysqlnd_client_option option, const char * const value)
|
||||||
|
{
|
||||||
|
DBG_ENTER("mysqlnd_pfc::set_client_option");
|
||||||
|
DBG_INF_FMT("option=%u", option);
|
||||||
|
switch (option) {
|
||||||
|
case MYSQL_OPT_COMPRESS:
|
||||||
|
pfc->data->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION;
|
||||||
|
break;
|
||||||
|
case MYSQL_SERVER_PUBLIC_KEY:
|
||||||
|
{
|
||||||
|
zend_bool pers = pfc->persistent;
|
||||||
|
if (pfc->data->options.sha256_server_public_key) {
|
||||||
|
mnd_pefree(pfc->data->options.sha256_server_public_key, pers);
|
||||||
|
}
|
||||||
|
pfc->data->options.sha256_server_public_key = value? mnd_pestrdup(value, pers) : NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
}
|
||||||
|
DBG_RETURN(PASS);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::free_contents */
|
||||||
|
static void
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, free_contents)(MYSQLND_PFC * pfc)
|
||||||
|
{
|
||||||
|
DBG_ENTER("mysqlnd_pfc::free_contents");
|
||||||
|
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
if (pfc->uncompressed_data) {
|
||||||
|
pfc->uncompressed_data->free_buffer(&pfc->uncompressed_data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (pfc->data->options.sha256_server_public_key) {
|
||||||
|
mnd_pefree(pfc->data->options.sha256_server_public_key, pfc->persistent);
|
||||||
|
pfc->data->options.sha256_server_public_key = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::init */
|
||||||
|
static enum_func_status
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, init)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
|
||||||
|
{
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc::dtor */
|
||||||
|
static void
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, dtor)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
|
||||||
|
{
|
||||||
|
DBG_ENTER("mysqlnd_pfc::dtor");
|
||||||
|
if (pfc) {
|
||||||
|
pfc->data->m.free_contents(pfc);
|
||||||
|
|
||||||
|
mnd_pefree(pfc->data, pfc->data->persistent);
|
||||||
|
mnd_pefree(pfc, pfc->persistent);
|
||||||
|
}
|
||||||
|
DBG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
MYSQLND_CLASS_METHODS_START(mysqlnd_protocol_packet_envelope_codec)
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, init),
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, dtor),
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, reset),
|
||||||
|
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, set_client_option),
|
||||||
|
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, decode),
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, encode),
|
||||||
|
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, send),
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, receive),
|
||||||
|
|
||||||
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, read_compressed_packet_from_stream_and_fill_read_buffer),
|
||||||
|
#else
|
||||||
|
NULL,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MYSQLND_METHOD(mysqlnd_pfc, free_contents),
|
||||||
|
MYSQLND_CLASS_METHODS_END;
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc_init */
|
||||||
|
PHPAPI MYSQLND_PFC *
|
||||||
|
mysqlnd_pfc_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
|
||||||
|
{
|
||||||
|
MYSQLND_PFC * pfc;
|
||||||
|
DBG_ENTER("mysqlnd_pfc_init");
|
||||||
|
pfc = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_net(persistent, stats, error_info);
|
||||||
|
DBG_RETURN(pfc);
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ mysqlnd_pfc_free */
|
||||||
|
PHPAPI void
|
||||||
|
mysqlnd_pfc_free(MYSQLND_PFC * const pfc, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
|
||||||
|
{
|
||||||
|
DBG_ENTER("mysqlnd_pfc_free");
|
||||||
|
if (pfc) {
|
||||||
|
pfc->data->m.dtor(pfc, stats, error_info);
|
||||||
|
}
|
||||||
|
DBG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
35
ext/mysqlnd/mysqlnd_protocol_frame_codec.h
Normal file
35
ext/mysqlnd/mysqlnd_protocol_frame_codec.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| PHP Version 7 |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| Copyright (c) 2006-2015 The PHP Group |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| This source file is subject to version 3.01 of the PHP license, |
|
||||||
|
| that is bundled with this package in the file LICENSE, and is |
|
||||||
|
| available through the world-wide-web at the following url: |
|
||||||
|
| http://www.php.net/license/3_01.txt |
|
||||||
|
| If you did not receive a copy of the PHP license and are unable to |
|
||||||
|
| obtain it through the world-wide-web, please send a note to |
|
||||||
|
| license@php.net so we can mail you a copy immediately. |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| Authors: Andrey Hristov <andrey@mysql.com> |
|
||||||
|
| Ulf Wendel <uwendel@mysql.com> |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MYSQLND_PROTOCOL_FRAME_CODEC_H
|
||||||
|
#define MYSQLND_PROTOCOL_FRAME_CODEC_H
|
||||||
|
|
||||||
|
PHPAPI MYSQLND_PFC * mysqlnd_pfc_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
||||||
|
PHPAPI void mysqlnd_pfc_free(MYSQLND_PFC * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
||||||
|
|
||||||
|
#endif /* MYSQLND_PROTOCOL_FRAME_CODEC_H */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* tab-width: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* End:
|
||||||
|
* vim600: noet sw=4 ts=4 fdm=marker
|
||||||
|
* vim<600: noet sw=4 ts=4
|
||||||
|
*/
|
|
@ -17,8 +17,6 @@
|
||||||
| Georg Richter <georg@mysql.com> |
|
| Georg Richter <georg@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
#include "mysqlnd_wireprotocol.h"
|
#include "mysqlnd_wireprotocol.h"
|
||||||
|
@ -1444,7 +1442,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
|
||||||
#if HAVE_USLEEP && !defined(PHP_WIN32)
|
#if HAVE_USLEEP && !defined(PHP_WIN32)
|
||||||
usleep(120000);
|
usleep(120000);
|
||||||
#endif
|
#endif
|
||||||
if ((packet_len = conn->net->m.consume_uneaten_data(conn->net, COM_STMT_SEND_LONG_DATA))) {
|
if ((packet_len = conn->protocol_frame_codec->m.consume_uneaten_data(conn->protocol_frame_codec, COM_STMT_SEND_LONG_DATA))) {
|
||||||
php_error_docref(NULL, E_WARNING, "There was an error "
|
php_error_docref(NULL, E_WARNING, "There was an error "
|
||||||
"while sending long data. Probably max_allowed_packet_size "
|
"while sending long data. Probably max_allowed_packet_size "
|
||||||
"is smaller than the data. You have to increase it or send "
|
"is smaller than the data. You have to increase it or send "
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef MYSQLND_STRUCTS_H
|
#ifndef MYSQLND_STRUCTS_H
|
||||||
#define MYSQLND_STRUCTS_H
|
#define MYSQLND_STRUCTS_H
|
||||||
|
|
||||||
|
@ -235,12 +233,12 @@ typedef struct st_mysqlnd_session_options
|
||||||
} MYSQLND_SESSION_OPTIONS;
|
} MYSQLND_SESSION_OPTIONS;
|
||||||
|
|
||||||
|
|
||||||
typedef struct st_mysqlnd_protocol_packet_envelope_codec_options
|
typedef struct st_mysqlnd_protocol_frame_codec_options
|
||||||
{
|
{
|
||||||
uint64_t flags;
|
uint64_t flags;
|
||||||
|
|
||||||
char * sha256_server_public_key;
|
char * sha256_server_public_key;
|
||||||
} MYSQLND_PPEC_OPTIONS;
|
} MYSQLND_PFC_OPTIONS;
|
||||||
|
|
||||||
|
|
||||||
typedef struct st_mysqlnd_vio_options
|
typedef struct st_mysqlnd_vio_options
|
||||||
|
@ -272,8 +270,8 @@ typedef struct st_mysqlnd_vio_options
|
||||||
|
|
||||||
typedef struct st_mysqlnd_connection MYSQLND;
|
typedef struct st_mysqlnd_connection MYSQLND;
|
||||||
typedef struct st_mysqlnd_connection_data MYSQLND_CONN_DATA;
|
typedef struct st_mysqlnd_connection_data MYSQLND_CONN_DATA;
|
||||||
typedef struct st_mysqlnd_protocol_packet_envelope_codec MYSQLND_PPEC;
|
typedef struct st_mysqlnd_protocol_frame_codec MYSQLND_PFC;
|
||||||
typedef struct st_mysqlnd_protocol_packet_envelope_codec_data MYSQLND_PPEC_DATA;
|
typedef struct st_mysqlnd_protocol_frame_codec_data MYSQLND_PFC_DATA;
|
||||||
typedef struct st_mysqlnd_vio MYSQLND_VIO;
|
typedef struct st_mysqlnd_vio MYSQLND_VIO;
|
||||||
typedef struct st_mysqlnd_vio_data MYSQLND_VIO_DATA;
|
typedef struct st_mysqlnd_vio_data MYSQLND_VIO_DATA;
|
||||||
typedef struct st_mysqlnd_protocol_payload_decoder_factory MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY;
|
typedef struct st_mysqlnd_protocol_payload_decoder_factory MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY;
|
||||||
|
@ -378,7 +376,7 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory);
|
||||||
typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(struct st_mysqlnd_object_factory_methods * factory, zend_bool persistent);
|
typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(struct st_mysqlnd_object_factory_methods * factory, zend_bool persistent);
|
||||||
typedef MYSQLND * (*func_mysqlnd_object_factory__clone_connection_object)(MYSQLND * conn);
|
typedef MYSQLND * (*func_mysqlnd_object_factory__clone_connection_object)(MYSQLND * conn);
|
||||||
typedef MYSQLND_STMT * (*func_mysqlnd_object_factory__get_prepared_statement)(MYSQLND_CONN_DATA * conn, zend_bool persistent);
|
typedef MYSQLND_STMT * (*func_mysqlnd_object_factory__get_prepared_statement)(MYSQLND_CONN_DATA * conn, zend_bool persistent);
|
||||||
typedef MYSQLND_PPEC * (*func_mysqlnd_object_factory__get_net)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
typedef MYSQLND_PFC * (*func_mysqlnd_object_factory__get_net)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
||||||
typedef MYSQLND_VIO * (*func_mysqlnd_object_factory__get_vio)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
typedef MYSQLND_VIO * (*func_mysqlnd_object_factory__get_vio)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
||||||
typedef MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * (*func_mysqlnd_object_factory__get_protocol_payload_decoder_factory)(MYSQLND_CONN_DATA * conn, zend_bool persistent);
|
typedef MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * (*func_mysqlnd_object_factory__get_protocol_payload_decoder_factory)(MYSQLND_CONN_DATA * conn, zend_bool persistent);
|
||||||
|
|
||||||
|
@ -886,7 +884,7 @@ struct st_mysqlnd_connection_state
|
||||||
struct st_mysqlnd_connection_data
|
struct st_mysqlnd_connection_data
|
||||||
{
|
{
|
||||||
/* Operation related */
|
/* Operation related */
|
||||||
MYSQLND_PPEC * net;
|
MYSQLND_PFC * protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio;
|
MYSQLND_VIO * vio;
|
||||||
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory;
|
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory;
|
||||||
|
|
||||||
|
@ -1088,42 +1086,42 @@ typedef struct st_mysqlnd_read_buffer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum_func_status (*func_mysqlnd_ppec__init)(MYSQLND_PPEC * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
|
typedef enum_func_status (*func_mysqlnd_pfc__init)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
|
||||||
typedef void (*func_mysqlnd_ppec__dtor)(MYSQLND_PPEC * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
|
typedef void (*func_mysqlnd_pfc__dtor)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
|
||||||
typedef enum_func_status (*func_mysqlnd_ppec__connect)(MYSQLND_PPEC * const net, const MYSQLND_CSTRING scheme, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
|
typedef enum_func_status (*func_mysqlnd_pfc__reset)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
|
||||||
typedef enum_func_status (*func_mysqlnd_ppec__set_client_option)(MYSQLND_PPEC * const net, enum_mysqlnd_client_option option, const char * const value);
|
typedef enum_func_status (*func_mysqlnd_pfc__set_client_option)(MYSQLND_PFC * const pfc, enum_mysqlnd_client_option option, const char * const value);
|
||||||
typedef enum_func_status (*func_mysqlnd_ppec__decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len, const zend_uchar * const compressed_data, const size_t compressed_data_len);
|
typedef enum_func_status (*func_mysqlnd_pfc__decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len, const zend_uchar * const compressed_data, const size_t compressed_data_len);
|
||||||
typedef enum_func_status (*func_mysqlnd_ppec__encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len, const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len);
|
typedef enum_func_status (*func_mysqlnd_pfc__encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len, const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len);
|
||||||
typedef size_t (*func_mysqlnd_ppec__send)(MYSQLND_PPEC * const net, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
|
typedef size_t (*func_mysqlnd_pfc__send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const vio, 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_ppec__receive)(MYSQLND_PPEC * const net, MYSQLND_VIO * const vio, 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_pfc__receive)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const vio, 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_ppec__read_compressed_packet_from_stream_and_fill_read_buffer)(MYSQLND_PPEC * net, MYSQLND_VIO * const vio, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info);
|
typedef enum_func_status (*func_mysqlnd_pfc__read_compressed_packet_from_stream_and_fill_read_buffer)(MYSQLND_PFC * pfc, MYSQLND_VIO * const vio, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info);
|
||||||
typedef void (*func_mysqlnd_ppec__free_contents)(MYSQLND_PPEC * net);
|
typedef void (*func_mysqlnd_pfc__free_contents)(MYSQLND_PFC * pfc);
|
||||||
|
|
||||||
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec)
|
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec)
|
||||||
{
|
{
|
||||||
func_mysqlnd_ppec__init init;
|
func_mysqlnd_pfc__init init;
|
||||||
func_mysqlnd_ppec__dtor dtor;
|
func_mysqlnd_pfc__dtor dtor;
|
||||||
func_mysqlnd_ppec__connect connect;
|
func_mysqlnd_pfc__reset reset;
|
||||||
func_mysqlnd_ppec__set_client_option set_client_option;
|
func_mysqlnd_pfc__set_client_option set_client_option;
|
||||||
|
|
||||||
func_mysqlnd_ppec__decode decode;
|
func_mysqlnd_pfc__decode decode;
|
||||||
func_mysqlnd_ppec__encode encode;
|
func_mysqlnd_pfc__encode encode;
|
||||||
|
|
||||||
func_mysqlnd_ppec__send send;
|
func_mysqlnd_pfc__send send;
|
||||||
func_mysqlnd_ppec__receive receive;
|
func_mysqlnd_pfc__receive receive;
|
||||||
|
|
||||||
func_mysqlnd_ppec__read_compressed_packet_from_stream_and_fill_read_buffer read_compressed_packet_from_stream_and_fill_read_buffer;
|
func_mysqlnd_pfc__read_compressed_packet_from_stream_and_fill_read_buffer read_compressed_packet_from_stream_and_fill_read_buffer;
|
||||||
|
|
||||||
func_mysqlnd_ppec__free_contents free_contents;
|
func_mysqlnd_pfc__free_contents free_contents;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct st_mysqlnd_protocol_packet_envelope_codec_data
|
struct st_mysqlnd_protocol_frame_codec_data
|
||||||
{
|
{
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
zend_bool compressed;
|
zend_bool compressed;
|
||||||
zend_bool ssl;
|
zend_bool ssl;
|
||||||
MYSQLND_PPEC_OPTIONS options;
|
MYSQLND_PFC_OPTIONS options;
|
||||||
|
|
||||||
unsigned int refcount;
|
unsigned int refcount;
|
||||||
|
|
||||||
|
@ -1133,9 +1131,9 @@ struct st_mysqlnd_protocol_packet_envelope_codec_data
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct st_mysqlnd_protocol_packet_envelope_codec
|
struct st_mysqlnd_protocol_frame_codec
|
||||||
{
|
{
|
||||||
struct st_mysqlnd_protocol_packet_envelope_codec_data * data;
|
struct st_mysqlnd_protocol_frame_codec_data * data;
|
||||||
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||||
MYSQLND_READ_BUFFER * uncompressed_data;
|
MYSQLND_READ_BUFFER * uncompressed_data;
|
||||||
|
@ -1372,7 +1370,7 @@ typedef zend_uchar * (*func_auth_plugin__get_auth_data)(struct st_mysqlnd_authen
|
||||||
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
|
||||||
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
|
||||||
const MYSQLND_SESSION_OPTIONS * const session_options,
|
const MYSQLND_SESSION_OPTIONS * const session_options,
|
||||||
const MYSQLND_PPEC_OPTIONS * const net_options, zend_ulong mysql_flags
|
const MYSQLND_PFC_OPTIONS * const pfc_options, zend_ulong mysql_flags
|
||||||
);
|
);
|
||||||
|
|
||||||
struct st_mysqlnd_authentication_plugin
|
struct st_mysqlnd_authentication_plugin
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
| Ulf Wendel <uwendel@mysql.com> |
|
| Ulf Wendel <uwendel@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: mysqlnd_ps.c 316906 2011-09-17 10:24:18Z pajoye $ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_globals.h"
|
#include "php_globals.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
| Ulf Wendel <uwendel@mysql.com> |
|
| Ulf Wendel <uwendel@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MYSQLND_VIO_H
|
#ifndef MYSQLND_VIO_H
|
||||||
#define MYSQLND_VIO_H
|
#define MYSQLND_VIO_H
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_globals.h"
|
#include "php_globals.h"
|
||||||
#include "mysqlnd.h"
|
#include "mysqlnd.h"
|
||||||
|
@ -27,9 +26,6 @@
|
||||||
#include "mysqlnd_statistics.h"
|
#include "mysqlnd_statistics.h"
|
||||||
#include "mysqlnd_debug.h"
|
#include "mysqlnd_debug.h"
|
||||||
#include "zend_ini.h"
|
#include "zend_ini.h"
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
#include <zlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MYSQLND_SILENT 1
|
#define MYSQLND_SILENT 1
|
||||||
#define MYSQLND_DUMP_HEADER_N_BODY
|
#define MYSQLND_DUMP_HEADER_N_BODY
|
||||||
|
@ -248,14 +244,14 @@ end:
|
||||||
|
|
||||||
/* {{{ mysqlnd_read_header */
|
/* {{{ mysqlnd_read_header */
|
||||||
static enum_func_status
|
static enum_func_status
|
||||||
mysqlnd_read_header(MYSQLND_PPEC * net, MYSQLND_VIO * vio, MYSQLND_PACKET_HEADER * header,
|
mysqlnd_read_header(MYSQLND_PFC * pfc, MYSQLND_VIO * vio, MYSQLND_PACKET_HEADER * header,
|
||||||
MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info)
|
MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info)
|
||||||
{
|
{
|
||||||
zend_uchar buffer[MYSQLND_HEADER_SIZE];
|
zend_uchar buffer[MYSQLND_HEADER_SIZE];
|
||||||
|
|
||||||
DBG_ENTER(mysqlnd_read_header_name);
|
DBG_ENTER(mysqlnd_read_header_name);
|
||||||
DBG_INF_FMT("compressed=%u", net->data->compressed);
|
DBG_INF_FMT("compressed=%u", pfc->data->compressed);
|
||||||
if (FAIL == net->data->m.receive(net, vio, buffer, MYSQLND_HEADER_SIZE, conn_stats, error_info)) {
|
if (FAIL == pfc->data->m.receive(pfc, vio, buffer, MYSQLND_HEADER_SIZE, conn_stats, error_info)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,21 +265,21 @@ mysqlnd_read_header(MYSQLND_PPEC * net, MYSQLND_VIO * vio, MYSQLND_PACKET_HEADER
|
||||||
STAT_PROTOCOL_OVERHEAD_IN, MYSQLND_HEADER_SIZE,
|
STAT_PROTOCOL_OVERHEAD_IN, MYSQLND_HEADER_SIZE,
|
||||||
STAT_PACKETS_RECEIVED, 1);
|
STAT_PACKETS_RECEIVED, 1);
|
||||||
|
|
||||||
if (net->data->compressed || net->packet_no == header->packet_no) {
|
if (pfc->data->compressed || pfc->packet_no == header->packet_no) {
|
||||||
/*
|
/*
|
||||||
Have to increase the number, so we can send correct number back. It will
|
Have to increase the number, so we can send correct number back. It will
|
||||||
round at 255 as this is unsigned char. The server needs this for simple
|
round at 255 as this is unsigned char. The server needs this for simple
|
||||||
flow control checking.
|
flow control checking.
|
||||||
*/
|
*/
|
||||||
net->packet_no++;
|
pfc->packet_no++;
|
||||||
DBG_RETURN(PASS);
|
DBG_RETURN(PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_ERR_FMT("Logical link: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
DBG_ERR_FMT("Logical link: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
||||||
net->packet_no, header->packet_no, header->size);
|
pfc->packet_no, header->packet_no, header->size);
|
||||||
|
|
||||||
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
||||||
net->packet_no, header->packet_no, header->size);
|
pfc->packet_no, header->packet_no, header->size);
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -292,7 +288,7 @@ mysqlnd_read_header(MYSQLND_PPEC * net, MYSQLND_VIO * vio, MYSQLND_PACKET_HEADER
|
||||||
/* {{{ mysqlnd_read_packet_header_and_body */
|
/* {{{ mysqlnd_read_packet_header_and_body */
|
||||||
static enum_func_status
|
static enum_func_status
|
||||||
mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
|
mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
|
||||||
MYSQLND_PPEC * net,
|
MYSQLND_PFC * pfc,
|
||||||
MYSQLND_VIO * vio,
|
MYSQLND_VIO * vio,
|
||||||
MYSQLND_STATS * stats,
|
MYSQLND_STATS * stats,
|
||||||
MYSQLND_ERROR_INFO * error_info,
|
MYSQLND_ERROR_INFO * error_info,
|
||||||
|
@ -302,7 +298,7 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
|
||||||
{
|
{
|
||||||
DBG_ENTER("mysqlnd_read_packet_header_and_body");
|
DBG_ENTER("mysqlnd_read_packet_header_and_body");
|
||||||
DBG_INF_FMT("buf=%p size=%u", buf, buf_size);
|
DBG_INF_FMT("buf=%p size=%u", buf, buf_size);
|
||||||
if (FAIL == mysqlnd_read_header(net, vio, packet_header, stats, error_info)) {
|
if (FAIL == mysqlnd_read_header(pfc, vio, packet_header, stats, error_info)) {
|
||||||
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
|
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
|
||||||
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||||
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
|
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
|
||||||
|
@ -314,7 +310,7 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
|
||||||
buf_size, packet_header->size, packet_header->size - buf_size);
|
buf_size, packet_header->size, packet_header->size - buf_size);
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
if (FAIL == net->data->m.receive(net, vio, buf, packet_header->size, stats, error_info)) {
|
if (FAIL == pfc->data->m.receive(pfc, vio, buf, packet_header->size, stats, error_info)) {
|
||||||
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
|
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
|
||||||
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||||
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
|
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
|
||||||
|
@ -340,14 +336,14 @@ php_mysqlnd_greet_read(void * _packet)
|
||||||
zend_uchar *pad_start = NULL;
|
zend_uchar *pad_start = NULL;
|
||||||
MYSQLND_PACKET_GREET *packet= (MYSQLND_PACKET_GREET *) _packet;
|
MYSQLND_PACKET_GREET *packet= (MYSQLND_PACKET_GREET *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_greet_read");
|
DBG_ENTER("php_mysqlnd_greet_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, sizeof(buf), "greeting", PROT_GREET_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, sizeof(buf), "greeting", PROT_GREET_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -509,7 +505,7 @@ size_t php_mysqlnd_auth_write(void * _packet)
|
||||||
MYSQLND_PACKET_AUTH * packet= (MYSQLND_PACKET_AUTH *) _packet;
|
MYSQLND_PACKET_AUTH * packet= (MYSQLND_PACKET_AUTH *) _packet;
|
||||||
MYSQLND_CONN_DATA * conn = packet->header.conn;
|
MYSQLND_CONN_DATA * conn = packet->header.conn;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -641,7 +637,7 @@ size_t php_mysqlnd_auth_write(void * _packet)
|
||||||
|
|
||||||
DBG_RETURN(ret == PASS? (p - buffer - MYSQLND_HEADER_SIZE) : 0);
|
DBG_RETURN(ret == PASS? (p - buffer - MYSQLND_HEADER_SIZE) : 0);
|
||||||
} else {
|
} else {
|
||||||
size_t sent = net->data->m.send(net, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
|
size_t sent = pfc->data->m.send(pfc, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
|
||||||
if (!sent) {
|
if (!sent) {
|
||||||
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
|
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
|
||||||
}
|
}
|
||||||
|
@ -671,7 +667,7 @@ php_mysqlnd_auth_response_read(void * _packet)
|
||||||
{
|
{
|
||||||
register MYSQLND_PACKET_AUTH_RESPONSE * packet= (MYSQLND_PACKET_AUTH_RESPONSE *) _packet;
|
register MYSQLND_PACKET_AUTH_RESPONSE * packet= (MYSQLND_PACKET_AUTH_RESPONSE *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -686,7 +682,7 @@ php_mysqlnd_auth_response_read(void * _packet)
|
||||||
|
|
||||||
/* leave space for terminating safety \0 */
|
/* leave space for terminating safety \0 */
|
||||||
buf_len--;
|
buf_len--;
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "OK", PROT_OK_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "OK", PROT_OK_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -798,7 +794,7 @@ php_mysqlnd_change_auth_response_write(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *packet= (MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *) _packet;
|
MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *packet= (MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -813,7 +809,7 @@ php_mysqlnd_change_auth_response_write(void * _packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t sent = net->data->m.send(net, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
|
size_t sent = pfc->data->m.send(pfc, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
|
||||||
if (buffer != vio->cmd_buffer.buffer) {
|
if (buffer != vio->cmd_buffer.buffer) {
|
||||||
mnd_efree(buffer);
|
mnd_efree(buffer);
|
||||||
}
|
}
|
||||||
|
@ -846,7 +842,7 @@ php_mysqlnd_ok_read(void * _packet)
|
||||||
{
|
{
|
||||||
register MYSQLND_PACKET_OK *packet= (MYSQLND_PACKET_OK *) _packet;
|
register MYSQLND_PACKET_OK *packet= (MYSQLND_PACKET_OK *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -859,7 +855,7 @@ php_mysqlnd_ok_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_ok_read");
|
DBG_ENTER("php_mysqlnd_ok_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "OK", PROT_OK_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "OK", PROT_OK_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -944,7 +940,7 @@ php_mysqlnd_eof_read(void * _packet)
|
||||||
*/
|
*/
|
||||||
MYSQLND_PACKET_EOF *packet= (MYSQLND_PACKET_EOF *) _packet;
|
MYSQLND_PACKET_EOF *packet= (MYSQLND_PACKET_EOF *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -955,7 +951,7 @@ php_mysqlnd_eof_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_eof_read");
|
DBG_ENTER("php_mysqlnd_eof_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "EOF", PROT_EOF_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "EOF", PROT_EOF_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -1023,7 +1019,7 @@ size_t php_mysqlnd_cmd_write(void * _packet)
|
||||||
/* Let's have some space, which we can use, if not enough, we will allocate new buffer */
|
/* Let's have some space, which we can use, if not enough, we will allocate new buffer */
|
||||||
MYSQLND_PACKET_COMMAND * packet= (MYSQLND_PACKET_COMMAND *) _packet;
|
MYSQLND_PACKET_COMMAND * packet= (MYSQLND_PACKET_COMMAND *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -1035,8 +1031,7 @@ size_t php_mysqlnd_cmd_write(void * _packet)
|
||||||
Reset packet_no, or we will get bad handshake!
|
Reset packet_no, or we will get bad handshake!
|
||||||
Every command starts a new TX and packet numbers are reset to 0.
|
Every command starts a new TX and packet numbers are reset to 0.
|
||||||
*/
|
*/
|
||||||
net->packet_no = 0;
|
pfc->data->m.reset(pfc, stats, error_info);
|
||||||
net->compressed_envelope_packet_no = 0; /* this is for the response */
|
|
||||||
|
|
||||||
if (error_reporting) {
|
if (error_reporting) {
|
||||||
EG(error_reporting) = 0;
|
EG(error_reporting) = 0;
|
||||||
|
@ -1052,7 +1047,7 @@ size_t php_mysqlnd_cmd_write(void * _packet)
|
||||||
zend_uchar buffer[MYSQLND_HEADER_SIZE + 1];
|
zend_uchar buffer[MYSQLND_HEADER_SIZE + 1];
|
||||||
|
|
||||||
int1store(buffer + MYSQLND_HEADER_SIZE, packet->command);
|
int1store(buffer + MYSQLND_HEADER_SIZE, packet->command);
|
||||||
sent = net->data->m.send(net, vio, buffer, 1, stats, error_info);
|
sent = pfc->data->m.send(pfc, vio, buffer, 1, stats, error_info);
|
||||||
} else {
|
} else {
|
||||||
size_t tmp_len = packet->argument.l + 1 + MYSQLND_HEADER_SIZE;
|
size_t tmp_len = packet->argument.l + 1 + MYSQLND_HEADER_SIZE;
|
||||||
zend_uchar *tmp, *p;
|
zend_uchar *tmp, *p;
|
||||||
|
@ -1067,7 +1062,7 @@ size_t php_mysqlnd_cmd_write(void * _packet)
|
||||||
|
|
||||||
memcpy(p, packet->argument.s, packet->argument.l);
|
memcpy(p, packet->argument.s, packet->argument.l);
|
||||||
|
|
||||||
sent = net->data->m.send(net, vio, tmp, tmp_len - MYSQLND_HEADER_SIZE, stats, error_info);
|
sent = pfc->data->m.send(pfc, vio, tmp, tmp_len - MYSQLND_HEADER_SIZE, stats, error_info);
|
||||||
if (tmp != vio->cmd_buffer.buffer) {
|
if (tmp != vio->cmd_buffer.buffer) {
|
||||||
MYSQLND_INC_CONN_STATISTIC(stats, STAT_CMD_BUFFER_TOO_SMALL);
|
MYSQLND_INC_CONN_STATISTIC(stats, STAT_CMD_BUFFER_TOO_SMALL);
|
||||||
mnd_efree(tmp);
|
mnd_efree(tmp);
|
||||||
|
@ -1104,7 +1099,7 @@ php_mysqlnd_rset_header_read(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_RSET_HEADER * packet= (MYSQLND_PACKET_RSET_HEADER *) _packet;
|
MYSQLND_PACKET_RSET_HEADER * packet= (MYSQLND_PACKET_RSET_HEADER *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -1117,7 +1112,7 @@ php_mysqlnd_rset_header_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_rset_header_read");
|
DBG_ENTER("php_mysqlnd_rset_header_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "resultset header", PROT_RSET_HEADER_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "resultset header", PROT_RSET_HEADER_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -1250,7 +1245,7 @@ php_mysqlnd_rset_field_read(void * _packet)
|
||||||
/* Should be enough for the metadata of a single row */
|
/* Should be enough for the metadata of a single row */
|
||||||
MYSQLND_PACKET_RES_FIELD *packet = (MYSQLND_PACKET_RES_FIELD *) _packet;
|
MYSQLND_PACKET_RES_FIELD *packet = (MYSQLND_PACKET_RES_FIELD *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -1265,7 +1260,7 @@ php_mysqlnd_rset_field_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_rset_field_read");
|
DBG_ENTER("php_mysqlnd_rset_field_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "field", PROT_RSET_FLD_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "field", PROT_RSET_FLD_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1465,7 +1460,7 @@ void php_mysqlnd_rset_field_free_mem(void * _packet, zend_bool stack_allocation)
|
||||||
|
|
||||||
/* {{{ php_mysqlnd_read_row_ex */
|
/* {{{ php_mysqlnd_read_row_ex */
|
||||||
static enum_func_status
|
static enum_func_status
|
||||||
php_mysqlnd_read_row_ex(MYSQLND_PPEC * net,
|
php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
|
||||||
MYSQLND_VIO * vio,
|
MYSQLND_VIO * vio,
|
||||||
MYSQLND_STATS * stats,
|
MYSQLND_STATS * stats,
|
||||||
MYSQLND_ERROR_INFO * error_info,
|
MYSQLND_ERROR_INFO * error_info,
|
||||||
|
@ -1491,7 +1486,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PPEC * net,
|
||||||
|
|
||||||
*data_size = prealloc_more_bytes;
|
*data_size = prealloc_more_bytes;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (FAIL == mysqlnd_read_header(net, vio, &header, stats, error_info)) {
|
if (FAIL == mysqlnd_read_header(pfc, vio, &header, stats, error_info)) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1524,7 +1519,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PPEC * net,
|
||||||
p = (*buffer)->ptr + (*data_size - header.size);
|
p = (*buffer)->ptr + (*data_size - header.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PASS != (ret = net->data->m.receive(net, vio, p, header.size, stats, error_info))) {
|
if (PASS != (ret = pfc->data->m.receive(pfc, vio, p, header.size, stats, error_info))) {
|
||||||
DBG_ERR("Empty row packet body");
|
DBG_ERR("Empty row packet body");
|
||||||
php_error(E_WARNING, "Empty row packet body");
|
php_error(E_WARNING, "Empty row packet body");
|
||||||
break;
|
break;
|
||||||
|
@ -1825,7 +1820,7 @@ php_mysqlnd_rowp_read(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_ROW *packet= (MYSQLND_PACKET_ROW *) _packet;
|
MYSQLND_PACKET_ROW *packet= (MYSQLND_PACKET_ROW *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
zend_uchar *p;
|
zend_uchar *p;
|
||||||
|
@ -1840,7 +1835,7 @@ php_mysqlnd_rowp_read(void * _packet)
|
||||||
post_alloc_for_bit_fields = packet->bit_fields_total_len + packet->bit_fields_count;
|
post_alloc_for_bit_fields = packet->bit_fields_total_len + packet->bit_fields_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = php_mysqlnd_read_row_ex(net, vio, stats, error_info,
|
ret = php_mysqlnd_read_row_ex(pfc, vio, stats, error_info,
|
||||||
packet->result_set_memory_pool, &packet->row_buffer, &data_size,
|
packet->result_set_memory_pool, &packet->row_buffer, &data_size,
|
||||||
packet->persistent_alloc, post_alloc_for_bit_fields
|
packet->persistent_alloc, post_alloc_for_bit_fields
|
||||||
);
|
);
|
||||||
|
@ -1950,7 +1945,7 @@ php_mysqlnd_stats_read(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_STATS *packet= (MYSQLND_PACKET_STATS *) _packet;
|
MYSQLND_PACKET_STATS *packet= (MYSQLND_PACKET_STATS *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -1959,7 +1954,7 @@ php_mysqlnd_stats_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_stats_read");
|
DBG_ENTER("php_mysqlnd_stats_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "statistics", PROT_STATS_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "statistics", PROT_STATS_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1999,7 +1994,7 @@ php_mysqlnd_prepare_read(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_PREPARE_RESPONSE *packet= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet;
|
MYSQLND_PACKET_PREPARE_RESPONSE *packet= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -2012,7 +2007,7 @@ php_mysqlnd_prepare_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_prepare_read");
|
DBG_ENTER("php_mysqlnd_prepare_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "prepare", PROT_PREPARE_RESP_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "prepare", PROT_PREPARE_RESP_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -2094,7 +2089,7 @@ php_mysqlnd_chg_user_read(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_CHG_USER_RESPONSE *packet= (MYSQLND_PACKET_CHG_USER_RESPONSE *) _packet;
|
MYSQLND_PACKET_CHG_USER_RESPONSE *packet= (MYSQLND_PACKET_CHG_USER_RESPONSE *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -2106,7 +2101,7 @@ php_mysqlnd_chg_user_read(void * _packet)
|
||||||
|
|
||||||
DBG_ENTER("php_mysqlnd_chg_user_read");
|
DBG_ENTER("php_mysqlnd_chg_user_read");
|
||||||
|
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, buf_len, "change user response", PROT_CHG_USER_RESP_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, buf_len, "change user response", PROT_CHG_USER_RESP_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -2189,7 +2184,7 @@ size_t php_mysqlnd_sha256_pk_request_write(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_SHA256_PK_REQUEST * packet = (MYSQLND_PACKET_SHA256_PK_REQUEST *) _packet;
|
MYSQLND_PACKET_SHA256_PK_REQUEST * packet = (MYSQLND_PACKET_SHA256_PK_REQUEST *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
zend_uchar buffer[MYSQLND_HEADER_SIZE + 1];
|
zend_uchar buffer[MYSQLND_HEADER_SIZE + 1];
|
||||||
|
@ -2198,7 +2193,7 @@ size_t php_mysqlnd_sha256_pk_request_write(void * _packet)
|
||||||
DBG_ENTER("php_mysqlnd_sha256_pk_request_write");
|
DBG_ENTER("php_mysqlnd_sha256_pk_request_write");
|
||||||
|
|
||||||
int1store(buffer + MYSQLND_HEADER_SIZE, '\1');
|
int1store(buffer + MYSQLND_HEADER_SIZE, '\1');
|
||||||
sent = net->data->m.send(net, vio, buffer, 1, stats, error_info);
|
sent = pfc->data->m.send(pfc, vio, buffer, 1, stats, error_info);
|
||||||
|
|
||||||
DBG_RETURN(sent);
|
DBG_RETURN(sent);
|
||||||
}
|
}
|
||||||
|
@ -2225,7 +2220,7 @@ php_mysqlnd_sha256_pk_request_response_read(void * _packet)
|
||||||
{
|
{
|
||||||
MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE * packet= (MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE *) _packet;
|
MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE * packet= (MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE *) _packet;
|
||||||
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
|
||||||
MYSQLND_PPEC * net = packet->header.net;
|
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio = packet->header.vio;
|
MYSQLND_VIO * vio = packet->header.vio;
|
||||||
MYSQLND_STATS * stats = packet->header.stats;
|
MYSQLND_STATS * stats = packet->header.stats;
|
||||||
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
|
||||||
|
@ -2236,7 +2231,7 @@ php_mysqlnd_sha256_pk_request_response_read(void * _packet)
|
||||||
DBG_ENTER("php_mysqlnd_sha256_pk_request_response_read");
|
DBG_ENTER("php_mysqlnd_sha256_pk_request_response_read");
|
||||||
|
|
||||||
/* leave space for terminating safety \0 */
|
/* leave space for terminating safety \0 */
|
||||||
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), net, vio, stats, error_info, connection_state, buf, sizeof(buf), "SHA256_PK_REQUEST_RESPONSE", PROT_SHA256_PK_REQUEST_RESPONSE_PACKET)) {
|
if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, sizeof(buf), "SHA256_PK_REQUEST_RESPONSE", PROT_SHA256_PK_REQUEST_RESPONSE_PACKET)) {
|
||||||
DBG_RETURN(FAIL);
|
DBG_RETURN(FAIL);
|
||||||
}
|
}
|
||||||
BAIL_IF_NO_MORE_DATA;
|
BAIL_IF_NO_MORE_DATA;
|
||||||
|
@ -2386,7 +2381,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECO
|
||||||
packet->header.m = &packet_methods[PROT_GREET_PACKET];
|
packet->header.m = &packet_methods[PROT_GREET_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2410,7 +2405,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECOD
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.conn = factory->conn;
|
packet->header.conn = factory->conn;
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2433,7 +2428,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_auth_response_packet)(MYSQLND_PROTOCOL_PAYL
|
||||||
packet->header.m = &packet_methods[PROT_AUTH_RESP_PACKET];
|
packet->header.m = &packet_methods[PROT_AUTH_RESP_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2456,7 +2451,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_change_auth_response_packet)(MYSQLND_PROTOC
|
||||||
packet->header.m = &packet_methods[PROT_CHANGE_AUTH_RESP_PACKET];
|
packet->header.m = &packet_methods[PROT_CHANGE_AUTH_RESP_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2479,7 +2474,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_ok_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER
|
||||||
packet->header.m = &packet_methods[PROT_OK_PACKET];
|
packet->header.m = &packet_methods[PROT_OK_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2502,7 +2497,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_eof_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODE
|
||||||
packet->header.m = &packet_methods[PROT_EOF_PACKET];
|
packet->header.m = &packet_methods[PROT_EOF_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2525,7 +2520,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_command_packet)(MYSQLND_PROTOCOL_PAYLOAD_DE
|
||||||
packet->header.m = &packet_methods[PROT_CMD_PACKET];
|
packet->header.m = &packet_methods[PROT_CMD_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2548,7 +2543,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_rset_header_packet)(MYSQLND_PROTOCOL_PAYLOA
|
||||||
packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
|
packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2571,7 +2566,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_result_field_packet)(MYSQLND_PROTOCOL_PAYLO
|
||||||
packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
|
packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2595,7 +2590,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_row_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODE
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.conn = factory->conn;
|
packet->header.conn = factory->conn;
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2618,7 +2613,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_stats_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECO
|
||||||
packet->header.m = &packet_methods[PROT_STATS_PACKET];
|
packet->header.m = &packet_methods[PROT_STATS_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2641,7 +2636,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_prepare_response_packet)(MYSQLND_PROTOCOL_P
|
||||||
packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
|
packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2664,7 +2659,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet)(MYSQLND_PROTOC
|
||||||
packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
|
packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2687,7 +2682,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_packet)(MYSQLND_PROTOCOL_
|
||||||
packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_PACKET];
|
packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2710,7 +2705,7 @@ MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_response_packet)(MYSQLND_
|
||||||
packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_RESPONSE_PACKET];
|
packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_RESPONSE_PACKET];
|
||||||
packet->header.factory = factory;
|
packet->header.factory = factory;
|
||||||
|
|
||||||
packet->header.net = factory->conn->net;
|
packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
|
||||||
packet->header.vio = factory->conn->vio;
|
packet->header.vio = factory->conn->vio;
|
||||||
packet->header.stats = factory->conn->stats;
|
packet->header.stats = factory->conn->stats;
|
||||||
packet->header.error_info = factory->conn->error_info;
|
packet->header.error_info = factory->conn->error_info;
|
||||||
|
@ -2935,516 +2930,6 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_response)(
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::connect */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, connect)(MYSQLND_PPEC * const net, const MYSQLND_CSTRING scheme, const zend_bool persistent,
|
|
||||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
|
|
||||||
{
|
|
||||||
DBG_ENTER("mysqlnd_ppec::connect");
|
|
||||||
net->packet_no = net->compressed_envelope_packet_no = 0;
|
|
||||||
DBG_RETURN(PASS);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */
|
|
||||||
#define COPY_HEADER(T,A) do { \
|
|
||||||
*(((char *)(T))) = *(((char *)(A)));\
|
|
||||||
*(((char *)(T))+1) = *(((char *)(A))+1);\
|
|
||||||
*(((char *)(T))+2) = *(((char *)(A))+2);\
|
|
||||||
*(((char *)(T))+3) = *(((char *)(A))+3); } while (0)
|
|
||||||
#define STORE_HEADER_SIZE(safe_storage, buffer) COPY_HEADER((safe_storage), (buffer))
|
|
||||||
#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::send */
|
|
||||||
/*
|
|
||||||
IMPORTANT : It's expected that buffer has place in the beginning for MYSQLND_HEADER_SIZE !!!!
|
|
||||||
This is done for performance reasons in the caller of this function.
|
|
||||||
Otherwise we will have to do send two TCP packets, or do new alloc and memcpy.
|
|
||||||
Neither are quick, thus the clients of this function are obligated to do
|
|
||||||
what they are asked for.
|
|
||||||
|
|
||||||
`count` is actually the length of the payload data. Thus :
|
|
||||||
count + MYSQLND_HEADER_SIZE = sizeof(buffer) (not the pointer but the actual buffer)
|
|
||||||
*/
|
|
||||||
static size_t
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, send)(MYSQLND_PPEC * const net, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count,
|
|
||||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
|
|
||||||
{
|
|
||||||
zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
|
|
||||||
zend_uchar * safe_storage = safe_buf;
|
|
||||||
size_t bytes_sent, packets_sent = 1;
|
|
||||||
size_t left = count;
|
|
||||||
zend_uchar * p = (zend_uchar *) buffer;
|
|
||||||
zend_uchar * compress_buf = NULL;
|
|
||||||
size_t to_be_sent;
|
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_ppec::send");
|
|
||||||
DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, net->data->compressed);
|
|
||||||
|
|
||||||
if (net->data->compressed == TRUE) {
|
|
||||||
size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE);
|
|
||||||
DBG_INF_FMT("compress_buf_size="MYSQLND_SZ_T_SPEC, comp_buf_size);
|
|
||||||
compress_buf = mnd_emalloc(comp_buf_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
to_be_sent = MIN(left, MYSQLND_MAX_PACKET_SIZE);
|
|
||||||
DBG_INF_FMT("to_be_sent=%u", to_be_sent);
|
|
||||||
DBG_INF_FMT("packets_sent=%u", packets_sent);
|
|
||||||
DBG_INF_FMT("compressed_envelope_packet_no=%u", net->compressed_envelope_packet_no);
|
|
||||||
DBG_INF_FMT("packet_no=%u", net->packet_no);
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
if (net->data->compressed == TRUE) {
|
|
||||||
/* here we need to compress the data and then write it, first comes the compressed header */
|
|
||||||
size_t tmp_complen = to_be_sent;
|
|
||||||
size_t payload_size;
|
|
||||||
zend_uchar * uncompressed_payload = p; /* should include the header */
|
|
||||||
|
|
||||||
STORE_HEADER_SIZE(safe_storage, uncompressed_payload);
|
|
||||||
int3store(uncompressed_payload, to_be_sent);
|
|
||||||
int1store(uncompressed_payload + 3, net->packet_no);
|
|
||||||
if (PASS == net->data->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen,
|
|
||||||
uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE))
|
|
||||||
{
|
|
||||||
int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent + MYSQLND_HEADER_SIZE);
|
|
||||||
payload_size = tmp_complen;
|
|
||||||
} else {
|
|
||||||
int3store(compress_buf + MYSQLND_HEADER_SIZE, 0);
|
|
||||||
memcpy(compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE);
|
|
||||||
payload_size = to_be_sent + MYSQLND_HEADER_SIZE;
|
|
||||||
}
|
|
||||||
RESTORE_HEADER_SIZE(uncompressed_payload, safe_storage);
|
|
||||||
|
|
||||||
int3store(compress_buf, payload_size);
|
|
||||||
int1store(compress_buf + 3, net->packet_no);
|
|
||||||
DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
|
|
||||||
bytes_sent = vio->data->m.network_write(vio, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, conn_stats, error_info);
|
|
||||||
net->compressed_envelope_packet_no++;
|
|
||||||
#if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
|
|
||||||
if (res == Z_OK) {
|
|
||||||
size_t decompressed_size = left + MYSQLND_HEADER_SIZE;
|
|
||||||
zend_uchar * decompressed_data = mnd_malloc(decompressed_size);
|
|
||||||
int error = net->data->m.decode(decompressed_data, decompressed_size,
|
|
||||||
compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size);
|
|
||||||
if (error == Z_OK) {
|
|
||||||
int i;
|
|
||||||
DBG_INF("success decompressing");
|
|
||||||
for (i = 0 ; i < decompressed_size; i++) {
|
|
||||||
if (i && (i % 30 == 0)) {
|
|
||||||
printf("\n\t\t");
|
|
||||||
}
|
|
||||||
printf("%.2X ", (int)*((char*)&(decompressed_data[i])));
|
|
||||||
DBG_INF_FMT("%.2X ", (int)*((char*)&(decompressed_data[i])));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_INF("error decompressing");
|
|
||||||
}
|
|
||||||
mnd_free(decompressed_data);
|
|
||||||
}
|
|
||||||
#endif /* WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY */
|
|
||||||
} else
|
|
||||||
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
|
||||||
{
|
|
||||||
DBG_INF("no compression");
|
|
||||||
STORE_HEADER_SIZE(safe_storage, p);
|
|
||||||
int3store(p, to_be_sent);
|
|
||||||
int1store(p + 3, net->packet_no);
|
|
||||||
bytes_sent = vio->data->m.network_write(vio, p, to_be_sent + MYSQLND_HEADER_SIZE, conn_stats, error_info);
|
|
||||||
RESTORE_HEADER_SIZE(p, safe_storage);
|
|
||||||
net->compressed_envelope_packet_no++;
|
|
||||||
}
|
|
||||||
net->packet_no++;
|
|
||||||
|
|
||||||
p += to_be_sent;
|
|
||||||
left -= to_be_sent;
|
|
||||||
packets_sent++;
|
|
||||||
/*
|
|
||||||
if left is 0 then there is nothing more to send, but if the last packet was exactly
|
|
||||||
with the size MYSQLND_MAX_PACKET_SIZE we need to send additional packet, which has
|
|
||||||
empty payload. Thus if left == 0 we check for to_be_sent being the max size. If it is
|
|
||||||
indeed it then loop once more, then to_be_sent will become 0, left will stay 0. Empty
|
|
||||||
packet will be sent and this loop will end.
|
|
||||||
*/
|
|
||||||
} while (bytes_sent && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
|
|
||||||
|
|
||||||
DBG_INF_FMT("packet_size="MYSQLND_SZ_T_SPEC" packet_no=%u", left, net->packet_no);
|
|
||||||
|
|
||||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats,
|
|
||||||
STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
|
|
||||||
STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE,
|
|
||||||
STAT_PACKETS_SENT, packets_sent);
|
|
||||||
|
|
||||||
if (compress_buf) {
|
|
||||||
mnd_efree(compress_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Even for zero size payload we have to send a packet */
|
|
||||||
if (!bytes_sent) {
|
|
||||||
DBG_ERR_FMT("Can't %u send bytes", count);
|
|
||||||
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
|
||||||
}
|
|
||||||
DBG_RETURN(bytes_sent);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
/* {{{ php_mysqlnd_read_buffer_is_empty */
|
|
||||||
static zend_bool
|
|
||||||
php_mysqlnd_read_buffer_is_empty(MYSQLND_READ_BUFFER * buffer)
|
|
||||||
{
|
|
||||||
return buffer->len? FALSE:TRUE;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ php_mysqlnd_read_buffer_read */
|
|
||||||
static void
|
|
||||||
php_mysqlnd_read_buffer_read(MYSQLND_READ_BUFFER * buffer, size_t count, zend_uchar * dest)
|
|
||||||
{
|
|
||||||
if (buffer->len >= count) {
|
|
||||||
memcpy(dest, buffer->data + buffer->offset, count);
|
|
||||||
buffer->offset += count;
|
|
||||||
buffer->len -= count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ php_mysqlnd_read_buffer_bytes_left */
|
|
||||||
static size_t
|
|
||||||
php_mysqlnd_read_buffer_bytes_left(MYSQLND_READ_BUFFER * buffer)
|
|
||||||
{
|
|
||||||
return buffer->len;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ php_mysqlnd_read_buffer_free */
|
|
||||||
static void
|
|
||||||
php_mysqlnd_read_buffer_free(MYSQLND_READ_BUFFER ** buffer)
|
|
||||||
{
|
|
||||||
DBG_ENTER("php_mysqlnd_read_buffer_free");
|
|
||||||
if (*buffer) {
|
|
||||||
mnd_efree((*buffer)->data);
|
|
||||||
mnd_efree(*buffer);
|
|
||||||
*buffer = NULL;
|
|
||||||
}
|
|
||||||
DBG_VOID_RETURN;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ php_mysqlnd_create_read_buffer */
|
|
||||||
static MYSQLND_READ_BUFFER *
|
|
||||||
mysqlnd_create_read_buffer(size_t count)
|
|
||||||
{
|
|
||||||
MYSQLND_READ_BUFFER * ret = mnd_emalloc(sizeof(MYSQLND_READ_BUFFER));
|
|
||||||
DBG_ENTER("mysqlnd_create_read_buffer");
|
|
||||||
ret->is_empty = php_mysqlnd_read_buffer_is_empty;
|
|
||||||
ret->read = php_mysqlnd_read_buffer_read;
|
|
||||||
ret->bytes_left = php_mysqlnd_read_buffer_bytes_left;
|
|
||||||
ret->free_buffer = php_mysqlnd_read_buffer_free;
|
|
||||||
ret->data = mnd_emalloc(count);
|
|
||||||
ret->size = ret->len = count;
|
|
||||||
ret->offset = 0;
|
|
||||||
DBG_RETURN(ret);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::read_compressed_packet_from_stream_and_fill_read_buffer */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, read_compressed_packet_from_stream_and_fill_read_buffer)
|
|
||||||
(MYSQLND_PPEC * net, MYSQLND_VIO * vio, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info)
|
|
||||||
{
|
|
||||||
size_t decompressed_size;
|
|
||||||
enum_func_status retval = PASS;
|
|
||||||
zend_uchar * compressed_data = NULL;
|
|
||||||
zend_uchar comp_header[COMPRESSED_HEADER_SIZE];
|
|
||||||
DBG_ENTER("mysqlnd_ppec::read_compressed_packet_from_stream_and_fill_read_buffer");
|
|
||||||
|
|
||||||
/* Read the compressed header */
|
|
||||||
if (FAIL == vio->data->m.network_read(vio, comp_header, COMPRESSED_HEADER_SIZE, conn_stats, error_info)) {
|
|
||||||
DBG_RETURN(FAIL);
|
|
||||||
}
|
|
||||||
decompressed_size = uint3korr(comp_header);
|
|
||||||
|
|
||||||
/* When decompressed_size is 0, then the data is not compressed, and we have wasted 3 bytes */
|
|
||||||
/* we need to decompress the data */
|
|
||||||
|
|
||||||
if (decompressed_size) {
|
|
||||||
compressed_data = mnd_emalloc(net_payload_size);
|
|
||||||
if (FAIL == vio->data->m.network_read(vio, compressed_data, net_payload_size, conn_stats, error_info)) {
|
|
||||||
retval = FAIL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
net->uncompressed_data = mysqlnd_create_read_buffer(decompressed_size);
|
|
||||||
retval = net->data->m.decode(net->uncompressed_data->data, decompressed_size, compressed_data, net_payload_size);
|
|
||||||
if (FAIL == retval) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_INF_FMT("The server decided not to compress the data. Our job is easy. Copying %u bytes", net_payload_size);
|
|
||||||
net->uncompressed_data = mysqlnd_create_read_buffer(net_payload_size);
|
|
||||||
if (FAIL == vio->data->m.network_read(vio, net->uncompressed_data->data, net_payload_size, conn_stats, error_info)) {
|
|
||||||
retval = FAIL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
if (compressed_data) {
|
|
||||||
mnd_efree(compressed_data);
|
|
||||||
}
|
|
||||||
DBG_RETURN(retval);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::decode */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len,
|
|
||||||
const zend_uchar * const compressed_data, const size_t compressed_data_len)
|
|
||||||
{
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
int error;
|
|
||||||
uLongf tmp_complen = uncompressed_data_len;
|
|
||||||
DBG_ENTER("mysqlnd_ppec::decode");
|
|
||||||
error = uncompress(uncompressed_data, &tmp_complen, compressed_data, compressed_data_len);
|
|
||||||
|
|
||||||
DBG_INF_FMT("compressed data: decomp_len=%lu compressed_size="MYSQLND_SZ_T_SPEC, tmp_complen, compressed_data_len);
|
|
||||||
if (error != Z_OK) {
|
|
||||||
DBG_INF_FMT("decompression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
|
|
||||||
}
|
|
||||||
DBG_RETURN(error == Z_OK? PASS:FAIL);
|
|
||||||
#else
|
|
||||||
DBG_ENTER("mysqlnd_ppec::decode");
|
|
||||||
DBG_RETURN(FAIL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::encode */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len,
|
|
||||||
const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len)
|
|
||||||
{
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
int error;
|
|
||||||
uLongf tmp_complen = *compress_buffer_len;
|
|
||||||
DBG_ENTER("mysqlnd_ppec::encode");
|
|
||||||
error = compress(compress_buffer, &tmp_complen, uncompressed_data, uncompressed_data_len);
|
|
||||||
|
|
||||||
if (error != Z_OK) {
|
|
||||||
DBG_INF_FMT("compression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
|
|
||||||
} else {
|
|
||||||
*compress_buffer_len = tmp_complen;
|
|
||||||
DBG_INF_FMT("compression successful. compressed size=%lu", tmp_complen);
|
|
||||||
}
|
|
||||||
|
|
||||||
DBG_RETURN(error == Z_OK? PASS:FAIL);
|
|
||||||
#else
|
|
||||||
DBG_ENTER("mysqlnd_ppec::encode");
|
|
||||||
DBG_RETURN(FAIL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::receive */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, receive)(MYSQLND_PPEC * const net, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count,
|
|
||||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
|
|
||||||
{
|
|
||||||
size_t to_read = count;
|
|
||||||
zend_uchar * p = buffer;
|
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_ppec::receive");
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
if (net->data->compressed) {
|
|
||||||
if (net->uncompressed_data) {
|
|
||||||
size_t to_read_from_buffer = MIN(net->uncompressed_data->bytes_left(net->uncompressed_data), to_read);
|
|
||||||
DBG_INF_FMT("reading "MYSQLND_SZ_T_SPEC" from uncompressed_data buffer", to_read_from_buffer);
|
|
||||||
if (to_read_from_buffer) {
|
|
||||||
net->uncompressed_data->read(net->uncompressed_data, to_read_from_buffer, (zend_uchar *) p);
|
|
||||||
p += to_read_from_buffer;
|
|
||||||
to_read -= to_read_from_buffer;
|
|
||||||
}
|
|
||||||
DBG_INF_FMT("left "MYSQLND_SZ_T_SPEC" to read", to_read);
|
|
||||||
if (TRUE == net->uncompressed_data->is_empty(net->uncompressed_data)) {
|
|
||||||
/* Everything was consumed. This should never happen here, but for security */
|
|
||||||
net->uncompressed_data->free_buffer(&net->uncompressed_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (to_read) {
|
|
||||||
zend_uchar net_header[MYSQLND_HEADER_SIZE];
|
|
||||||
size_t net_payload_size;
|
|
||||||
zend_uchar packet_no;
|
|
||||||
|
|
||||||
if (FAIL == vio->data->m.network_read(vio, net_header, MYSQLND_HEADER_SIZE, conn_stats, error_info)) {
|
|
||||||
DBG_RETURN(FAIL);
|
|
||||||
}
|
|
||||||
net_payload_size = uint3korr(net_header);
|
|
||||||
packet_no = uint1korr(net_header + 3);
|
|
||||||
if (net->compressed_envelope_packet_no != packet_no) {
|
|
||||||
DBG_ERR_FMT("Transport level: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
|
||||||
net->compressed_envelope_packet_no, packet_no, net_payload_size);
|
|
||||||
|
|
||||||
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
|
|
||||||
net->compressed_envelope_packet_no, packet_no, net_payload_size);
|
|
||||||
DBG_RETURN(FAIL);
|
|
||||||
}
|
|
||||||
net->compressed_envelope_packet_no++;
|
|
||||||
#ifdef MYSQLND_DUMP_HEADER_N_BODY
|
|
||||||
DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (zend_ulong) net_payload_size);
|
|
||||||
#endif
|
|
||||||
/* Now let's read from the wire, decompress it and fill the read buffer */
|
|
||||||
net->data->m.read_compressed_packet_from_stream_and_fill_read_buffer(net, vio, net_payload_size, conn_stats, error_info);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Now a bit of recursion - read from the read buffer,
|
|
||||||
if the data which we have just read from the wire
|
|
||||||
is not enough, then the recursive call will try to
|
|
||||||
satisfy it until it is satisfied.
|
|
||||||
*/
|
|
||||||
DBG_RETURN(net->data->m.receive(net, vio, p, to_read, conn_stats, error_info));
|
|
||||||
}
|
|
||||||
DBG_RETURN(PASS);
|
|
||||||
}
|
|
||||||
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
|
||||||
DBG_RETURN(vio->data->m.network_read(vio, p, to_read, conn_stats, error_info));
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::set_client_option */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, set_client_option)(MYSQLND_PPEC * const net, enum_mysqlnd_client_option option, const char * const value)
|
|
||||||
{
|
|
||||||
DBG_ENTER("mysqlnd_ppec::set_client_option");
|
|
||||||
DBG_INF_FMT("option=%u", option);
|
|
||||||
switch (option) {
|
|
||||||
case MYSQL_OPT_COMPRESS:
|
|
||||||
net->data->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION;
|
|
||||||
break;
|
|
||||||
case MYSQL_SERVER_PUBLIC_KEY:
|
|
||||||
{
|
|
||||||
zend_bool pers = net->persistent;
|
|
||||||
if (net->data->options.sha256_server_public_key) {
|
|
||||||
mnd_pefree(net->data->options.sha256_server_public_key, pers);
|
|
||||||
}
|
|
||||||
net->data->options.sha256_server_public_key = value? mnd_pestrdup(value, pers) : NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
DBG_RETURN(FAIL);
|
|
||||||
}
|
|
||||||
DBG_RETURN(PASS);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::free_contents */
|
|
||||||
static void
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, free_contents)(MYSQLND_PPEC * net)
|
|
||||||
{
|
|
||||||
zend_bool pers = net->persistent;
|
|
||||||
DBG_ENTER("mysqlnd_ppec::free_contents");
|
|
||||||
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
if (net->uncompressed_data) {
|
|
||||||
net->uncompressed_data->free_buffer(&net->uncompressed_data);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (net->data->options.sha256_server_public_key) {
|
|
||||||
mnd_pefree(net->data->options.sha256_server_public_key, pers);
|
|
||||||
net->data->options.sha256_server_public_key = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DBG_VOID_RETURN;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::init */
|
|
||||||
static enum_func_status
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, init)(MYSQLND_PPEC * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
|
|
||||||
{
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec::dtor */
|
|
||||||
static void
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, dtor)(MYSQLND_PPEC * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
|
|
||||||
{
|
|
||||||
DBG_ENTER("mysqlnd_ppec::dtor");
|
|
||||||
if (net) {
|
|
||||||
net->data->m.free_contents(net);
|
|
||||||
|
|
||||||
mnd_pefree(net->data, net->data->persistent);
|
|
||||||
mnd_pefree(net, net->persistent);
|
|
||||||
}
|
|
||||||
DBG_VOID_RETURN;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
MYSQLND_CLASS_METHODS_START(mysqlnd_protocol_packet_envelope_codec)
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, init),
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, dtor),
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, connect),
|
|
||||||
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, set_client_option),
|
|
||||||
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, decode),
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, encode),
|
|
||||||
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, send),
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, receive),
|
|
||||||
|
|
||||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, read_compressed_packet_from_stream_and_fill_read_buffer),
|
|
||||||
#else
|
|
||||||
NULL,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MYSQLND_METHOD(mysqlnd_ppec, free_contents),
|
|
||||||
MYSQLND_CLASS_METHODS_END;
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec_init */
|
|
||||||
PHPAPI MYSQLND_PPEC *
|
|
||||||
mysqlnd_ppec_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
|
|
||||||
{
|
|
||||||
MYSQLND_PPEC * net;
|
|
||||||
DBG_ENTER("mysqlnd_ppec_init");
|
|
||||||
net = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_net(persistent, stats, error_info);
|
|
||||||
DBG_RETURN(net);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_ppec_free */
|
|
||||||
PHPAPI void
|
|
||||||
mysqlnd_ppec_free(MYSQLND_PPEC * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
|
|
||||||
{
|
|
||||||
DBG_ENTER("mysqlnd_ppec_free");
|
|
||||||
if (net) {
|
|
||||||
net->data->m.dtor(net, stats, error_info);
|
|
||||||
}
|
|
||||||
DBG_VOID_RETURN;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MYSQLND_CLASS_METHODS_START(mysqlnd_protocol_payload_decoder_factory)
|
MYSQLND_CLASS_METHODS_START(mysqlnd_protocol_payload_decoder_factory)
|
||||||
MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet),
|
MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet),
|
||||||
MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet),
|
MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet),
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
| Georg Richter <georg@mysql.com> |
|
| Georg Richter <georg@mysql.com> |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef MYSQLND_WIREPROTOCOL_H
|
#ifndef MYSQLND_WIREPROTOCOL_H
|
||||||
#define MYSQLND_WIREPROTOCOL_H
|
#define MYSQLND_WIREPROTOCOL_H
|
||||||
|
|
||||||
|
@ -63,7 +60,7 @@ typedef struct st_mysqlnd_packet_header {
|
||||||
mysqlnd_packet_methods *m;
|
mysqlnd_packet_methods *m;
|
||||||
|
|
||||||
MYSQLND_CONN_DATA * conn;
|
MYSQLND_CONN_DATA * conn;
|
||||||
MYSQLND_PPEC * net;
|
MYSQLND_PFC * protocol_frame_codec;
|
||||||
MYSQLND_VIO * vio;
|
MYSQLND_VIO * vio;
|
||||||
MYSQLND_ERROR_INFO * error_info;
|
MYSQLND_ERROR_INFO * error_info;
|
||||||
MYSQLND_STATS * stats;
|
MYSQLND_STATS * stats;
|
||||||
|
@ -324,11 +321,6 @@ enum_func_status php_mysqlnd_rowp_read_text_protocol_c(MYSQLND_MEMORY_POOL_CHUNK
|
||||||
PHPAPI MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * mysqlnd_protocol_payload_decoder_factory_init(MYSQLND_CONN_DATA * conn, zend_bool persistent);
|
PHPAPI MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * mysqlnd_protocol_payload_decoder_factory_init(MYSQLND_CONN_DATA * conn, zend_bool persistent);
|
||||||
PHPAPI void mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory);
|
PHPAPI void mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory);
|
||||||
|
|
||||||
|
|
||||||
PHPAPI MYSQLND_PPEC * mysqlnd_ppec_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
|
||||||
PHPAPI void mysqlnd_ppec_free(MYSQLND_PPEC * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MYSQLND_WIREPROTOCOL_H */
|
#endif /* MYSQLND_WIREPROTOCOL_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue