com php-src: Merge branch 'PHP-7.2' into PHP-7.3: Zend/zend_h ash.c ext/pgsql/pgsql.c ext/pgsql/php_pgsql.h
| From: | Nikita Popov | Date: | Wed, 10 Apr 2019 10:22:34 +0000 |
| Subject: | com php-src: Merge branch 'PHP-7.2' into PHP-7.3: Zend/zend_h ash.c ext/pgsql/pgsql.c ext/pgsql/php_pgsql.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105614@lists.php.net to get a copy of this message | ||
Commit: 6615b9c287963730fcc6fdf0f49d2597154e40f9
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 10 Apr 2019 12:22:34 +0200
Parents: ed1df9d135422bbb44fcd291ad7954358a6f87ed c7a86a38a3f657ab81163ac794450fc7ada2ba3c
Branches: PHP-7.3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6615b9c287963730fcc6fdf0f49d2597154e40f9
Log:
Merge branch 'PHP-7.2' into PHP-7.3
Changed paths:
MM Zend/zend_hash.c
MM ext/pgsql/pgsql.c
MM ext/pgsql/php_pgsql.h
Diff:
diff --cc ext/pgsql/pgsql.c
index 78b3555,c97c600..27462bc
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@@ -1093,8 -1105,9 +1101,9 @@@ static PHP_GINIT_FUNCTION(pgsql
ZEND_TSRMLS_CACHE_UPDATE();
#endif
memset(pgsql_globals, 0, sizeof(zend_pgsql_globals));
- /* Initilize notice message hash at MINIT only */
+ /* Initialize notice message hash at MINIT only */
zend_hash_init_ex(&pgsql_globals->notices, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
+ zend_hash_init_ex(&pgsql_globals->hashes, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
}
/* }}} */
@@@ -1440,14 -1442,11 +1451,11 @@@ static void php_pgsql_do_connect(INTERN
}
link = (zend_resource *)index_ptr->ptr;
- if (link->ptr && (link->type == le_link || link->type == le_plink)) {
- php_pgsql_set_default_link(link);
- GC_ADDREF(link);
- RETVAL_RES(link);
- goto cleanup;
- } else {
- zend_hash_del(&EG(regular_list), str.s);
- }
+ ZEND_ASSERT(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;
}
if (PGG(max_links) != -1 && PGG(num_links) >= PGG(max_links)) {
php_error_docref(NULL, E_WARNING, "Cannot create new link. Too many open links ("
ZEND_LONG_FMT ")", PGG(num_links));
@@@ -1490,7 -1489,19 +1498,17 @@@
/* add it to the hash */
new_index_ptr.ptr = (void *) Z_RES_P(return_value);
new_index_ptr.type = le_index_ptr;
- if (zend_hash_update_mem(&EG(regular_list), str.s, (void *) &new_index_ptr,
sizeof(zend_resource)) == NULL) {
- goto err;
- }
+ zend_hash_update_mem(&EG(regular_list), str.s, (void *) &new_index_ptr,
sizeof(zend_resource));
+
+ /* Keep track of link => hash mapping, so we can remove the hash entry from regular_list
+ * when the connection is closed. This uses the address of the connection rather than the
+ * zend_resource, because the resource destructor is passed a stack copy of the resource
+ * structure. */
+ {
+ zval tmp;
+ ZVAL_STR_COPY(&tmp, str.s);
+ zend_hash_index_update(&PGG(hashes), (uintptr_t) pgsql, &tmp);
+ }
PGG(num_links)++;
}
/* set notice processor */