From 49ea143bbd8d0bfcd393d0b5308a5d7833fc087c Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 27 Oct 2017 01:28:58 +0300 Subject: Encapsulate reference-counting primitives. Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead. Added mactros to validate reference-counting (disabled for now). These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads. --- ext/pgsql/pgsql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/pgsql/pgsql.c') diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d9cb3ec301..f1bc779cfe 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -923,7 +923,7 @@ static inline char * _php_pgsql_trim_result(PGconn * pgsql, char **buf) */ static void php_pgsql_set_default_link(zend_resource *res) { - GC_REFCOUNT(res)++; + GC_ADDREF(res); if (PGG(default_link) != NULL) { zend_list_delete(PGG(default_link)); @@ -1451,7 +1451,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) link = (zend_resource *)index_ptr->ptr; if (link->ptr && (link->type == le_link || link->type == le_plink)) { php_pgsql_set_default_link(link); - GC_REFCOUNT(link)++; + GC_ADDREF(link); RETVAL_RES(link); goto cleanup; } else { -- cgit v1.2.1