Removing unnecessary FD duplication prevents EMFILE errors. Signed-off-by: Gao Xiang <hsiang...@linux.alibaba.com> --- lib/compress.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/compress.c b/lib/compress.c index 73554d6..2bafb0e 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -1720,7 +1720,6 @@ int erofs_mt_write_compressed_file(struct z_erofs_compress_ictx *ictx) ret = erofs_commit_compressed_file(ictx, bh, pstart - ptotal, ptotal); out: - close(ictx->fd); free(ictx); return ret; } @@ -1791,13 +1790,12 @@ void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos) pthread_mutex_unlock(&g_ictx.mutex); #endif ictx = &g_ictx; - ictx->fd = fd; } else { ictx = malloc(sizeof(*ictx)); if (!ictx) return ERR_PTR(-ENOMEM); - ictx->fd = dup(fd); } + ictx->fd = fd; ictx->ccfg = &sbi->zmgr->ccfg[inode->z_algorithmtype[0]]; inode->z_algorithmtype[0] = ictx->ccfg->algorithmtype; -- 2.43.5