com php-src: Move cleanup code to a separate function and export it. Export also other functions that can be of use for plugins:
ext/mysqlnd/mysqlnd_connection.c ext/mysqlnd/mysqlnd_co nnection.h ext/mysqlnd/mysqlnd_structs.h
| From: | Andrey Hristov | Date: | Fri, 15 Jan 2016 02:08:02 +0000 |
| Subject: | com php-src: Move cleanup code to a separate function and export it. Export also other functions that can be of use for plugins: ext/mysqlnd/mysqlnd_connection.c ext/mysqlnd/mysqlnd_co nnection.h ext/mysqlnd/mysqlnd_structs.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90648@lists.php.net to get a copy of this message | ||
Commit: 7e9a6f72024e99ab3e85205d208225eda4801d2b
Author: Andrey Hristov <andrey@php.net> Thu, 14 Jan 2016 22:36:44 +0100
Parents: 07849e80069ad24476b2ce0df44b692f05aa3727
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7e9a6f72024e99ab3e85205d208225eda4801d2b
Log:
Move cleanup code to a separate function and export it. Export also
other functions that can be of use for plugins
Changed paths:
M ext/mysqlnd/mysqlnd_connection.c
M ext/mysqlnd/mysqlnd_connection.h
M ext/mysqlnd/mysqlnd_structs.h
Diff:
diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c
index 2cefe75..6f350cf 100644
--- a/ext/mysqlnd/mysqlnd_connection.c
+++ b/ext/mysqlnd/mysqlnd_connection.c
@@ -40,7 +40,7 @@ PHPAPI const char * const mysqlnd_server_gone = "MySQL server has gone
away";
PHPAPI const char * const mysqlnd_out_of_sync = "Commands out of sync; you can't run this
command now";
PHPAPI const char * const mysqlnd_out_of_memory = "Out of memory";
-PHPAPI MYSQLND_STATS *mysqlnd_global_stats = NULL;
+PHPAPI MYSQLND_STATS * mysqlnd_global_stats = NULL;
/* {{{ mysqlnd_upsert_status::reset */
@@ -152,8 +152,8 @@ MYSQLND_CLASS_METHODS_END;
/* {{{ mysqlnd_error_info_init */
-enum_func_status
-mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent)
+PHPAPI enum_func_status
+mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persistent)
{
DBG_ENTER("mysqlnd_error_info_init");
info->m = mysqlnd_error_info_get_methods();
@@ -163,12 +163,28 @@ mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent)
if (info->error_list) {
zend_llist_init(info->error_list, sizeof(MYSQLND_ERROR_LIST_ELEMENT), (llist_dtor_func_t)
mysqlnd_error_list_pdtor, persistent);
}
-
+ info->persistent = persistent;
DBG_RETURN(info->error_list? PASS:FAIL);
}
/* }}} */
+/* {{{ mysqlnd_error_info_free_contents */
+PHPAPI void
+mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info)
+{
+ DBG_ENTER("mysqlnd_error_info_free_contents");
+ info->m->reset(info);
+ if (info->error_list) {
+ mnd_pefree(info->error_list, info->persistent);
+ info->error_list = NULL;
+ }
+
+ DBG_VOID_RETURN;
+}
+/* }}} */
+
+
/* {{{ mysqlnd_connection_state::get */
@@ -200,10 +216,8 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_connection_state)
MYSQLND_CLASS_METHODS_END;
-
-
/* {{{ mysqlnd_upsert_status_init */
-void
+PHPAPI void
mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state)
{
DBG_ENTER("mysqlnd_error_info_init");
@@ -214,6 +228,7 @@ mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state)
/* }}} */
+
/* {{{ mysqlnd_conn_data::free_options */
static void
MYSQLND_METHOD(mysqlnd_conn_data, free_options)(MYSQLND_CONN_DATA * conn)
@@ -318,11 +333,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn)
mnd_pefree(conn->last_message.s, pers);
conn->last_message.s = NULL;
}
- if (conn->error_info->error_list) {
- zend_llist_clean(conn->error_info->error_list);
- mnd_pefree(conn->error_info->error_list, pers);
- conn->error_info->error_list = NULL;
- }
+
conn->charset = NULL;
conn->greet_charset = NULL;
@@ -341,6 +352,11 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, dtor)(MYSQLND_CONN_DATA * conn)
conn->m->free_contents(conn);
conn->m->free_options(conn);
+ if (conn->error_info) {
+ mysqlnd_error_info_free_contents(conn->error_info);
+ conn->error_info = NULL;
+ }
+
if (conn->protocol_frame_codec) {
mysqlnd_pfc_free(conn->protocol_frame_codec, conn->stats, conn->error_info);
conn->protocol_frame_codec = NULL;
diff --git a/ext/mysqlnd/mysqlnd_connection.h b/ext/mysqlnd/mysqlnd_connection.h
index cdffe59..0668d09 100644
--- a/ext/mysqlnd/mysqlnd_connection.h
+++ b/ext/mysqlnd/mysqlnd_connection.h
@@ -67,12 +67,13 @@ void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status);
}
-enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent);
+PHPAPI enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool
persistent);
+PHPAPI void mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info);
#define GET_CONNECTION_STATE(state_struct) (state_struct)->m->get((state_struct))
#define SET_CONNECTION_STATE(state_struct, s) (state_struct)->m->set((state_struct), (s))
-void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state);
+PHPAPI void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state);
#endif /* MYSQLND_CONNECTION_H */
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index 1c213d2..cc5e2b7 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -157,6 +157,7 @@ struct st_mysqlnd_error_info
unsigned int error_no;
zend_llist * error_list;
+ zend_bool persistent;
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) *m;
};