1
0
Fork 0

fix #16, messy XCACHE_MAP_FAILED logic, thanks Jan

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.0@80 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.0
Xuefer 17 years ago
parent 52e2913855
commit 5436368ebe

@ -199,11 +199,14 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
#else
shm->ptr_ro = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
#endif
if (shm->ptr_ro == XCACHE_MAP_FAILED) {
shm->ptr_ro = NULL;
}
romem = shm->ptr_ro;
/* {{{ check if ptr_ro works */
do {
if (shm->ptr_ro == XCACHE_MAP_FAILED || shm->ptr_ro == shm->ptr) {
if (shm->ptr_ro == NULL || shm->ptr_ro == shm->ptr) {
break;
}
*(char *)shm->ptr = 1;
@ -223,7 +226,7 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
assert(abs(shm->diff) >= size);
}
else {
if (shm->ptr_ro != XCACHE_MAP_FAILED) {
if (shm->ptr_ro) {
munmap(shm->ptr_ro, size);
}
shm->ptr_ro = NULL;

Loading…
Cancel
Save