mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
MNDR:
- move handling of commands to the command itself
This commit is contained in:
parent
7e6f9a84cb
commit
75a1fcc724
@ -1644,12 +1644,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, ping)(MYSQLND_CONN_DATA * const conn)
|
|||||||
ret = command->run(command);
|
ret = command->run(command);
|
||||||
command->free_command(command);
|
command->free_command(command);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
The server sends 0 but libmysql doesn't read it and has established
|
|
||||||
a protocol of giving back -1. Thus we have to follow it :(
|
|
||||||
*/
|
|
||||||
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
|
|
||||||
|
|
||||||
conn->m->local_tx_end(conn, this_func, ret);
|
conn->m->local_tx_end(conn, this_func, ret);
|
||||||
}
|
}
|
||||||
DBG_INF_FMT("ret=%u", ret);
|
DBG_INF_FMT("ret=%u", ret);
|
||||||
@ -1664,36 +1658,16 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_stri
|
|||||||
{
|
{
|
||||||
const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), get_server_statistics);
|
const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), get_server_statistics);
|
||||||
enum_func_status ret = FAIL;
|
enum_func_status ret = FAIL;
|
||||||
MYSQLND_PACKET_STATS * stats_header;
|
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_conn_data::statistic");
|
DBG_ENTER("mysqlnd_conn_data::statistic");
|
||||||
DBG_INF_FMT("conn=%llu", conn->thread_id);
|
DBG_INF_FMT("conn=%llu", conn->thread_id);
|
||||||
|
|
||||||
if (PASS == conn->m->local_tx_start(conn, this_func)) {
|
if (PASS == conn->m->local_tx_start(conn, this_func)) {
|
||||||
do {
|
struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STATISTICS, conn, message);
|
||||||
struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STATISTICS, conn);
|
if (command) {
|
||||||
if (command) {
|
ret = command->run(command);
|
||||||
ret = command->run(command);
|
command->free_command(command);
|
||||||
command->free_command(command);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (FAIL == ret) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
stats_header = conn->payload_decoder_factory->m.get_stats_packet(conn->payload_decoder_factory, FALSE);
|
|
||||||
if (!stats_header) {
|
|
||||||
SET_OOM_ERROR(conn->error_info);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PASS == (ret = PACKET_READ(stats_header))) {
|
|
||||||
/* will be freed by Zend, thus don't use the mnd_ allocator */
|
|
||||||
*message = zend_string_init(stats_header->message.s, stats_header->message.l, 0);
|
|
||||||
DBG_INF(ZSTR_VAL(*message));
|
|
||||||
}
|
|
||||||
PACKET_FREE(stats_header);
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
conn->m->local_tx_end(conn, this_func, ret);
|
conn->m->local_tx_end(conn, this_func, ret);
|
||||||
}
|
}
|
||||||
DBG_RETURN(ret);
|
DBG_RETURN(ret);
|
||||||
@ -1719,16 +1693,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, kill)(MYSQLND_CONN_DATA * conn, unsigned int p
|
|||||||
if (command) {
|
if (command) {
|
||||||
ret = command->run(command);
|
ret = command->run(command);
|
||||||
command->free_command(command);
|
command->free_command(command);
|
||||||
if (read_response) {
|
|
||||||
/*
|
|
||||||
The server sends 0 but libmysql doesn't read it and has established
|
|
||||||
a protocol of giving back -1. Thus we have to follow it :(
|
|
||||||
*/
|
|
||||||
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
|
|
||||||
} else if (PASS == ret) {
|
|
||||||
SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
|
|
||||||
conn->m->send_close(conn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
conn->m->local_tx_end(conn, this_func, ret);
|
conn->m->local_tx_end(conn, this_func, ret);
|
||||||
}
|
}
|
||||||
@ -1792,6 +1756,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, refresh)(MYSQLND_CONN_DATA * const conn, uint8
|
|||||||
ret = command->run(command);
|
ret = command->run(command);
|
||||||
command->free_command(command);
|
command->free_command(command);
|
||||||
}
|
}
|
||||||
|
conn->m->local_tx_end(conn, this_func, ret);
|
||||||
}
|
}
|
||||||
DBG_RETURN(ret);
|
DBG_RETURN(ret);
|
||||||
}
|
}
|
||||||
|
@ -3085,6 +3085,11 @@ mysqlnd_com_ping_run(void *cmd)
|
|||||||
ret = send_command_handle_response(PROT_OK_PACKET, TRUE, COM_PING, TRUE,
|
ret = send_command_handle_response(PROT_OK_PACKET, TRUE, COM_PING, TRUE,
|
||||||
conn->error_info, conn->upsert_status, conn->payload_decoder_factory, &conn->last_message, conn->persistent);
|
conn->error_info, conn->upsert_status, conn->payload_decoder_factory, &conn->last_message, conn->persistent);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
The server sends 0 but libmysql doesn't read it and has established
|
||||||
|
a protocol of giving back -1. Thus we have to follow it :(
|
||||||
|
*/
|
||||||
|
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
|
||||||
|
|
||||||
DBG_RETURN(ret);
|
DBG_RETURN(ret);
|
||||||
}
|
}
|
||||||
@ -3184,13 +3189,25 @@ mysqlnd_com_field_list_create_command(va_list args)
|
|||||||
|
|
||||||
|
|
||||||
/************************** COM_STATISTICS ******************************************/
|
/************************** COM_STATISTICS ******************************************/
|
||||||
|
struct st_mysqlnd_protocol_com_statistics_command
|
||||||
|
{
|
||||||
|
struct st_mysqlnd_protocol_command parent;
|
||||||
|
struct st_mysqlnd_com_statistics_context
|
||||||
|
{
|
||||||
|
MYSQLND_CONN_DATA * conn;
|
||||||
|
zend_string ** message;
|
||||||
|
} context;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* {{{ mysqlnd_com_statistics_run */
|
/* {{{ mysqlnd_com_statistics_run */
|
||||||
static enum_func_status
|
static enum_func_status
|
||||||
mysqlnd_com_statistics_run(void *cmd)
|
mysqlnd_com_statistics_run(void *cmd)
|
||||||
{
|
{
|
||||||
struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
|
struct st_mysqlnd_protocol_com_statistics_command * command = (struct st_mysqlnd_protocol_com_statistics_command *) cmd;
|
||||||
enum_func_status ret = FAIL;
|
enum_func_status ret = FAIL;
|
||||||
MYSQLND_CONN_DATA * conn = command->context.conn;
|
MYSQLND_CONN_DATA * conn = command->context.conn;
|
||||||
|
zend_string **message = command->context.message;
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_com_statistics_run");
|
DBG_ENTER("mysqlnd_com_statistics_run");
|
||||||
|
|
||||||
@ -3203,6 +3220,20 @@ mysqlnd_com_statistics_run(void *cmd)
|
|||||||
conn->m->send_close,
|
conn->m->send_close,
|
||||||
conn);
|
conn);
|
||||||
|
|
||||||
|
if (PASS == ret) {
|
||||||
|
MYSQLND_PACKET_STATS * stats_header = conn->payload_decoder_factory->m.get_stats_packet(conn->payload_decoder_factory, FALSE);
|
||||||
|
if (!stats_header) {
|
||||||
|
SET_OOM_ERROR(conn->error_info);
|
||||||
|
} else {
|
||||||
|
if (PASS == (ret = PACKET_READ(stats_header))) {
|
||||||
|
/* will be freed by Zend, thus don't use the mnd_ allocator */
|
||||||
|
*message = zend_string_init(stats_header->message.s, stats_header->message.l, 0);
|
||||||
|
DBG_INF(ZSTR_VAL(*message));
|
||||||
|
}
|
||||||
|
PACKET_FREE(stats_header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DBG_RETURN(ret);
|
DBG_RETURN(ret);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
@ -3212,13 +3243,14 @@ mysqlnd_com_statistics_run(void *cmd)
|
|||||||
static struct st_mysqlnd_protocol_command *
|
static struct st_mysqlnd_protocol_command *
|
||||||
mysqlnd_com_statistics_create_command(va_list args)
|
mysqlnd_com_statistics_create_command(va_list args)
|
||||||
{
|
{
|
||||||
struct st_mysqlnd_protocol_no_params_command * command;
|
struct st_mysqlnd_protocol_com_statistics_command * command;
|
||||||
DBG_ENTER("mysqlnd_com_statistics_create_command");
|
DBG_ENTER("mysqlnd_com_statistics_create_command");
|
||||||
command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
|
command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_statistics_command));
|
||||||
if (command) {
|
if (command) {
|
||||||
command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
|
command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
|
||||||
command->parent.free_command = mysqlnd_com_no_params_free_command;
|
command->context.message = va_arg(args, zend_string **);
|
||||||
|
|
||||||
|
command->parent.free_command = mysqlnd_com_no_params_free_command;
|
||||||
command->parent.run = mysqlnd_com_statistics_run;
|
command->parent.run = mysqlnd_com_statistics_run;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3247,6 +3279,7 @@ mysqlnd_com_process_kill_run(void *cmd)
|
|||||||
zend_uchar buff[4];
|
zend_uchar buff[4];
|
||||||
enum_func_status ret = FAIL;
|
enum_func_status ret = FAIL;
|
||||||
MYSQLND_CONN_DATA * conn = command->context.conn;
|
MYSQLND_CONN_DATA * conn = command->context.conn;
|
||||||
|
zend_bool read_response = command->context.read_response;
|
||||||
|
|
||||||
DBG_ENTER("mysqlnd_com_process_kill_run");
|
DBG_ENTER("mysqlnd_com_process_kill_run");
|
||||||
int4store(buff, command->context.process_id);
|
int4store(buff, command->context.process_id);
|
||||||
@ -3259,11 +3292,22 @@ mysqlnd_com_process_kill_run(void *cmd)
|
|||||||
conn->payload_decoder_factory,
|
conn->payload_decoder_factory,
|
||||||
conn->m->send_close,
|
conn->m->send_close,
|
||||||
conn);
|
conn);
|
||||||
if (PASS == ret && command->context.read_response) {
|
if (PASS == ret && read_response) {
|
||||||
ret = send_command_handle_response(PROT_OK_PACKET, FALSE, COM_PROCESS_KILL, TRUE,
|
ret = send_command_handle_response(PROT_OK_PACKET, FALSE, COM_PROCESS_KILL, TRUE,
|
||||||
conn->error_info, conn->upsert_status, conn->payload_decoder_factory, &conn->last_message, conn->persistent);
|
conn->error_info, conn->upsert_status, conn->payload_decoder_factory, &conn->last_message, conn->persistent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (read_response) {
|
||||||
|
/*
|
||||||
|
The server sends 0 but libmysql doesn't read it and has established
|
||||||
|
a protocol of giving back -1. Thus we have to follow it :(
|
||||||
|
*/
|
||||||
|
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
|
||||||
|
} else if (PASS == ret) {
|
||||||
|
SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
|
||||||
|
conn->m->send_close(conn);
|
||||||
|
}
|
||||||
|
|
||||||
DBG_RETURN(ret);
|
DBG_RETURN(ret);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
Loading…
Reference in New Issue
Block a user