Commit 179c189f authored by Mike Hibler's avatar Mike Hibler

Avoid a pre-mature close of the output fd.

Wait til all other threads have joined.
parent c5d15a6b
......@@ -156,6 +156,9 @@ static void threadinit(void);
static void threadwait(void);
static void threadquit(void);
static void *DiskWriter(void *arg);
#ifdef FRISBEE
extern void (*DiskStatusCallback)(int);
#endif
static int writeinprogress; /* XXX */
static pthread_t child_pid;
......@@ -1070,12 +1073,19 @@ ImageUnzipFlush(void)
threadwait();
if (outfd >= 0) {
if (DiskStatusCallback)
(*DiskStatusCallback)(3);
/* can return EINVAL if device doesn't support fsync */
if (fsync(outfd) < 0 && errno != EINVAL) {
perror("fsync");
rv = -1;
}
close(outfd);
if (DiskStatusCallback)
(*DiskStatusCallback)(4);
/* XXX don't close it here, wait til UnzipQuit */
}
return(rv);
......@@ -1090,6 +1100,10 @@ ImageUnzipQuit(void)
if (slice && dostype >= 0)
fixmbr(slice, dostype);
/* Now we can close it */
if (outfd >= 0)
close(outfd);
#ifdef WITH_CRYPTO
#ifdef SIGN_CHECKSUM
if (do_checksum)
......@@ -1168,10 +1182,6 @@ threadquit(void)
pthread_join(child_pid, &ignored);
}
#ifdef FRISBEE
extern void (*DiskStatusCallback)(int);
#endif
void *
DiskWriter(void *arg)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment