1
0
Fork 0

refix to unlink correctly for newly created files

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@61 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.1
Xuefer 2006-06-05 05:13:34 +00:00
parent 7e0b3b0ea8
commit 36f82d9433
1 changed files with 4 additions and 3 deletions

7
mmap.c
View File

@ -166,15 +166,16 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
# define XCACHE_MMAP_PERMISSION (S_IRUSR | S_IWUSR)
fd = open(shm->name, O_RDWR, XCACHE_MMAP_PERMISSION);
if (fd == -1) {
/* do not create file in /dev */
if (strncmp(shm->name, "/dev", 4) == 0) {
goto err;
}
fd = open(shm->name, O_CREAT | O_RDWR, XCACHE_MMAP_PERMISSION);
shm->newfile = 1;
if (fd == -1) {
goto err;
}
}
if (strncmp(shm->name, "/tmp", 4) == 0) {
shm->newfile = 0;
}
ftruncate(fd, size);
#endif