Skip to content

Commit a530ecf

Browse files
committed
MNDR:
- better name for MYSQLND_PPEC - MYSQLND_PFC (protocol frame codec)
1 parent 654d1a7 commit a530ecf

18 files changed

+725
-693
lines changed

ext/mysqlnd/config.w32

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ if (PHP_MYSQLND != "no") {
1616
"mysqlnd_ext_plugin.c " +
1717
"mysqlnd_loaddata.c " +
1818
"mysqlnd_reverse_api.c " +
19-
"mysqlnd_vio.c " +
2019
"mysqlnd_plugin.c " +
20+
"mysqlnd_protocol_frame_codec.c " +
2121
"mysqlnd_ps.c " +
2222
"mysqlnd_ps_codec.c " +
2323
"mysqlnd_result.c " +
2424
"mysqlnd_result_meta.c " +
2525
"mysqlnd_statistics.c " +
26+
"mysqlnd_vio.c " +
2627
"mysqlnd_wireprotocol.c " +
2728
"php_mysqlnd.c ";
2829
EXTENSION("mysqlnd", mysqlnd_source, false, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");

ext/mysqlnd/config9.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dnl If some extension uses mysqlnd it will get compiled in PHP core
1919
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
2020
mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
2121
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
22-
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_vio.c \
22+
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_vio.c mysqlnd_protocol_frame_codec.c \
2323
mysqlnd_statistics.c mysqlnd_driver.c mysqlnd_ext_plugin.c mysqlnd_auth.c \
2424
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
2525
mysqlnd_block_alloc.c mysqlnd_plugin.c php_mysqlnd.c"

ext/mysqlnd/mysqlnd.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21-
/* $Id$ */
2221
#include "php.h"
2322
#include "mysqlnd.h"
2423
#include "mysqlnd_vio.h"
24+
#include "mysqlnd_protocol_frame_codec.h"
2525
#include "mysqlnd_wireprotocol.h"
2626
#include "mysqlnd_priv.h"
2727
#include "mysqlnd_result.h"
@@ -267,8 +267,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn)
267267
conn->current_result = NULL;
268268
}
269269

270-
if (conn->net) {
271-
conn->net->data->m.free_contents(conn->net);
270+
if (conn->protocol_frame_codec) {
271+
conn->protocol_frame_codec->data->m.free_contents(conn->protocol_frame_codec);
272272
}
273273

274274
if (conn->vio) {
@@ -341,9 +341,9 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, dtor)(MYSQLND_CONN_DATA * conn)
341341
conn->m->free_contents(conn);
342342
conn->m->free_options(conn);
343343

344-
if (conn->net) {
345-
mysqlnd_ppec_free(conn->net, conn->stats, conn->error_info);
346-
conn->net = NULL;
344+
if (conn->protocol_frame_codec) {
345+
mysqlnd_pfc_free(conn->protocol_frame_codec, conn->stats, conn->error_info);
346+
conn->protocol_frame_codec = NULL;
347347
}
348348

349349
if (conn->vio) {
@@ -540,7 +540,7 @@ mysqlnd_run_authentication(
540540
scrambled_data =
541541
auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
542542
plugin_data, plugin_data_len, session_options,
543-
&conn->net->data->options, mysql_flags);
543+
&conn->protocol_frame_codec->data->options, mysql_flags);
544544
if (conn->error_info->error_no) {
545545
goto end;
546546
}
@@ -664,7 +664,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, execute_init_commands)(MYSQLND_CONN_DATA * con
664664
static unsigned int
665665
MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA * conn, unsigned int mysql_flags)
666666
{
667-
MYSQLND_PPEC * net = conn->net;
667+
MYSQLND_PFC * pfc = conn->protocol_frame_codec;
668668
MYSQLND_VIO * vio = conn->vio;
669669

670670
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 *
682682
mysql_flags &= ~CLIENT_COMPRESS;
683683
}
684684
#else
685-
if (net && net->data->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) {
685+
if (pfc && pfc->data->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) {
686686
mysql_flags |= CLIENT_COMPRESS;
687687
}
688688
#endif
@@ -713,12 +713,12 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn,
713713
const unsigned int mysql_flags)
714714
{
715715
enum_func_status ret = FAIL;
716-
size_t client_flags = mysql_flags;
717716
DBG_ENTER("mysqlnd_conn_data::connect_handshake");
718717

719-
if (FAIL == conn->vio->data->m.connect(conn->vio, *scheme, conn->persistent, conn->stats, conn->error_info)) {
720-
DBG_RETURN(FAIL);
721-
} else if (PASS == conn->net->data->m.connect(conn->net, *scheme, conn->persistent, conn->stats, conn->error_info)) {
718+
if (PASS == conn->vio->data->m.connect(conn->vio, *scheme, conn->persistent, conn->stats, conn->error_info) &&
719+
PASS == conn->protocol_frame_codec->data->m.reset(conn->protocol_frame_codec, conn->stats, conn->error_info))
720+
{
721+
size_t client_flags = mysql_flags;
722722
struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_HANDSHAKE, conn, username, password, database, client_flags);
723723
if (command) {
724724
ret = command->run(command);
@@ -784,7 +784,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
784784
zend_bool reconnect = FALSE;
785785
zend_bool saved_compression = FALSE;
786786
zend_bool local_tx_started = FALSE;
787-
MYSQLND_PPEC * net = conn->net;
787+
MYSQLND_PFC * pfc = conn->protocol_frame_codec;
788788
MYSQLND_STRING transport = { NULL, 0 };
789789

790790
DBG_ENTER("mysqlnd_conn_data::connect");
@@ -813,17 +813,17 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
813813

814814
conn->m->free_contents(conn);
815815
/* Now reconnect using the same handle */
816-
if (net->data->compressed) {
816+
if (pfc->data->compressed) {
817817
/*
818-
we need to save the state. As we will re-connect, net->compressed should be off, or
818+
we need to save the state. As we will re-connect, pfc->compressed should be off, or
819819
we will look for a compression header as part of the greet message, but there will
820820
be none.
821821
*/
822822
saved_compression = TRUE;
823-
net->data->compressed = FALSE;
823+
pfc->data->compressed = FALSE;
824824
}
825-
if (net->data->ssl) {
826-
net->data->ssl = FALSE;
825+
if (pfc->data->ssl) {
826+
pfc->data->ssl = FALSE;
827827
}
828828
} else {
829829
unsigned int max_allowed_size = MYSQLND_ASSEMBLED_PACKET_MAX_SIZE;
@@ -867,14 +867,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
867867
SET_CONNECTION_STATE(&conn->state, CONN_READY);
868868

869869
if (saved_compression) {
870-
net->data->compressed = TRUE;
870+
pfc->data->compressed = TRUE;
871871
}
872872
/*
873873
If a connect on a existing handle is performed and mysql_flags is
874874
passed which doesn't CLIENT_COMPRESS, then we need to overwrite the value
875875
which we set based on saved_compression.
876876
*/
877-
net->data->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE;
877+
pfc->data->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE;
878878

879879

880880
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
14351435
{
14361436
const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), ssl_set);
14371437
enum_func_status ret = FAIL;
1438-
MYSQLND_VIO * net = conn->vio;
1438+
MYSQLND_VIO * vio = conn->vio;
14391439
DBG_ENTER("mysqlnd_conn_data::ssl_set");
14401440

14411441
if (PASS == conn->m->local_tx_start(conn, this_func)) {
1442-
ret = (PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_KEY, key) &&
1443-
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CERT, cert) &&
1444-
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CA, ca) &&
1445-
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CAPATH, capath) &&
1446-
PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CIPHER, cipher)) ? PASS : FAIL;
1442+
ret = (PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_KEY, key) &&
1443+
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CERT, cert) &&
1444+
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CA, ca) &&
1445+
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CAPATH, capath) &&
1446+
PASS == vio->data->m.set_client_option(vio, MYSQLND_OPT_SSL_CIPHER, cipher)) ? PASS : FAIL;
14471447

14481448
conn->m->local_tx_end(conn, this_func, ret);
14491449
}
@@ -1688,12 +1688,10 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn)
16881688
enum_func_status ret = PASS;
16891689
MYSQLND_VIO * vio = conn->vio;
16901690
php_stream * net_stream = vio->data->m.get_stream(vio);
1691-
enum mysqlnd_connection_state state;
1691+
enum mysqlnd_connection_state state = GET_CONNECTION_STATE(&conn->state);
16921692

16931693
DBG_ENTER("mysqlnd_send_close");
1694-
DBG_INF_FMT("conn=%llu net->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->abstract:NULL);
1695-
1696-
state = GET_CONNECTION_STATE(&conn->state);
1694+
DBG_INF_FMT("conn=%llu vio->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->abstract:NULL);
16971695
DBG_INF_FMT("state=%u", state);
16981696

16991697
if (state >= CONN_READY) {
@@ -2116,7 +2114,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c
21162114
ret = conn->vio->data->m.set_client_option(conn->vio, option, value);
21172115
break;
21182116
case MYSQL_SERVER_PUBLIC_KEY:
2119-
ret = conn->net->data->m.set_client_option(conn->net, option, value);
2117+
ret = conn->protocol_frame_codec->data->m.set_client_option(conn->protocol_frame_codec, option, value);
21202118
break;
21212119
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
21222120
case MYSQLND_OPT_INT_AND_FLOAT_NATIVE:

ext/mysqlnd/mysqlnd_auth.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21-
/* $Id: mysqlnd.c 307377 2011-01-11 13:02:57Z andrey $ */
2221
#include "php.h"
2322
#include "mysqlnd.h"
2423
#include "mysqlnd_structs.h"
@@ -360,7 +359,7 @@ mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
360359
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
361360
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
362361
const MYSQLND_SESSION_OPTIONS * const session_options,
363-
const MYSQLND_PPEC_OPTIONS * const ppec_options,
362+
const MYSQLND_PFC_OPTIONS * const ppec_options,
364363
zend_ulong mysql_flags
365364
)
366365
{
@@ -420,7 +419,7 @@ mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
420419
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
421420
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
422421
const MYSQLND_SESSION_OPTIONS * const session_options,
423-
const MYSQLND_PPEC_OPTIONS * const ppec_options,
422+
const MYSQLND_PFC_OPTIONS * const ppec_options,
424423
zend_ulong mysql_flags
425424
)
426425
{
@@ -481,7 +480,7 @@ mysqlnd_xor_string(char * dst, const size_t dst_len, const char * xor_str, const
481480
static RSA *
482481
mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
483482
const MYSQLND_SESSION_OPTIONS * const session_options,
484-
const MYSQLND_PPEC_OPTIONS * const io_options
483+
const MYSQLND_PFC_OPTIONS * const io_options
485484
)
486485
{
487486
RSA * ret = NULL;
@@ -570,7 +569,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
570569
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
571570
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
572571
const MYSQLND_SESSION_OPTIONS * const session_options,
573-
const MYSQLND_PPEC_OPTIONS * const ppec_options,
572+
const MYSQLND_PFC_OPTIONS * const ppec_options,
574573
zend_ulong mysql_flags
575574
)
576575
{
@@ -580,7 +579,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
580579
DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
581580

582581

583-
if (conn->net->data->ssl) {
582+
if (conn->protocol_frame_codec->data->ssl) {
584583
DBG_INF("simple clear text under SSL");
585584
/* clear text under SSL */
586585
*auth_data_len = passwd_len;

ext/mysqlnd/mysqlnd_driver.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21-
/* $Id: mysqlnd.c 317989 2011-10-10 20:49:28Z andrey $ */
2221
#include "php.h"
2322
#include "mysqlnd.h"
2423
#include "mysqlnd_vio.h"
24+
#include "mysqlnd_protocol_frame_codec.h"
2525
#include "mysqlnd_wireprotocol.h"
2626
#include "mysqlnd_priv.h"
2727
#include "mysqlnd_result.h"
@@ -140,12 +140,12 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(struct st_mysqlnd_object_
140140

141141
mysqlnd_stats_init(&data->stats, STAT_LAST, persistent);
142142

143-
data->net = mysqlnd_ppec_init(persistent, data->stats, data->error_info);
143+
data->protocol_frame_codec = mysqlnd_pfc_init(persistent, data->stats, data->error_info);
144144
data->vio = mysqlnd_vio_init(persistent, data->stats, data->error_info);
145145
data->payload_decoder_factory = mysqlnd_protocol_payload_decoder_factory_init(data, persistent);
146146
data->command_factory = mysqlnd_command_factory_get();
147147

148-
if (!data->net || !data->payload_decoder_factory) {
148+
if (!data->protocol_frame_codec || !data->vio || !data->payload_decoder_factory || !data->command_factory) {
149149
new_object->m->dtor(new_object);
150150
DBG_RETURN(NULL);
151151
}
@@ -244,20 +244,20 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
244244

245245

246246
/* {{{ mysqlnd_object_factory::get_ppec */
247-
static MYSQLND_PPEC *
247+
static MYSQLND_PFC *
248248
MYSQLND_METHOD(mysqlnd_object_factory, get_ppec)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
249249
{
250-
size_t ppec_alloc_size = sizeof(MYSQLND_PPEC) + mysqlnd_plugin_count() * sizeof(void *);
251-
size_t ppec_data_alloc_size = sizeof(MYSQLND_PPEC_DATA) + mysqlnd_plugin_count() * sizeof(void *);
252-
MYSQLND_PPEC * ppec = mnd_pecalloc(1, ppec_alloc_size, persistent);
253-
MYSQLND_PPEC_DATA * ppec_data = mnd_pecalloc(1, ppec_data_alloc_size, persistent);
250+
size_t ppec_alloc_size = sizeof(MYSQLND_PFC) + mysqlnd_plugin_count() * sizeof(void *);
251+
size_t ppec_data_alloc_size = sizeof(MYSQLND_PFC_DATA) + mysqlnd_plugin_count() * sizeof(void *);
252+
MYSQLND_PFC * ppec = mnd_pecalloc(1, ppec_alloc_size, persistent);
253+
MYSQLND_PFC_DATA * ppec_data = mnd_pecalloc(1, ppec_data_alloc_size, persistent);
254254

255255
DBG_ENTER("mysqlnd_object_factory::get_ppec");
256256
DBG_INF_FMT("persistent=%u", persistent);
257257
if (ppec && ppec_data) {
258258
ppec->data = ppec_data;
259259
ppec->persistent = ppec->data->persistent = persistent;
260-
ppec->data->m = *mysqlnd_ppec_get_methods();
260+
ppec->data->m = *mysqlnd_pfc_get_methods();
261261

262262
if (PASS != ppec->data->m.init(ppec, stats, error_info)) {
263263
ppec->data->m.dtor(ppec, stats, error_info);

ext/mysqlnd/mysqlnd_enum_n_def.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21-
/* $Id$ */
2221
#ifndef MYSQLND_ENUM_N_DEF_H
2322
#define MYSQLND_ENUM_N_DEF_H
2423

ext/mysqlnd/mysqlnd_ext_plugin.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
| Ulf Wendel <uwendel@mysql.com> |
1717
+----------------------------------------------------------------------+
1818
*/
19-
20-
/* $Id: mysqlnd.c 318221 2011-10-19 15:04:12Z andrey $ */
2119
#include "php.h"
2220
#include "mysqlnd.h"
2321
#include "mysqlnd_priv.h"
@@ -142,14 +140,14 @@ mysqlnd_plugin__get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plu
142140

143141
/* {{{ mysqlnd_plugin__get_plugin_ppec_data */
144142
static void **
145-
mysqlnd_plugin__get_plugin_ppec_data(const MYSQLND_PPEC * ppec, unsigned int plugin_id)
143+
mysqlnd_plugin__get_plugin_ppec_data(const MYSQLND_PFC * ppec, unsigned int plugin_id)
146144
{
147145
DBG_ENTER("mysqlnd_plugin__get_plugin_ppec_data");
148146
DBG_INF_FMT("plugin_id=%u", plugin_id);
149147
if (!ppec || plugin_id >= mysqlnd_plugin_count()) {
150148
return NULL;
151149
}
152-
DBG_RETURN((void *)((char *)ppec + sizeof(MYSQLND_PPEC) + plugin_id * sizeof(void *)));
150+
DBG_RETURN((void *)((char *)ppec + sizeof(MYSQLND_PFC) + plugin_id * sizeof(void *)));
153151
}
154152
/* }}} */
155153

@@ -324,18 +322,18 @@ _mysqlnd_protocol_payload_decoder_factory_set_methods(MYSQLND_CLASS_METHODS_TYPE
324322
/* }}} */
325323

326324

327-
/* {{{ _mysqlnd_ppec_get_methods */
325+
/* {{{ _mysqlnd_pfc_get_methods */
328326
static MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) *
329-
_mysqlnd_ppec_get_methods()
327+
_mysqlnd_pfc_get_methods()
330328
{
331329
return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol_packet_envelope_codec);
332330
}
333331
/* }}} */
334332

335333

336-
/* {{{ _mysqlnd_ppec_set_methods */
334+
/* {{{ _mysqlnd_pfc_set_methods */
337335
static void
338-
_mysqlnd_ppec_set_methods(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) * methods)
336+
_mysqlnd_pfc_set_methods(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_envelope_codec) * methods)
339337
{
340338
MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_protocol_packet_envelope_codec) = *methods;
341339
}
@@ -431,8 +429,8 @@ struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters =
431429
_mysqlnd_protocol_payload_decoder_factory_set_methods,
432430
},
433431
{
434-
_mysqlnd_ppec_get_methods,
435-
_mysqlnd_ppec_set_methods,
432+
_mysqlnd_pfc_get_methods,
433+
_mysqlnd_pfc_set_methods,
436434
},
437435
{
438436
_mysqlnd_vio_get_methods,

0 commit comments

Comments
 (0)