# HG changeset patch # User Timo Sirainen # Date 1103241954 -7200 # Node ID 51a05fd0032427d1c42f7e4474acd5df3a7b8208 # Parent f1e67917a669f33dfd666cbd383bc7c65480cb7a Named pipes are now treated as write-only mboxes. diff -r f1e67917a669 -r 51a05fd00324 src/lib-storage/index/mbox/mbox-file.c --- a/src/lib-storage/index/mbox/mbox-file.c Thu Dec 16 22:41:15 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-file.c Fri Dec 17 02:05:54 2004 +0200 @@ -33,6 +33,7 @@ return -1; } + ibox->mbox_writeonly = S_ISFIFO(st.st_mode); ibox->mbox_fd = fd; ibox->mbox_dev = st.st_dev; ibox->mbox_ino = st.st_ino; @@ -62,7 +63,10 @@ return -1; } - if (ibox->mail_read_mmaped) { + if (ibox->mbox_writeonly) { + ibox->mbox_file_stream = + i_stream_create_from_data(default_pool, NULL, 0); + } else if (ibox->mail_read_mmaped) { ibox->mbox_file_stream = i_stream_create_mmap(ibox->mbox_fd, default_pool, MAIL_MMAP_BLOCK_SIZE, diff -r f1e67917a669 -r 51a05fd00324 src/lib-storage/index/mbox/mbox-save.c --- a/src/lib-storage/index/mbox/mbox-save.c Thu Dec 16 22:41:15 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-save.c Fri Dec 17 02:05:54 2004 +0200 @@ -68,6 +68,11 @@ char ch; int fd; + if (ctx->ibox->mbox_writeonly) { + *offset = 0; + return 0; + } + fd = ctx->ibox->mbox_fd; if (fstat(fd, &st) < 0) return mbox_set_syscall_error(ctx->ibox, "fstat()"); @@ -146,6 +151,11 @@ size_t len; int ret = 0; + if (ctx->ibox->mbox_writeonly) { + /* we can't seek, don't set Content-Length */ + return 0; + } + end_offset = ctx->output->offset; /* write Content-Length headers */ @@ -541,9 +551,10 @@ &ctx->next_uid, sizeof(ctx->next_uid)); } - if (!ctx->synced && ctx->ibox->mbox_fd != -1) { + if (!ctx->synced && ctx->ibox->mbox_fd != -1 && + !ctx->ibox->mbox_writeonly) { if (fdatasync(ctx->ibox->mbox_fd) < 0) { - mbox_set_syscall_error(ctx->ibox, "fsync()"); + mbox_set_syscall_error(ctx->ibox, "fdatasync()"); ret = -1; } } diff -r f1e67917a669 -r 51a05fd00324 src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Thu Dec 16 22:41:15 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Fri Dec 17 02:05:54 2004 +0200 @@ -1403,7 +1403,8 @@ } } - if (ret == 0 && ibox->mbox_lock_type == F_WRLCK) { + if (ret == 0 && ibox->mbox_lock_type == F_WRLCK && + !ibox->mbox_writeonly) { if (fsync(ibox->mbox_fd) < 0) { mbox_set_syscall_error(ibox, "fsync()"); ret = -1;