iliaa Tue Jul 29 14:26:59 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-src/main streams.c php_streams.h
/php-src/ext/dba dba.c
/php-src/ext/standard file.c
Log:
MFH: persistent streams patch
Index: php-src/main/streams.c
diff -u php-src/main/streams.c:1.125.2.72 php-src/main/streams.c:1.125.2.73
--- php-src/main/streams.c:1.125.2.72 Mon Jul 28 14:57:49 2003
+++ php-src/main/streams.c Tue Jul 29 14:26:59 2003
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.125.2.72 2003/07/28 18:57:49 iliaa Exp $ */
+/* $Id: streams.c,v 1.125.2.73 2003/07/29 18:26:59 iliaa Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -280,7 +280,7 @@
static int _php_stream_free_persistent(list_entry *le, void *pStream TSRMLS_DC)
{
- return (le->ptr == pStream && !((php_stream *)pStream)->in_free);
+ return le->ptr == pStream;
}
PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /* {{{ */
@@ -378,7 +378,7 @@
stream->readbuf = NULL;
}
- if (stream->is_persistent) {
+ if (stream->is_persistent && (close_options &
PHP_STREAM_FREE_PERSISTENT)) {
/* we don't work with *stream but need its value for
comparison */
zend_hash_apply_with_argument(&EG(persistent_list),
(apply_func_arg_t) _php_stream_free_persistent, stream TSRMLS_CC);
}
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.61.2.15 php-src/main/php_streams.h:1.61.2.16
--- php-src/main/php_streams.h:1.61.2.15 Fri Jun 27 12:16:46 2003
+++ php-src/main/php_streams.h Tue Jul 29 14:26:59 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_streams.h,v 1.61.2.15 2003/06/27 16:16:46 pollita Exp $ */
+/* $Id: php_streams.h,v 1.61.2.16 2003/07/29 18:26:59 iliaa Exp $ */
#ifndef PHP_STREAMS_H
#define PHP_STREAMS_H
@@ -333,11 +333,14 @@
#define PHP_STREAM_FREE_RELEASE_STREAM 2 /* pefree(stream) */
#define PHP_STREAM_FREE_PRESERVE_HANDLE 4 /* tell ops->close to not
close it's underlying handle */
#define PHP_STREAM_FREE_RSRC_DTOR 8 /* called from the resource
list dtor */
+#define PHP_STREAM_FREE_PERSISTENT 16 /* manually freeing a
persistent connection */
#define PHP_STREAM_FREE_CLOSE (PHP_STREAM_FREE_CALL_DTOR |
PHP_STREAM_FREE_RELEASE_STREAM)
#define PHP_STREAM_FREE_CLOSE_CASTED (PHP_STREAM_FREE_CLOSE |
PHP_STREAM_FREE_PRESERVE_HANDLE)
+#define PHP_STREAM_FREE_CLOSE_PERSISTENT (PHP_STREAM_FREE_CLOSE |
PHP_STREAM_FREE_PERSISTENT)
PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC);
#define php_stream_free(stream, close_options) _php_stream_free((stream),
(close_options) TSRMLS_CC)
#define php_stream_close(stream) _php_stream_free((stream),
PHP_STREAM_FREE_CLOSE TSRMLS_CC)
+#define php_stream_pclose(stream) _php_stream_free((stream),
PHP_STREAM_FREE_CLOSE_PERSISTENT TSRMLS_CC)
PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC);
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET
TSRMLS_CC)
Index: php-src/ext/dba/dba.c
diff -u php-src/ext/dba/dba.c:1.61.2.20 php-src/ext/dba/dba.c:1.61.2.21
--- php-src/ext/dba/dba.c:1.61.2.20 Sat Jun 14 15:27:01 2003
+++ php-src/ext/dba/dba.c Tue Jul 29 14:26:59 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.61.2.20 2003/06/14 19:27:01 helly Exp $ */
+/* $Id: dba.c,v 1.61.2.21 2003/07/29 18:26:59 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -321,7 +321,11 @@
pefree(info->path, info->flags&DBA_PERSISTENT);
}
if (info->fp && info->fp!=info->lock.fp) {
- php_stream_close(info->fp);
+ if(info->flags&DBA_PERSISTENT) {
+ php_stream_pclose(info->fp);
+ } else {
+ php_stream_close(info->fp);
+ }
}
if (info->lock.fd) {
php_flock(info->lock.fd, LOCK_UN);
@@ -329,7 +333,11 @@
info->lock.fd = 0;
}
if (info->lock.fp) {
- php_stream_close(info->lock.fp);
+ if(info->flags&DBA_PERSISTENT) {
+ php_stream_pclose(info->lock.fp);
+ } else {
+ php_stream_close(info->lock.fp);
+ }
}
if (info->lock.name) {
pefree(info->lock.name, info->flags&DBA_PERSISTENT);
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.33 php-src/ext/standard/file.c:1.279.2.34
--- php-src/ext/standard/file.c:1.279.2.33 Mon Jul 28 10:42:56 2003
+++ php-src/ext/standard/file.c Tue Jul 29 14:26:59 2003
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.279.2.33 2003/07/28 14:42:56 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.34 2003/07/29 18:26:59 iliaa Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -1156,7 +1156,11 @@
}
php_stream_from_zval(stream, arg1);
- zend_list_delete(stream->rsrc_id);
+ if (!stream->is_persistent) {
+ zend_list_delete(stream->rsrc_id);
+ } else {
+ php_stream_pclose(stream);
+ }
RETURN_TRUE;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php