diff options
| author | Sascha Schumann <sas@php.net> | 2001-05-18 23:38:46 +0000 |
|---|---|---|
| committer | Sascha Schumann <sas@php.net> | 2001-05-18 23:38:46 +0000 |
| commit | d5cfb03ac9126a2f0ff29bee873c36830fc037fe (patch) | |
| tree | 5f03ae6336c8ba8cc6d23cb656da18bae5101602 | |
| parent | d1697ad012854bea81dfbe7792dce96b6bb0701a (diff) | |
| download | php-git-d5cfb03ac9126a2f0ff29bee873c36830fc037fe.tar.gz | |
munmap() file in RSHUTDOWN, if PHPWRITE fails.
| -rw-r--r-- | ext/standard/basic_functions.c | 12 | ||||
| -rw-r--r-- | ext/standard/basic_functions.h | 5 | ||||
| -rw-r--r-- | ext/standard/file.c | 5 |
3 files changed, 22 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 355e4cff8f..5f1fec4ece 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -48,6 +48,9 @@ #if HAVE_LOCALE_H #include <locale.h> #endif +#if HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif #include "safe_mode.h" #ifdef PHP_WIN32 #include "win32/unistd.h" @@ -830,6 +833,9 @@ PHP_RINIT_FUNCTION(basic) BG(user_compare_func_name) = NULL; BG(array_walk_func_name) = NULL; BG(incomplete_class) = NULL; +#ifdef HAVE_MMAP + BG(mmap_file) = NULL; +#endif BG(page_uid) = -1; BG(page_inode) = -1; BG(page_mtime) = -1; @@ -897,6 +903,12 @@ PHP_RSHUTDOWN_FUNCTION(basic) BG(user_tick_functions) = NULL; } +#ifdef HAVE_MMAP + if (BG(mmap_file)) { + munmap(BG(mmap_file), BG(mmap_len)); + } +#endif + return SUCCESS; } diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 86e7756c74..8a3c1e3de6 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -188,6 +188,11 @@ typedef struct { /* url_scanner_ex.re */ url_adapt_state_ex_t url_adapt_state_ex; #endif + +#ifdef HAVE_MMAP + void *mmap_file; + size_t mmap_len; +#endif } php_basic_globals; #ifdef ZTS diff --git a/ext/standard/file.c b/ext/standard/file.c index a1d7a74e41..a395ab29ce 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -33,6 +33,7 @@ #include "ext/standard/exec.h" #include "ext/standard/php_filestat.h" #include "php_open_temporary_file.h" +#include "ext/standard/basic_functions.h" #include <stdio.h> #include <stdlib.h> @@ -1548,7 +1549,11 @@ static size_t php_passthru_fd(int socketd, FILE *fp, int issock) len = sbuf.st_size - off; p = mmap(0, len, PROT_READ, MAP_SHARED, fd, off); if (p != (void *) MAP_FAILED) { + BLS_FETCH(); + BG(mmap_file) = p; + BG(mmap_len) = len; PHPWRITE(p, len); + BG(mmap_file) = NULL; munmap(p, len); bcount += len; ready = 1; |
