Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2022-10-28 19:56:09 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2022-10-29 20:34:05 +0300
commitd3d63cecbb295ea476edeb75f0d7ca1d507085e5 (patch)
treed98d48ba86f314487540a9cfe06a4369c7fc1a89 /newlib/doc
parent9b89811c9fc0cc859c8d43a5a162e5fe8cc1ff2c (diff)
makedocbook: Add explicit locking for PLY parser table generation
Drop 'makedocbook --cache' (any dependency on the man-cache rule which invokes that was dropped by the non-recursive make changes) Instead, add some explicit locking which prevents processes colliding over the file containing generated python code for the parser table.
Diffstat (limited to 'newlib/doc')
-rw-r--r--newlib/doc/Makefile.inc5
-rwxr-xr-xnewlib/doc/makedocbook.py16
2 files changed, 11 insertions, 10 deletions
diff --git a/newlib/doc/Makefile.inc b/newlib/doc/Makefile.inc
index 630681c88..d2c26a13b 100644
--- a/newlib/doc/Makefile.inc
+++ b/newlib/doc/Makefile.inc
@@ -14,11 +14,6 @@ doc/makedoc.o: doc/makedoc.c
$(MKDIR_P) doc
$(CC_FOR_BUILD) -g $(CFLAGS_FOR_BUILD) -o $@ -c $<
-man-cache:
- ${srcdir}/doc/makedocbook.py --cache
-
-PHONY += man-cache
-
#
# Subdir documentation rules.
#
diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py
index 66481a672..4e83ab63a 100755
--- a/newlib/doc/makedocbook.py
+++ b/newlib/doc/makedocbook.py
@@ -22,7 +22,9 @@
from __future__ import print_function
+import fcntl
import sys
+import os
import re
from optparse import OptionParser
import lxml.etree
@@ -796,7 +798,15 @@ def p_error(t):
print('parse error at line %d, token %s, next token %s' % (t.lineno, t, parser.token()), file=sys.stderr)
exit(1)
-parser = yacc.yacc(start='input')
+# protect creating the parser with a lockfile, so that when multiple processes
+# are running this script simultaneously, we don't get one of them generating a
+# parsetab.py file, while another one attempts to read it...
+#
+# see also https://github.com/dabeaz/ply/pull/184
+with open(os.path.join(os.path.dirname(__file__), 'parsetab.lock'), 'w+') as lockfile:
+ fcntl.flock(lockfile.fileno(), fcntl.LOCK_EX)
+ parser = yacc.yacc(start='input')
+ fcntl.flock(lockfile.fileno(), fcntl.LOCK_UN)
#
#
@@ -829,12 +839,8 @@ def main(file):
if __name__ == '__main__' :
options = OptionParser()
options.add_option('-v', '--verbose', action='count', dest = 'verbose', default = 0)
- options.add_option('-c', '--cache', action='store_true', dest = 'cache', help="just ensure PLY cache is up to date")
(opts, args) = options.parse_args()
- if opts.cache:
- sys.exit()
-
verbose = opts.verbose
if len(args) > 0: