[dovecot-cvs] dovecot/src/lib ostream-file.c,1.18,1.19

cras at procontrol.fi cras at procontrol.fi
Mon May 19 10:35:04 EEST 2003


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv3247

Modified Files:
	ostream-file.c 
Log Message:
fixes



Index: ostream-file.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ostream-file.c	17 May 2003 09:28:49 -0000	1.18
+++ ostream-file.c	19 May 2003 06:35:02 -0000	1.19
@@ -872,12 +872,22 @@
 	if (offset >= 0) {
 		ostream->offset = offset;
 
-		if (fstat(fd, &st) == 0 &&
-		    (uoff_t)st.st_blksize > fstream->optimal_block_size) {
-			/* use the optimal block size, but with a
-			   reasonable limit */
-			fstream->optimal_block_size =
-				I_MIN(st.st_blksize, MAX_OPTIMAL_BLOCK_SIZE);
+		if (fstat(fd, &st) == 0) {
+			if ((uoff_t)st.st_blksize >
+			    fstream->optimal_block_size) {
+				/* use the optimal block size, but with a
+				   reasonable limit */
+				fstream->optimal_block_size =
+					I_MIN(st.st_blksize,
+					      MAX_OPTIMAL_BLOCK_SIZE);
+			}
+
+			if (S_ISREG(st.st_mode)) {
+				fstream->no_socket_cork = TRUE;
+				fstream->file = TRUE;
+
+				o_stream_set_blocking(ostream, 60000, 0, NULL);
+			}
 		}
 #ifndef HAVE_LINUX_SENDFILE
 		/* only Linux supports sendfile() with non-sockets. Other
@@ -885,14 +895,10 @@
 		   don't bother to even try with them. */
 		fstream->no_sendfile = TRUE;
 #endif
-		fstream->no_socket_cork = FALSE;
-		fstream->file = TRUE;
-
-		o_stream_set_blocking(ostream, 60000, 0, NULL);
 	} else {
 		if (net_getsockname(fd, NULL, NULL) < 0) {
 			fstream->no_sendfile = TRUE;
-			fstream->no_socket_cork = FALSE;
+			fstream->no_socket_cork = TRUE;
 		}
 	}
 	return ostream;



More information about the dovecot-cvs mailing list