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

@ -1,28 +1,28 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
*/
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
*/
/* LzmaEnc.c -- LZMA Encoder
2010-04-16 : Igor Pavlov : Public domain */
@ -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;