aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-08-10 12:17:31 +0200
committerBjörn Gustavsson <[email protected]>2016-08-12 11:59:59 +0200
commitd7984e5f221ccbe8624d18790920038781720bc6 (patch)
tree5b0a15291b7ae84f1f4d9421a6582919ecc436f4
parent1db9e32445dc368c6073e3b412567d81a2b5eeb2 (diff)
downloadotp-d7984e5f221ccbe8624d18790920038781720bc6.tar.gz
otp-d7984e5f221ccbe8624d18790920038781720bc6.tar.bz2
otp-d7984e5f221ccbe8624d18790920038781720bc6.zip
Support 'make -j' when compiling ASN.1 modules
When attempting to build multiple ASN.1 modules in parallel (e.g. by running 'make -j'), the ASN.1 compiler could crash because the names of the .asn1db files clashed. For example, if A.asn1 and B.asn1 both import from C.asn1, the compiler would write a C.asn1db file when compiling A.asn1 and when compiling B.asn1. We can avoid this problem if the compiler only writes the module's own .asn1db file. That is, when compiling A.asn1, the compiler would only write A.asn1db, not C.asn1db. Also, make sure that we make the write atomic by first writing to a temporary file that is then renamed.
-rw-r--r--lib/asn1/src/asn1_db.erl4
-rw-r--r--lib/asn1/src/asn1ct.erl3
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/asn1/src/asn1_db.erl b/lib/asn1/src/asn1_db.erl
index 557eca0ffd..869ea310aa 100644
--- a/lib/asn1/src/asn1_db.erl
+++ b/lib/asn1/src/asn1_db.erl
@@ -106,7 +106,9 @@ loop(#state{parent = Parent, monitor = MRef, table = Table,
loop(State);
{save, OutFile, Mod} ->
[{_,Mtab}] = ets:lookup(Table, Mod),
- ok = ets:tab2file(Mtab, OutFile),
+ TempFile = OutFile ++ ".#temp",
+ ok = ets:tab2file(Mtab, TempFile),
+ ok = file:rename(TempFile, OutFile),
loop(State);
{From, {new, Mod, Erule}} ->
[] = ets:lookup(Table, Mod), %Assertion.
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index dd269f095d..8783b5418d 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -221,9 +221,8 @@ check_pass(#st{code=M,file=File,includes=Includes,
{error,St#st{error=Reason}}
end.
-save_pass(#st{code=M,erule=Erule,dbfile=DbFile}=St) ->
+save_pass(#st{code=M,erule=Erule}=St) ->
ok = asn1ct_check:storeindb(#state{erule=Erule}, M),
- asn1_db:dbsave(DbFile,M#module.name),
{ok,St}.
parse_listing(#st{code=Code,outfile=OutFile0}=St) ->