summaryrefslogtreecommitdiff
path: root/xdelta3
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2010-11-07 08:45:56 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2010-11-07 08:45:56 +0000
commit5c20b63301a8f58096fe32926a6ab53d6e2d2017 (patch)
tree8090dc351c4064d40de1b6ad5ec130df53a5719f /xdelta3
parent1aa254921a98abec3139e9f3888c82ce2f2188c8 (diff)
Cleanup after external compression processes
Diffstat (limited to 'xdelta3')
-rw-r--r--xdelta3/xdelta3-blkcache.h2
-rw-r--r--xdelta3/xdelta3-main.h29
2 files changed, 20 insertions, 11 deletions
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,
155 * is the point at which external decompression may begin. Set the 155 * is the point at which external decompression may begin. Set the
156 * system for a single block. */ 156 * system for a single block. */
157 lru_size = 1; 157 lru_size = 1;
158 lru[0].blkno = -1; 158 lru[0].blkno = (xoff_t) -1;
159 blksize = option_srcwinsz; 159 blksize = option_srcwinsz;
160 main_blklru_list_push_back (& lru_list, & lru[0]); 160 main_blklru_list_push_back (& lru_list, & lru[0]);
161 161
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)
2102#define MAX_SUBPROCS 4 /* max(source + copier + output, 2102#define MAX_SUBPROCS 4 /* max(source + copier + output,
2103 source + copier + input + copier). */ 2103 source + copier + input + copier). */
2104static pid_t ext_subprocs[MAX_SUBPROCS]; 2104static pid_t ext_subprocs[MAX_SUBPROCS];
2105static char* ext_tmpfile = NULL;
2106 2105
2107/* Like write(), applies to a fd instead of a main_file, for the pipe 2106/* Like write(), applies to a fd instead of a main_file, for the pipe
2108 * copier subprocess. Does not print an error, to facilitate ignoring 2107 * copier subprocess. Does not print an error, to facilitate ignoring
@@ -2169,11 +2168,29 @@ main_external_compression_finish (void)
2169 { 2168 {
2170 return ret; 2169 return ret;
2171 } 2170 }
2171
2172 ext_subprocs[i] = 0;
2172 } 2173 }
2173 2174
2174 return 0; 2175 return 0;
2175} 2176}
2176 2177
2178/* Kills any outstanding compression process. */
2179static void
2180main_external_compression_cleanup (void)
2181{
2182 int i;
2183
2184 for (i = 0; i < num_subprocs; i += 1)
2185 {
2186 if (! ext_subprocs[i]) { continue; }
2187
2188 kill (ext_subprocs[i], SIGTERM);
2189
2190 ext_subprocs[i] = 0;
2191 }
2192}
2193
2177/* This runs as a forked process of main_input_decompress_setup() to 2194/* This runs as a forked process of main_input_decompress_setup() to
2178 * copy input to the decompression process. First, the available 2195 * copy input to the decompression process. First, the available
2179 * input is copied out of the existing buffer, then the buffer is 2196 * input is copied out of the existing buffer, then the buffer is
@@ -3470,11 +3487,6 @@ main_cleanup (void)
3470 main_bdata = NULL; 3487 main_bdata = NULL;
3471 main_bsize = 0; 3488 main_bsize = 0;
3472 3489
3473#if EXTERNAL_COMPRESSION
3474 main_free (ext_tmpfile);
3475 ext_tmpfile = NULL;
3476#endif
3477
3478 main_lru_cleanup(); 3490 main_lru_cleanup();
3479 3491
3480 if (recode_stream != NULL) 3492 if (recode_stream != NULL)
@@ -3948,10 +3960,7 @@ main (int argc, char **argv)
3948 } 3960 }
3949 3961
3950#if EXTERNAL_COMPRESSION 3962#if EXTERNAL_COMPRESSION
3951 if (ext_tmpfile != NULL) 3963 main_external_compression_cleanup ();
3952 {
3953 unlink (ext_tmpfile);
3954 }
3955#endif 3964#endif
3956 3965
3957 main_file_cleanup (& ifile); 3966 main_file_cleanup (& ifile);