#ifdef ZTS
zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) php_oci_list_helper, (void *)le_descriptor TSRMLS_CC);
zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) php_oci_list_helper, (void *)le_collection TSRMLS_CC);
- zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) php_oci_list_helper, (void *)le_statement TSRMLS_CC);
+ while (OCI_G(num_statements)) {
+ zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) php_oci_list_helper, (void *)le_statement TSRMLS_CC);
+ }
#endif
/* check persistent connections and do the necessary actions if needed */
static int php_oci_list_helper(zend_rsrc_list_entry *le, void *le_type TSRMLS_DC)
{
int type = (int) le_type;
-
+
if (le->type == type) {
- if (le->ptr != NULL) {
- return 1;
+ if (le->ptr != NULL && --le->refcount<=0) {
+ return ZEND_HASH_APPLY_REMOVE;
}
}
- return 0;
+ return ZEND_HASH_APPLY_KEEP;
} /* }}} */
#endif
}
PHP_OCI_REGISTER_RESOURCE(statement, le_statement);
+
+ OCI_G(num_statements)++;
return statement;
}
outcol->retlen = -1;
dynamic = OCI_DEFAULT;
buf = &(outcol->statement->stmt);
+ zend_list_addref(statement->id);
break;
case SQLT_RDD: /* ROWID */
zend_list_delete(statement->connection->rsrc_id);
efree(statement);
+
+ OCI_G(num_statements)--;
} /* }}} */
/* {{{ php_oci_bind_pre_exec()
long max_persistent; /* maximum number of persistent connections per process */
long num_persistent; /* number of existing persistent connections */
long num_links; /* non-persistent + persistent connections */
+ long num_statements; /* number of statements open */
long ping_interval; /* time interval between pings */
long persistent_timeout; /* time period after which idle persistent connection is considered expired */
long statement_cache_size; /* statement cache size. used with 9i+ clients only*/