zic on multi-processor systems

Hi, the following patch will improve the usability of zic in environments with multiple processors (or make running several processes). We are in this situation in GNU libc. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -u gnu/glibc/time/zic.c:1.1.1.4 gnu/glibc/time/zic.c:1.2 --- gnu/glibc/time/zic.c:1.1.1.4 Wed Jan 22 06:58:14 1997 +++ gnu/glibc/time/zic.c Sun Feb 2 12:02:29 1997 @@ -2126,8 +2126,11 @@ if (!itsdir(name)) { /* ** It doesn't seem to exist, so we try to create it. + ** Double check the return. Someone may be one + ** step ahead of us. */ - if (mkdir(name, 0755) != 0) { + if (mkdir(name, 0755) != 0 && !itsdir(name)) + { const char *e = strerror(errno); (void) fprintf(stderr, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks, -- Uli ---------------. drepper@cygnus.com ,-. Rubensstrasse 5 Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany Cygnus Solutions `--' drepper@gnu.ai.mit.edu `------------------------

Urlich Drepper's recent patch has a minor problem: the call to itsdir() can reset the errno so that a misleading message may be reported for a mkdir() failure; I propose the following patch instead: --- zic.c.orig Mon Jan 20 16:02:25 1997 +++ zic.c Sun Feb 2 15:15:41 1997 @@ -2126,15 +2126,20 @@ if (!itsdir(name)) { /* ** It doesn't seem to exist, so we try to create it. + ** Double check the return. Someone may be one + ** step ahead of us. */ if (mkdir(name, 0755) != 0) { - const char *e = strerror(errno); + int sverr = errno; + if (!itsdir(name)) { + const char *e = strerror(sverr); - (void) fprintf(stderr, - _("%s: Can't create directory %s: %s\n"), - progname, name, e); - ifree(name); - return -1; + (void) fprintf(stderr, + _("%s: Can't create directory %s: %s\n"), + progname, name, e); + ifree(name); + return -1; + } } } *cp = '/'; Due to reindentation of a block that looks uglier than it really is; for human consumption, here is the patch again, but using the "-b" option to diff: if (!itsdir(name)) { /* ** It doesn't seem to exist, so we try to create it. + ** Double check the return. Someone may be one + ** step ahead of us. */ if (mkdir(name, 0755) != 0) { + int sverr = errno; + if (!itsdir(name)) { const char *e = strerror(errno); (void) fprintf(stderr, _("%s: Can't create directory %s: %s\n"), progname, name, e); ifree(name); return -1; + } } } --Ken Pizzini
participants (2)
-
Ken Pizzini
-
Ulrich Drepper