[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-file.c, 1.6, 1.7 mbox-save.c, 1.69, 1.70 mbox-sync.c, 1.130, 1.131

cras at dovecot.org cras at dovecot.org
Fri Dec 17 02:05:57 EET 2004


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv6091/lib-storage/index/mbox

Modified Files:
	mbox-file.c mbox-save.c mbox-sync.c 
Log Message:
Named pipes are now treated as write-only mboxes.



Index: mbox-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-file.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mbox-file.c	3 Oct 2004 12:32:01 -0000	1.6
+++ mbox-file.c	17 Dec 2004 00:05:54 -0000	1.7
@@ -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,

Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- mbox-save.c	15 Dec 2004 21:31:53 -0000	1.69
+++ mbox-save.c	17 Dec 2004 00:05:54 -0000	1.70
@@ -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;
 		}
 	}

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- mbox-sync.c	15 Dec 2004 19:24:11 -0000	1.130
+++ mbox-sync.c	17 Dec 2004 00:05:54 -0000	1.131
@@ -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;



More information about the dovecot-cvs mailing list