cvs: pecl(PECL_4_3) /sqlite sqlite.c

From: Date: Sun, 13 Jul 2003 09:20:05 +0000
Subject: cvs: pecl(PECL_4_3) /sqlite sqlite.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-358@lists.php.net to get a copy of this message
wez Sun Jul 13 05:20:05 2003 EDT Modified files: (Branch: PECL_4_3) /pecl/sqlite sqlite.c Log: A much better fix for the popen problem # no thanks to Jolt Cola Index: pecl/sqlite/sqlite.c diff -u pecl/sqlite/sqlite.c:1.62.2.7 pecl/sqlite/sqlite.c:1.62.2.8 --- pecl/sqlite/sqlite.c:1.62.2.7 Sun Jul 13 04:49:07 2003 +++ pecl/sqlite/sqlite.c Sun Jul 13 05:20:05 2003 @@ -17,7 +17,7 @@ | Marcus Boerger <helly@php.net> | +----------------------------------------------------------------------+ - $Id: sqlite.c,v 1.62.2.7 2003/07/13 08:49:07 wez Exp $ + $Id: sqlite.c,v 1.62.2.8 2003/07/13 09:20:05 wez Exp $ */ #ifdef HAVE_CONFIG_H @@ -205,17 +205,11 @@ } } -static ZEND_RSRC_DTOR_FUNC(php_sqlite_pdb_invalidator) -{ - struct php_sqlite_db *db = (struct php_sqlite_db*)rsrc->ptr; - - db->rsrc_id = FAILURE; -} - static ZEND_RSRC_DTOR_FUNC(php_sqlite_db_dtor) { if (rsrc->ptr) { struct php_sqlite_db *db = (struct php_sqlite_db*)rsrc->ptr; + sqlite_close(db->db); zend_hash_destroy(&db->callbacks); @@ -631,7 +625,7 @@ REGISTER_INI_ENTRIES(); le_sqlite_db = zend_register_list_destructors_ex(php_sqlite_db_dtor, NULL, "sqlite database", module_number); - le_sqlite_pdb = zend_register_list_destructors_ex(php_sqlite_pdb_invalidator, php_sqlite_db_dtor, "sqlite database (persistent)", module_number); + le_sqlite_pdb = zend_register_list_destructors_ex(NULL, php_sqlite_db_dtor, "sqlite database (persistent)", module_number); le_sqlite_result = zend_register_list_destructors_ex(php_sqlite_result_dtor, NULL, "sqlite result", module_number); REGISTER_LONG_CONSTANT("SQLITE_BOTH", PHPSQLITE_BOTH, CONST_CS|CONST_PERSISTENT); @@ -675,7 +669,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "SQLite support", "enabled"); - php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.62.2.7 2003/07/13 08:49:07 wez Exp $"); + php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.62.2.8 2003/07/13 09:20:05 wez Exp $"); php_info_print_table_row(2, "SQLite Library", sqlite_libversion()); php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding()); php_info_print_table_end(); @@ -787,8 +781,16 @@ /* give it a valid resource id for this request */ db->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, db, le_sqlite_pdb); } else { - /* already accessed this request; map it */ - ZVAL_RESOURCE(return_value, db->rsrc_id); + int type; + /* sanity check to ensure that the resource is still a valid regular resource + * number */ + if (_zend_list_find(db->rsrc_id, &type) == db) { + /* already accessed this request; map it */ + zend_list_addref(db->rsrc_id); + ZVAL_RESOURCE(return_value, db->rsrc_id); + } else { + db->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, db, le_sqlite_pdb); + } } /* all set */

« previous php.pecl.cvs (#358) next »