We are flushing the wrong file on decompression. Make sure we flush the file out.

This commit is contained in:
Con Kolivas 2011-02-08 08:27:22 +11:00
parent 6b73eb1394
commit 9c2b86fec6
3 changed files with 5 additions and 4 deletions

2
main.c
View file

@ -292,6 +292,7 @@ static void decompress_file(void)
preserve_perms(fd_in, fd_out);
} else
fd_out = open_tmpoutfile();
control.fd_out = fd_out;
fd_hist = open(control.outfile, O_RDONLY);
if (unlikely(fd_hist == -1))
@ -490,6 +491,7 @@ static void compress_file(void)
fatal("Failed to create %s: %s\n", control.outfile, strerror(errno));
} else
fd_out = open_tmpoutfile();
control.fd_out = fd_out;
preserve_perms(fd_in, fd_out);

1
rzip.h
View file

@ -266,6 +266,7 @@ struct rzip_control {
int minor_version;
i64 st_size;
long page_size;
int fd_out;
} control;
struct stream {

View file

@ -43,7 +43,6 @@ struct uncomp_thread{
sem_t ready; /* Taken this thread's data so it can die */
sem_t free;
int stream;
int fd;
} *ucthread;
void init_sem(sem_t *sem)
@ -969,7 +968,7 @@ static void *compthread(void *t)
cti->c_type = CTYPE_NONE;
cti->c_len = cti->s_len;
/* Flushing writes to disk, frees up any dirty ram, improving chances
/* Flushing writes to disk frees up any dirty ram, improving chances
* of succeeding in allocating more ram */
fsync(ctis->fd);
retry:
@ -1095,7 +1094,6 @@ static void *ucompthread(void *t)
if (unlikely(setpriority(PRIO_PROCESS, 0, control.nice_val) == -1))
print_err("Warning, unable to set nice value on thread\n");
fsync(uci->fd);
retry:
if (uci->c_type != CTYPE_NONE) {
switch (uci->c_type) {
@ -1190,6 +1188,7 @@ fill_another:
/* Wait till the next thread is free */
wait_sem(&ucthread[s->uthread_no].free);
fsync(control.fd_out);
s_buf = malloc(u_len);
if (unlikely(u_len && !s_buf))
@ -1205,7 +1204,6 @@ fill_another:
ucthread[s->uthread_no].u_len = u_len;
ucthread[s->uthread_no].c_type = c_type;
ucthread[s->uthread_no].stream = stream;
ucthread[s->uthread_no].fd = sinfo->fd;
s->last_head = last_head;
print_maxverbose("Starting thread %ld to decompress %lld bytes from stream %d\n",