Fix issue #7.

Ensure tempfile cleanup even with error abort.
This commit is contained in:
Moinak Ghosh 2013-05-01 18:01:17 +05:30
parent b23b5789fb
commit eae16b82d3
2 changed files with 33 additions and 35 deletions

View file

@ -83,8 +83,7 @@ static int ttt = 0;
"movntiq %[val], (%[ptr1]);"\
"movntiq %[val], 0x8(%[ptr1]);"\
: \
: [ptr1] "q" (mem), [val] "q" (val) \
:)
: [ptr1] "q" (mem), [val] "q" (val) )
#define MOV_DBL_QUAD_UNALIGNED(mem, val) \
*((UInt64 *)(mem)) = val; *((UInt64 *)((Byte *)mem + 8)) = val
@ -94,8 +93,7 @@ static int ttt = 0;
"movntiq %[val], 0x10(%[ptr1]);"\
"movntiq %[val], 0x18(%[ptr1]);"\
: \
: [ptr1] "q" (mem), [val] "q" (val) \
:)
: [ptr1] "q" (mem), [val] "q" (val) )
#define MOV_QUAD_QUAD_UNALIGNED(mem, val) \
*((UInt64 *)(mem)) = val; *((UInt64 *)((Byte *)mem + 8)) = val; \
*((UInt64 *)((Byte *)mem + 16)) = val; *((UInt64 *)((Byte *)mem + 24)) = val

View file

@ -291,6 +291,12 @@ init_global_db_s(char *path, char *tmppath, uint32_t chunksize, uint64_t user_ch
cfg->seg_fd_r[i].mapping = NULL;
}
/*
* Remove tempfile entry from the filesystem metadata so that file gets
* automatically removed once process exits.
*/
unlink(cfg->rootdir);
if (errored) {
cleanup_indx(indx);
if (cfg->seg_fd_r)
@ -298,12 +304,6 @@ init_global_db_s(char *path, char *tmppath, uint32_t chunksize, uint64_t user_ch
free(cfg);
return (NULL);
}
/*
* Remove tempfile entry from the filesystem metadata so that file gets
* automatically removed once process exits.
*/
unlink(cfg->rootdir);
}
cfg->segcache_pos = 0;
cfg->dbdata = indx;