refix to unlink correctly for newly created files
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@61 c26eb9a1-5813-0410-bd6c-c2e55f420ca71.1
parent
7e0b3b0ea8
commit
36f82d9433
7
mmap.c
7
mmap.c
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue