Browse Source

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 16 years ago
parent
commit
36f82d9433
  1. 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…
Cancel
Save