[distcc] sendfile() not working on tmpfs

Martin Pool mbp at sourcefrog.net
Thu Jun 27 23:21:03 GMT 2002


I think your problem is fixed in CVS HEAD, or by the attached patch.
If you get a chance to try it please let me know.

-- 
Martin 

Index: io.c
===================================================================
RCS file: /data/cvs/distcc/src/io.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -u -r1.30 -r1.31
--- io.c	2002/06/28 01:42:55	1.30
+++ io.c	2002/06/28 06:04:07	1.31
@@ -94,7 +94,7 @@
 #else
     /* Linux or something. */
     off_t offset = 0;
-    return sendfile(ofd, ifd, &offset, size) == size ? 0 : -1;
+    return sendfile(ofd, ifd, &offset, size) == (ssize_t) size ? 0 : -1;
 #endif
 }
 
@@ -102,14 +102,24 @@
 /**
  * Transmit the body of a file using sendfile().
  *
+ * If the sendfile() call fails in a way that makes us think that
+ * regular IO might work, then we try that instead.  For example, the
+ * /tmp filesystem may not support sendfile().
+ *
  * @param ofd Output fd
  * @param ifd Input file (must allow mmap)
  **/
 int dcc_pump_sendfile(int ofd, int ifd, size_t size)
 {
     if (sys_sendfile(ofd, ifd, size)) {
-	rs_log_error("sendfile failed: %s", strerror(errno));
-	return -1;
+        if (errno == ENOSYS || errno == EINVAL) {
+            rs_log_info("sendfile failed, falling back to read/write: %s",
+                        strerror(errno));
+            return dcc_pump_readwrite(ofd, ifd, size);
+        } else {
+            rs_log_error("sendfile failed: %s", strerror(errno));
+            return -1;
+        }
     }
     return 0;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/distcc/attachments/20020627/11a949b1/attachment.bin


More information about the distcc mailing list