diff --git a/src/posixos.c b/src/posixos.c index 44aeb346..3d7d6614 100644 --- a/src/posixos.c +++ b/src/posixos.c @@ -167,12 +167,12 @@ jobserver_setup (int slots, const char *style) hang until the write side is open. */ EINTRLOOP (job_fds[0], open (fifo_name, O_RDONLY|O_NONBLOCK)); if (job_fds[0] < 0) - OSS (fatal, NILF, _("Cannot open jobserver %s: %s"), + OSS (fatal, NILF, _("cannot open jobserver %s: %s"), fifo_name, strerror (errno)); EINTRLOOP (job_fds[1], open (fifo_name, O_WRONLY)); if (job_fds[0] < 0) - OSS (fatal, NILF, _("Cannot open jobserver %s: %s"), + OSS (fatal, NILF, _("cannot open jobserver %s: %s"), fifo_name, strerror (errno)); js_type = js_fifo; @@ -183,7 +183,7 @@ jobserver_setup (int slots, const char *style) if (js_type == js_none) { if (style && strcmp (style, "pipe") != 0) - OS (fatal, NILF, _("Unknown jobserver auth style '%s'"), style); + OS (fatal, NILF, _("unknown jobserver auth style '%s'"), style); EINTRLOOP (r, pipe (job_fds)); if (r < 0) @@ -229,14 +229,19 @@ jobserver_parse_auth (const char *auth) EINTRLOOP (job_fds[0], open (fifo_name, O_RDONLY)); if (job_fds[0] < 0) - OSS (fatal, NILF, - _("Cannot open jobserver %s: %s"), fifo_name, strerror (errno)); + { + OSS (error, NILF, + _("cannot open jobserver %s: %s"), fifo_name, strerror (errno)); + return 0; + } EINTRLOOP (job_fds[1], open (fifo_name, O_WRONLY)); - if (job_fds[0] < 0) - OSS (fatal, NILF, - _("Cannot open jobserver %s: %s"), fifo_name, strerror (errno)); - + if (job_fds[1] < 0) + { + OSS (error, NILF, + _("cannot open jobserver %s: %s"), fifo_name, strerror (errno)); + return 0; + } js_type = js_fifo; } /* If not, it must be a simple pipe. */ diff --git a/src/w32/w32os.c b/src/w32/w32os.c index 9c5dec24..213bbf12 100644 --- a/src/w32/w32os.c +++ b/src/w32/w32os.c @@ -216,12 +216,12 @@ jobserver_setup (int slots, const char *style) /* sub_proc.c is limited in the number of objects it can wait for. */ if (style && strcmp (style, "sem") != 0) - OS (fatal, NILF, _("Unknown jobserver auth style '%s'"), style); + OS (fatal, NILF, _("unknown jobserver auth style '%s'"), style); if (slots > process_table_usable_size()) { slots = process_table_usable_size(); - DB (DB_JOBS, (_("Jobserver slots limited to %d\n"), slots)); + DB (DB_JOBS, (_("jobserver slots limited to %d\n"), slots)); } sprintf (jobserver_semaphore_name, "gmake_semaphore_%d", _getpid ()); @@ -255,10 +255,12 @@ jobserver_parse_auth (const char *auth) { DWORD err = GetLastError (); const char *estr = map_windows32_error_to_string (err); - fatal (NILF, strlen (auth) + INTSTR_LENGTH + strlen (estr), - _("internal error: unable to open jobserver semaphore '%s': (Error %ld: %s)"), + error (NILF, strlen (auth) + INTSTR_LENGTH + strlen (estr), + _("unable to open jobserver semaphore '%s': (Error %ld: %s)"), auth, err, estr); + return 0; } + DB (DB_JOBS, (_("Jobserver client (semaphore %s)\n"), auth)); return 1; diff --git a/tests/scripts/features/jobserver b/tests/scripts/features/jobserver index 8ecbe345..e12facf0 100644 --- a/tests/scripts/features/jobserver +++ b/tests/scripts/features/jobserver @@ -14,6 +14,7 @@ if (!$parallel_jobs) { # Shorthand my $np = '--no-print-directory'; +my $j1err = "warning: jobserver unavailable: using -j1. Add '+' to parent make rule."; # Simple test of MAKEFLAGS settings run_make_test(q! @@ -90,7 +91,7 @@ if ($port_type ne 'W32') { default: ; @ #MAKEPATH# -f Makefile2 !, "--jobserver-style=pipe -j2 $np", -"#MAKE#[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. +"#MAKE#[1]: $j1err #MAKE#[1]: Nothing to be done for 'foo'."); rmfiles('Makefile2'); @@ -98,15 +99,15 @@ default: ; @ #MAKEPATH# -f Makefile2 # For Windows and named pipes, we don't need to worry about recursion if ($port_type eq 'W32' || exists $FEATURES{'jobserver-fifo'}) { - create_file('Makefile2', "vpath %.c ../\n", "foo:\n"); + create_file('Makefile2', "vpath %.c ../\n", "foo:\n"); - run_make_test(q! + run_make_test(q! default: ; @ #MAKEPATH# -f Makefile2 !, "-j2 $np", "#MAKE#[1]: Nothing to be done for 'foo'."); - rmfiles('Makefile2'); + rmfiles('Makefile2'); } # Ensure enter/leave directory messages appear before jobserver warnings @@ -129,17 +130,17 @@ all: a all a: ; @echo $@ !, '--jobserver-style=foo -j8', - "#MAKE#: *** Unknown jobserver auth style 'foo'. Stop.", 512); + "#MAKE#: *** unknown jobserver auth style 'foo'. Stop.", 512); -# sv 62908. -# Test that when mkfifo fails, make switches to pipe and succeeds. -# Force mkfifo to fail by attempting to create a fifo in a non existent -# directory. -# run_make_test does not allow matching a multiline pattern, therefore run the -# test twice. -# First time look for /$ERR_no_such_file/ to ensure mkfifo failed. -# Second time look for /Nothing to be done/ to ensure make succeeded. if (exists $FEATURES{'jobserver-fifo'}) { + # sv 62908. + # Test that when mkfifo fails, make switches to pipe and succeeds. + # Force mkfifo to fail by attempting to create a fifo in a non existent + # directory. + # run_make_test does not allow matching a multiline pattern, therefore run + # the test twice. + # First time look for /$ERR_no_such_file/ to ensure mkfifo failed. + # Second time look for /Nothing to be done/ to ensure make succeeded. $ENV{TMPDIR} = "nosuchdir"; run_make_test("all:\n", '-j2', "/$ERR_no_such_file/"); @@ -155,6 +156,10 @@ recurse: ; @$(MAKE) -f #MAKEFILE# all all:;@echo "$$MAKEFLAGS" !, "-j2 --no-print-directory", "/--jobserver-auth=fifo:\\./"); + + # Verify we fall back to -j1 but continue, of the auth is bad. + $ENV{MAKEFLAGS} = '-j2 --jobserver-auth=fifo:nosuchfile'; + run_make_test(q!all:;@echo hi!, "", "#MAKE#: cannot open jobserver nosuchfile: $ERR_no_such_file\n#MAKE#: $j1err\nhi\n"); } 1;