Skip to content

Commit

Permalink
Allow bowtie2 to continue trying after partial writes, use perror for…
Browse files Browse the repository at this point in the history
… write errors for better debugging
  • Loading branch information
ch4rr0 committed Apr 21, 2024
1 parent 2c91155 commit f08f26f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions filebuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,16 +951,27 @@ class OutFileBuf {
static void writeAsync(AsyncData *asyncDataPtr) {
AsyncData &asyncData = *asyncDataPtr;
bool abort = false;
size_t written = 0;
while(!abort) {
abort = asyncData.waitForBuf();
if(abort) break;
if(asyncData.cur != fwrite((const void *)asyncData.buf, 1, asyncData.cur, asyncData.out)) {
while (asyncData.cur != 0) {
written += fwrite((const void *)(asyncData.buf + written), 1, asyncData.cur, asyncData.out);
if (errno == EPIPE) {
exit(EXIT_SUCCESS);
}
std::cerr << "Error while flushing and closing output" << std::endl;
throw 1;
if (feof(asyncData.out) || written == 0)
break;
// asyncData.buf += written;
asyncData.cur -= written;
written = 0;
}

if (written != asyncData.cur) {
// std::cerr << "Error while flushing and closing output" << std::endl;
perror("fwrite");
throw 1;
}
abort = asyncData.writeComplete();
}

Expand Down

0 comments on commit f08f26f

Please sign in to comment.