Browse Source

munmap() file in RSHUTDOWN, if PHPWRITE fails.

experimental/pre_new_hash_func
Sascha Schumann 25 years ago
parent
commit
d5cfb03ac9
  1. 12
      ext/standard/basic_functions.c
  2. 5
      ext/standard/basic_functions.h
  3. 5
      ext/standard/file.c

12
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;
}

5
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

5
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;

Loading…
Cancel
Save