com php-src: Fixed persistent dba handling: ext/dba/dba.c
| From: | Xinchen Hui | Date: | Wed, 21 May 2014 04:22:59 +0000 |
| Subject: | com php-src: Fixed persistent dba handling: ext/dba/dba.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78485@lists.php.net to get a copy of this message | ||
Commit: 96617874bd5d9872dde39488bc272385764ff8e2
Author: Xinchen Hui <laruence@php.net> Wed, 21 May 2014 12:22:59 +0800
Parents: 6d12d3bae12682e66cc45de56b3bb6d07c038575
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=96617874bd5d9872dde39488bc272385764ff8e2
Log:
Fixed persistent dba handling
Changed paths:
M ext/dba/dba.c
Diff:
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index b04a2ee..15b5ad9 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -417,14 +417,14 @@ static void dba_close(dba_info *info TSRMLS_DC)
pefree(info->path, info->flags&DBA_PERSISTENT);
}
if (info->fp && info->fp != info->lock.fp) {
- if(info->flags&DBA_PERSISTENT) {
+ if (info->flags & DBA_PERSISTENT) {
php_stream_pclose(info->fp);
} else {
php_stream_close(info->fp);
}
}
if (info->lock.fp) {
- if(info->flags & DBA_PERSISTENT) {
+ if (info->flags & DBA_PERSISTENT) {
php_stream_pclose(info->lock.fp);
} else {
php_stream_close(info->lock.fp);
@@ -443,16 +443,14 @@ static void dba_close_rsrc(zend_resource *rsrc TSRMLS_DC)
{
dba_info *info = (dba_info *)rsrc->ptr;
- if (info) {
- dba_close(info TSRMLS_CC);
- }
+ dba_close(info TSRMLS_CC);
}
/* }}} */
/* {{{ dba_close_pe_rsrc_deleter */
int dba_close_pe_rsrc_deleter(zval *el, void *pDba TSRMLS_DC)
{
- return ((zend_resource *)Z_PTR_P(el))->ptr == pDba;
+ return ((zend_resource *)Z_PTR_P(el))->ptr == pDba ? ZEND_HASH_APPLY_REMOVE:
ZEND_HASH_APPLY_KEEP;
}
/* }}} */
@@ -674,7 +672,8 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
info = (dba_info *)le->ptr;
- ZEND_REGISTER_RESOURCE(return_value, info, le_pdb);
+ GC_REFCOUNT(le)++;
+ RETURN_RES(le);
return;
}
}
@@ -987,7 +986,11 @@ PHP_FUNCTION(dba_close)
DBA_FETCH_RESOURCE(info, id);
- zend_list_close(Z_RES_P(id));
+ if (info->flags & DBA_PERSISTENT) {
+ zend_list_delete(Z_RES_P(id));
+ } else {
+ zend_list_close(Z_RES_P(id));
+ }
}
/* }}} */