From: Heng Li Date: Fri, 11 May 2012 02:03:54 +0000 (-0400) Subject: bugfix: bgzf-mt may write prematured output X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=9f851f04b857a43aea38b32ef891572266e10669 bugfix: bgzf-mt may write prematured output --- diff --git a/bgzf.c b/bgzf.c index 7254fa2..880d5af 100644 --- a/bgzf.c +++ b/bgzf.c @@ -401,7 +401,7 @@ static int worker_aux(worker_t *w) w->errcode = 0; for (i = w->i; i < w->mt->curr; i += w->mt->n_threads) { int clen = BGZF_MAX_BLOCK_SIZE; - if (bgzf_compress(w->buf, &clen, w->mt->blk[i], w->mt->len[i], w->fp->compress_level) != 0) + if (bgzf_compress(w->buf, &clen, w->mt->blk[i], w->mt->len[i], w->fp->compress_level) != 0) w->errcode |= BGZF_ERR_ZLIB; memcpy(w->mt->blk[i], w->buf, clen); w->mt->len[i] = clen; @@ -502,7 +502,7 @@ static int mt_flush(BGZF *fp) static int mt_lazy_flush(BGZF *fp) { mtaux_t *mt = (mtaux_t*)fp->mt; - mt_queue(fp); + if (fp->block_offset) mt_queue(fp); if (mt->curr == mt->n_blks) return mt_flush(fp); return -1;