summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArnaud Le Blanc <lbarnaud@php.net>2009-05-17 14:58:10 +0000
committerArnaud Le Blanc <lbarnaud@php.net>2009-05-17 14:58:10 +0000
commitc79528a26d6fed5e11b29dabb4694c52e659cceb (patch)
tree440a6093da48bf83f33a0f497668bd1c8be38fe9 /main
parent7c30401aec34d57ed24ca3cb61be6756043c4fc4 (diff)
downloadphp-git-c79528a26d6fed5e11b29dabb4694c52e659cceb.tar.gz
MFH: Fixed bug #48309 (stream_copy_to_stream() and fpasstru() do not
update stream position of plain files)
Diffstat (limited to 'main')
-rw-r--r--main/streams/mmap.c14
-rw-r--r--main/streams/php_stream_mmap.h5
-rwxr-xr-xmain/streams/streams.c6
3 files changed, 22 insertions, 3 deletions
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index e8ee8bd152..4b8d356881 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -51,6 +51,20 @@ PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC)
return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0;
}
+PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC)
+{
+ int ret = 1;
+
+ if (php_stream_seek(stream, readden, SEEK_CUR) != 0) {
+ ret = 0;
+ }
+ if (php_stream_mmap_unmap(stream) == 0) {
+ ret = 0;
+ }
+
+ return ret;
+}
+
/*
* Local variables:
* tab-width: 4
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index 30ea7889be..1e4ced33e1 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -58,6 +58,8 @@ typedef struct {
} php_stream_mmap_range;
+#define PHP_STREAM_MMAP_ALL 0
+
#define php_stream_mmap_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_SUPPORTED, NULL TSRMLS_CC) == 0 ? 1 : 0)
/* Returns 1 if the stream in its current state can be memory mapped,
@@ -71,6 +73,9 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
/* un-maps the last mapped range */
PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC);
#define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream) TSRMLS_CC)
+
+PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC);
+#define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC)
END_EXTERN_C()
/*
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 77a6b6e024..6bbe09be59 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1215,12 +1215,12 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC)
char *p;
size_t mapped;
- p = php_stream_mmap_range(stream, php_stream_tell(stream), PHP_STREAM_COPY_ALL, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
+ p = php_stream_mmap_range(stream, php_stream_tell(stream), PHP_STREAM_MMAP_ALL, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
if (p) {
PHPWRITE(p, mapped);
- php_stream_mmap_unmap(stream);
+ php_stream_mmap_unmap_ex(stream, mapped);
return mapped;
}
@@ -1340,7 +1340,7 @@ PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, s
if (p) {
mapped = php_stream_write(dest, p, mapped);
- php_stream_mmap_unmap(src);
+ php_stream_mmap_unmap_ex(src, mapped);
*len = mapped;