]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Don't close file we appended to if we're still reading from it.
authorTimo Sirainen <tss@iki.fi>
Thu, 5 Mar 2009 21:37:44 +0000 (16:37 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 5 Mar 2009 21:37:44 +0000 (16:37 -0500)
--HG--
branch : HEAD

src/lib-storage/index/dbox/dbox-map.c

index faa80d84cee21bda284fdae510f22e0c400d61c6..d06d846dff68e24c710704d9ab8dfa2c26242c13 100644 (file)
@@ -482,11 +482,13 @@ dbox_map_find_appendable_file(struct dbox_map_append_context *ctx,
                }
                /* can't append to this file anymore */
                if (files[i-1]->fd != -1) {
-                       /* avoid wasting fds by closing the file */
+                       /* avoid wasting fds by closing the file, but not if
+                          we're also reading from it. */
                        if (dbox_file_flush_append(files[i-1]) < 0)
                                return -1;
                        dbox_file_unlock(files[i-1]);
-                       dbox_file_close(files[i-1]);
+                       if (files[i-1]->refcount == 1)
+                               dbox_file_close(files[i-1]);
                }
        }
        ctx->files_nonappendable_count = count;