Skip to content

Commit 1f36070

Browse files
committed
Use OBJ_RELEASE.
1 parent cb26705 commit 1f36070

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

php_swoole.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,16 +1002,13 @@ static sw_inline void sw_fci_cache_persist(zend_fcall_info_cache *fci_cache)
10021002

10031003
static sw_inline void sw_fci_cache_discard(zend_fcall_info_cache *fci_cache)
10041004
{
1005-
zval _zobject, *zobject = &_zobject;
10061005
if (fci_cache->object)
10071006
{
1008-
ZVAL_OBJ(zobject, fci_cache->object);
1009-
zval_ptr_dtor(zobject);
1007+
OBJ_RELEASE(fci_cache->object);
10101008
}
10111009
if (fci_cache->function_handler->op_array.fn_flags & ZEND_ACC_CLOSURE)
10121010
{
1013-
ZVAL_OBJ(zobject, ZEND_CLOSURE_OBJECT(fci_cache->function_handler));
1014-
zval_ptr_dtor(zobject);
1011+
OBJ_RELEASE(ZEND_CLOSURE_OBJECT(fci_cache->function_handler));
10151012
}
10161013
}
10171014

swoole_coroutine.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,26 +215,23 @@ static void php_coro_create(void *arg)
215215
{
216216
int i;
217217
php_args *php_arg = (php_args *) arg;
218-
zend_fcall_info_cache *fci_cache = php_arg->fci_cache;
219-
zend_function *func = fci_cache->function_handler;
218+
zend_fcall_info_cache fci_cache = *php_arg->fci_cache;
219+
zend_function *func = fci_cache.function_handler;
220220
zval *argv = php_arg->argv;
221221
int argc = php_arg->argc;
222222
coro_task *task;
223223
coro_task *origin_task = php_arg->origin_task;
224224
zend_execute_data *call;
225-
zval _zobject, *zobject = nullptr;
226225
zval _retval, *retval = &_retval;
227226

228227
if (swCoroG.count() > COROG.peak_coro_num)
229228
{
230229
COROG.peak_coro_num = swCoroG.count();
231230
}
232231

233-
if (fci_cache->object)
232+
if (fci_cache.object)
234233
{
235-
zobject = &_zobject;
236-
ZVAL_OBJ(zobject, fci_cache->object);
237-
Z_ADDREF_P(zobject);
234+
GC_ADDREF(fci_cache.object);
238235
}
239236

240237
php_vm_stack_init();
@@ -243,7 +240,7 @@ static void php_coro_create(void *arg)
243240
EG(vm_stack_top) = (zval *) ((char *) call + TASK_SLOT * sizeof(zval));
244241
call = zend_vm_stack_push_call_frame(
245242
ZEND_CALL_TOP_FUNCTION | ZEND_CALL_ALLOCATED,
246-
func, argc, fci_cache->called_scope, fci_cache->object
243+
func, argc, fci_cache.called_scope, fci_cache.object
247244
);
248245

249246
SW_SET_EG_SCOPE(func->common.scope);
@@ -331,9 +328,9 @@ static void php_coro_create(void *arg)
331328

332329
zval_ptr_dtor(retval);
333330

334-
if (zobject)
331+
if (fci_cache.object)
335332
{
336-
zval_ptr_dtor(zobject);
333+
OBJ_RELEASE(fci_cache.object);
337334
}
338335

339336
if (UNEXPECTED(EG(exception)))

0 commit comments

Comments
 (0)