[distcc] Re: distcc 0.5
Martin Pool
mbp at samba.org
Wed Jun 26 20:43:01 GMT 2002
On 26 Jun 2002, Frerich Raabe <raabe at kde.org> wrote:
Content-Description: clearsigned data
> Hash: SHA1
>
> On Wednesday 26 June 2002 03:56, you wrote:
> > On 25 Jun 2002, Frerich Raabe <raabe at kde.org> wrote:
> > > just wanted to ask you whether you'd drop me a note before you go and
> > > release distcc 0.5.
> >
> > I'm not going to make many more changes before releasing 0.5. I agree
> > with the approach you suggest. Please go ahead and send patches.
>
> Ok, here are the patches which seem to be required to get distcc CVS running
> properly on FreeBSD:
>
> patch-src::io.c - this patch to src/io.c honors the fact that FreeBSD provides
> a sendfile() method as well, but with a different signature. Necessary to
> make it compile.
Well, OK, I can agree that we need to support it, but that patch looks
pretty wierd to me. Unix system calls don't normally return errno
values directly.
Index: io.c
===================================================================
RCS file: /cvsroot/distcc/src/io.c,v
retrieving revision 1.27
diff -u -3 -p -r1.27 io.c
--- io.c 13 Jun 2002 05:14:21 -0000 1.27
+++ io.c 26 Jun 2002 07:26:35 -0000
@@ -72,7 +72,11 @@
**/
int dcc_pump_sendfile(int ofd, int ifd, size_t size)
{
+#ifdef __FreeBSD__
+ if (sendfile(ifd, ofd, 0, size, 0, 0, 0) == EAGAIN) {
+#else
if (sendfile(ofd, ifd, 0, size) != (int) size) {
+#endif
rs_log_error("sendfile failed: %s", strerror(errno));
return -1;
}
I looked in
http://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2&apropos=0&manpath=FreeBSD+5.0-current
and it says that sendfile() returns -1 and sets errno on error; and
returns 0 on success. Also because our sockets are not nonblocking I
don't think we need to handle EAGAIN.
My patch is below, please let me know if it works OK.
--
Martin
--- io.c.~1.27.~ Thu Jun 13 15:14:21 2002
+++ io.c Thu Jun 27 13:40:31 2002
@@ -1,4 +1,4 @@
-/* -*- c-file-style: "k&r"; c-basic-offset: 4; indent-tabs-mode: nil -*-
+/* -*- c-file-style: "java"; indent-tabs-mode: nil -*-
*
* distcc -- A simple distributed compiler system
* $Header: /data/cvs/distcc/src/io.c,v 1.27 2002/06/13 05:14:21 mbp Exp $
@@ -64,6 +64,33 @@
#ifdef HAVE_SENDFILE
/* If you don't have it, just use dcc_pump_readwrite */
+
+/**
+ * Map FreeBSD and Linux into something like the Linux interface.
+ *
+ * Our sockets are never non-blocking, so that seems to me to say that
+ * the kernel will never return EAGAIN -- we will always either send
+ * the whole thing or get an error. Is that really true?
+ *
+ * How nice to have the function parameters reversed between platforms
+ * in a way that will not give a compiler warning.
+ *
+ * @return 0 for success (everything sent); -1 otherwise, with errno set.
+ *
+ * @sa http://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2&apropos=0&manpath=FreeBSD+5.0-current
+ **/
+static int sys_sendfile(int ofd, int ifd, size_t size)
+{
+#ifdef __FreeBSD__
+ return sendfile(ifd, ofd, 0, size, 0, 0, 0);
+#else
+ /* Linux or something. */
+ off_t offset = 0;
+ return sendfile(ofd, ifd, &offset, size) == size ? 0 : -1;
+#endif
+}
+
+
/**
* Transmit the body of a file using sendfile().
*
@@ -72,7 +99,7 @@
**/
int dcc_pump_sendfile(int ofd, int ifd, size_t size)
{
- if (sendfile(ofd, ifd, 0, size) != (int) size) {
+ if (sys_sendfile(ofd, ifd, size)) {
rs_log_error("sendfile failed: %s", strerror(errno));
return -1;
}
-------------- 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/20020626/cad5219e/attachment.bin
More information about the distcc
mailing list