[distcc] Do not allow localhost compile

Jean Delvare khali at linux-fr.org
Wed Jun 1 20:10:56 GMT 2005


Hi all,

[Martin Pool]
> Although that patch should probably be merged, and might help, I don't
> think it has any effect on when cc1plus runs on localhost, which was the
> original question.  That will basically be either when delegation
> fails, or when there is a compiler option that can't be distributed.

The former case could probably be improved by trying to redistribute to
a different host rather than falling back to localhost (which we have no
real reason to do, that I can see). I think this was discussed already
on this list, but I don't remember anyone proposing a patch to do this.
I have been giving it a try, patch is attached (against the latest Arch
version of distcc). Seems to work just fine for me, I would appreciate
if others could try it, especially people which are actually interested
in this feature. Comments would be very welcome too, of course.

Thanks,
-- 
Jean Delvare
-------------- next part --------------
--- orig/src/compile.c
+++ mod/src/compile.c
@@ -118,6 +118,7 @@
     int cpu_lock_fd;
     int ret;
     struct dcc_hostdef *host = NULL;
+    int retrying = 0;
 
     if (sg_level)
         goto run_local;
@@ -135,6 +136,7 @@
     dcc_note_state(DCC_PHASE_STARTUP, input_fname, NULL);
 #endif
 
+  retry:
     if ((ret = dcc_pick_host_from_list(&host, &cpu_lock_fd)) != 0) {
         /* Doesn't happen at the moment: all failures are masked by
            returning localhost. */
@@ -146,11 +148,17 @@
          * need to lock it now. */
         goto run_local;
 
-    if ((ret = dcc_cpp_maybe(argv, input_fname, &cpp_fname, &cpp_pid) != 0))
-        goto fallback;
+    if (retrying) {
+        /* No need to preprocess the same file again. Same for stripping
+         * the local args, it was done already. */
+        cpp_pid = 0;
+    } else {
+        if ((ret = dcc_cpp_maybe(argv, input_fname, &cpp_fname, &cpp_pid) != 0))
+            goto fallback;
 
-    if ((ret = dcc_strip_local_args(argv, &argv_stripped)))
-        goto fallback;
+        if ((ret = dcc_strip_local_args(argv, &argv_stripped)))
+            goto fallback;
+    }
 
     /* FIXME: argv_stripped is leaked. */
 
@@ -183,12 +191,13 @@
         return ret;
     }
 
-    /* "You guys are so lazy!  Do I have to do all the work myself??" */
     if (host) {
         rs_log(RS_LOG_WARNING|RS_LOG_NONAME,
-               "failed to distribute %s to %s, running locally instead",
+               "failed to distribute %s to %s, trying another host instead",
                input_fname ? input_fname : "(unknown)",
                host->hostdef_string);
+        retrying = 1;
+        goto retry;
     } else {
         rs_log_warning("failed to distribute, running locally instead");
     }


More information about the distcc mailing list