From 5c20b63301a8f58096fe32926a6ab53d6e2d2017 Mon Sep 17 00:00:00 2001 From: "josh.macdonald" Date: Sun, 7 Nov 2010 08:45:56 +0000 Subject: Cleanup after external compression processes --- xdelta3/xdelta3-blkcache.h | 2 +- xdelta3/xdelta3-main.h | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'xdelta3') diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h index 87cffac..a570665 100644 --- a/xdelta3/xdelta3-blkcache.h +++ b/xdelta3/xdelta3-blkcache.h @@ -155,7 +155,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, * is the point at which external decompression may begin. Set the * system for a single block. */ lru_size = 1; - lru[0].blkno = -1; + lru[0].blkno = (xoff_t) -1; blksize = option_srcwinsz; main_blklru_list_push_back (& lru_list, & lru[0]); diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index d52dfc1..ebceb39 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h @@ -2102,7 +2102,6 @@ main_merge_output (xd3_stream *stream, main_file *ofile) #define MAX_SUBPROCS 4 /* max(source + copier + output, source + copier + input + copier). */ static pid_t ext_subprocs[MAX_SUBPROCS]; -static char* ext_tmpfile = NULL; /* Like write(), applies to a fd instead of a main_file, for the pipe * copier subprocess. Does not print an error, to facilitate ignoring @@ -2169,11 +2168,29 @@ main_external_compression_finish (void) { return ret; } + + ext_subprocs[i] = 0; } return 0; } +/* Kills any outstanding compression process. */ +static void +main_external_compression_cleanup (void) +{ + int i; + + for (i = 0; i < num_subprocs; i += 1) + { + if (! ext_subprocs[i]) { continue; } + + kill (ext_subprocs[i], SIGTERM); + + ext_subprocs[i] = 0; + } +} + /* This runs as a forked process of main_input_decompress_setup() to * copy input to the decompression process. First, the available * input is copied out of the existing buffer, then the buffer is @@ -3470,11 +3487,6 @@ main_cleanup (void) main_bdata = NULL; main_bsize = 0; -#if EXTERNAL_COMPRESSION - main_free (ext_tmpfile); - ext_tmpfile = NULL; -#endif - main_lru_cleanup(); if (recode_stream != NULL) @@ -3948,10 +3960,7 @@ main (int argc, char **argv) } #if EXTERNAL_COMPRESSION - if (ext_tmpfile != NULL) - { - unlink (ext_tmpfile); - } + main_external_compression_cleanup (); #endif main_file_cleanup (& ifile); -- cgit v1.2.3