php extension fix free object bug in PHP 7
parent
16f33458b8
commit
4a57692c72
3
HISTORY
3
HISTORY
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
Version 5.09 2016-11-10
|
Version 5.09 2016-12-29
|
||||||
* bug fixed: list_all_groups expand buffer auto for so many groups
|
* bug fixed: list_all_groups expand buffer auto for so many groups
|
||||||
* tracker.conf add parameters: min_buff_size and max_buff_size
|
* tracker.conf add parameters: min_buff_size and max_buff_size
|
||||||
|
* php extension fix free object bug in PHP 7
|
||||||
|
|
||||||
Version 5.08 2016-04-08
|
Version 5.08 2016-04-08
|
||||||
* install library to $(TARGET_PREFIX)/lib anyway
|
* install library to $(TARGET_PREFIX)/lib anyway
|
||||||
|
|
|
||||||
|
|
@ -62,15 +62,11 @@ typedef struct
|
||||||
static int php_fdfs_download_callback(void *arg, const int64_t file_size, \
|
static int php_fdfs_download_callback(void *arg, const int64_t file_size, \
|
||||||
const char *data, const int current_size);
|
const char *data, const int current_size);
|
||||||
|
|
||||||
static void php_fdfs_free_storage(php_fdfs_t *i_obj);
|
|
||||||
|
|
||||||
static FDFSConfigInfo *config_list = NULL;
|
static FDFSConfigInfo *config_list = NULL;
|
||||||
static int config_count = 0;
|
static int config_count = 0;
|
||||||
|
|
||||||
static FDFSPhpContext php_context = {&g_tracker_group, 0};
|
static FDFSPhpContext php_context = {&g_tracker_group, 0};
|
||||||
|
|
||||||
static int le_fdfs;
|
|
||||||
|
|
||||||
static zend_class_entry *fdfs_ce = NULL;
|
static zend_class_entry *fdfs_ce = NULL;
|
||||||
static zend_class_entry *fdfs_exception_ce = NULL;
|
static zend_class_entry *fdfs_exception_ce = NULL;
|
||||||
|
|
||||||
|
|
@ -5373,28 +5369,6 @@ static void php_fdfs_destroy(php_fdfs_t *i_obj TSRMLS_DC)
|
||||||
efree(i_obj->context.pTrackerGroup);
|
efree(i_obj->context.pTrackerGroup);
|
||||||
i_obj->context.pTrackerGroup = NULL;
|
i_obj->context.pTrackerGroup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
efree(i_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZEND_RSRC_DTOR_FUNC(php_fdfs_dtor)
|
|
||||||
{
|
|
||||||
#if PHP_MAJOR_VERSION < 7
|
|
||||||
if (rsrc->ptr != NULL)
|
|
||||||
{
|
|
||||||
php_fdfs_t *i_obj = (php_fdfs_t *)rsrc->ptr;
|
|
||||||
php_fdfs_destroy(i_obj TSRMLS_CC);
|
|
||||||
rsrc->ptr = NULL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (res->ptr != NULL)
|
|
||||||
{
|
|
||||||
php_fdfs_t *i_obj = (php_fdfs_t *)res->ptr;
|
|
||||||
php_fdfs_destroy(i_obj TSRMLS_CC);
|
|
||||||
res->ptr = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FastDFS::__construct([int config_index = 0, bool bMultiThread = false])
|
/* FastDFS::__construct([int config_index = 0, bool bMultiThread = false])
|
||||||
|
|
@ -5455,15 +5429,6 @@ static PHP_METHOD(FastDFS, __construct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PHP_METHOD(FastDFS, __destruct)
|
|
||||||
{
|
|
||||||
zval *object = getThis();
|
|
||||||
php_fdfs_t *i_obj;
|
|
||||||
|
|
||||||
i_obj = (php_fdfs_t *) fdfs_get_object(object);
|
|
||||||
php_fdfs_free_storage(i_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
array FastDFS::tracker_get_connection()
|
array FastDFS::tracker_get_connection()
|
||||||
return array for success, false for error
|
return array for success, false for error
|
||||||
|
|
@ -6574,9 +6539,6 @@ ZEND_ARG_INFO(0, config_index)
|
||||||
ZEND_ARG_INFO(0, bMultiThread)
|
ZEND_ARG_INFO(0, bMultiThread)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo___destruct, 0, 0, 0)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_tracker_get_connection, 0, 0, 0)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_tracker_get_connection, 0, 0, 0)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
|
@ -7077,7 +7039,6 @@ ZEND_END_ARG_INFO()
|
||||||
#define FDFS_ME(name, args) PHP_ME(FastDFS, name, args, ZEND_ACC_PUBLIC)
|
#define FDFS_ME(name, args) PHP_ME(FastDFS, name, args, ZEND_ACC_PUBLIC)
|
||||||
static zend_function_entry fdfs_class_methods[] = {
|
static zend_function_entry fdfs_class_methods[] = {
|
||||||
FDFS_ME(__construct, arginfo___construct)
|
FDFS_ME(__construct, arginfo___construct)
|
||||||
FDFS_ME(__destruct, arginfo___destruct)
|
|
||||||
FDFS_ME(tracker_get_connection, arginfo_tracker_get_connection)
|
FDFS_ME(tracker_get_connection, arginfo_tracker_get_connection)
|
||||||
FDFS_ME(tracker_make_all_connections, arginfo_tracker_make_all_connections)
|
FDFS_ME(tracker_make_all_connections, arginfo_tracker_make_all_connections)
|
||||||
FDFS_ME(tracker_close_all_connections,arginfo_tracker_close_all_connections)
|
FDFS_ME(tracker_close_all_connections,arginfo_tracker_close_all_connections)
|
||||||
|
|
@ -7153,11 +7114,23 @@ static zend_function_entry fdfs_class_methods[] = {
|
||||||
#undef FDFS_ME
|
#undef FDFS_ME
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
static void php_fdfs_free_storage(php_fdfs_t *i_obj)
|
#if PHP_MAJOR_VERSION < 7
|
||||||
|
static void php_fdfs_free_storage(void *object TSRMLS_DC)
|
||||||
{
|
{
|
||||||
|
php_fdfs_t *i_obj = (php_fdfs_t *)object;
|
||||||
|
zend_object_std_dtor(&i_obj->zo TSRMLS_CC);
|
||||||
|
php_fdfs_destroy(i_obj TSRMLS_CC);
|
||||||
|
efree(i_obj);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void php_fdfs_free_storage(zend_object *object)
|
||||||
|
{
|
||||||
|
php_fdfs_t *i_obj = (php_fdfs_t *)((char*)(object) -
|
||||||
|
XtOffsetOf(php_fdfs_t , zo));
|
||||||
zend_object_std_dtor(&i_obj->zo TSRMLS_CC);
|
zend_object_std_dtor(&i_obj->zo TSRMLS_CC);
|
||||||
php_fdfs_destroy(i_obj TSRMLS_CC);
|
php_fdfs_destroy(i_obj TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if PHP_MAJOR_VERSION < 7
|
#if PHP_MAJOR_VERSION < 7
|
||||||
zend_object_value php_fdfs_new(zend_class_entry *ce TSRMLS_DC)
|
zend_object_value php_fdfs_new(zend_class_entry *ce TSRMLS_DC)
|
||||||
|
|
@ -7170,7 +7143,7 @@ zend_object_value php_fdfs_new(zend_class_entry *ce TSRMLS_DC)
|
||||||
zend_object_std_init(&i_obj->zo, ce TSRMLS_CC);
|
zend_object_std_init(&i_obj->zo, ce TSRMLS_CC);
|
||||||
retval.handle = zend_objects_store_put(i_obj, \
|
retval.handle = zend_objects_store_put(i_obj, \
|
||||||
(zend_objects_store_dtor_t)zend_objects_destroy_object, \
|
(zend_objects_store_dtor_t)zend_objects_destroy_object, \
|
||||||
NULL, NULL TSRMLS_CC);
|
php_fdfs_free_storage, NULL TSRMLS_CC);
|
||||||
retval.handlers = zend_get_std_object_handlers();
|
retval.handlers = zend_get_std_object_handlers();
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -7517,15 +7490,13 @@ PHP_MINIT_FUNCTION(fastdfs_client)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PHP_MAJOR_VERSION >= 7
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
memcpy(&fdfs_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
memcpy(&fdfs_object_handlers, zend_get_std_object_handlers(),
|
||||||
|
sizeof(zend_object_handlers));
|
||||||
fdfs_object_handlers.offset = XtOffsetOf(php_fdfs_t, zo);
|
fdfs_object_handlers.offset = XtOffsetOf(php_fdfs_t, zo);
|
||||||
fdfs_object_handlers.free_obj = NULL;
|
fdfs_object_handlers.free_obj = php_fdfs_free_storage;
|
||||||
fdfs_object_handlers.clone_obj = NULL;
|
fdfs_object_handlers.clone_obj = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
le_fdfs = zend_register_list_destructors_ex(NULL, php_fdfs_dtor, \
|
|
||||||
"FastDFS", module_number);
|
|
||||||
|
|
||||||
INIT_CLASS_ENTRY(ce, "FastDFS", fdfs_class_methods);
|
INIT_CLASS_ENTRY(ce, "FastDFS", fdfs_class_methods);
|
||||||
fdfs_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
fdfs_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||||
fdfs_ce->create_object = php_fdfs_new;
|
fdfs_ce->create_object = php_fdfs_new;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue