aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Lindberg <[email protected]>2012-01-05 14:24:55 +0100
committerAdam Lindberg <[email protected]>2012-02-28 14:59:31 +0100
commitc797ac2ca286b70dae9f78d512631c8fd6522c3c (patch)
tree8e84d2a7b58e93d9c4e494abf9f0699d088a71b6
parentf06de6450bbbd324a0784780d892fa69908a2126 (diff)
downloadotp-c797ac2ca286b70dae9f78d512631c8fd6522c3c.tar.gz
otp-c797ac2ca286b70dae9f78d512631c8fd6522c3c.tar.bz2
otp-c797ac2ca286b70dae9f78d512631c8fd6522c3c.zip
[asn1] Run asn1 compilation in a separate process
-rw-r--r--lib/asn1/src/asn1ct.erl41
1 files changed, 23 insertions, 18 deletions
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index 85bb5b2f28..1507b01d81 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -94,23 +94,28 @@ compile(File,Options) when is_list(Options) ->
Options1 = optimize_ber_bin(Options),
Options2 = includes(File,Options1),
Includes=[I||{i,I}<-Options2],
- case (catch input_file_type(File,Includes)) of
- {single_file,SuffixedFile} -> %% "e.g. "/tmp/File.asn"
- (catch compile1(SuffixedFile,Options2));
- {multiple_files_file,SetBase,FileName} ->
- FileList = get_file_list(FileName,Includes),
-%% io:format("FileList: ~p~n",[FileList]),
- case FileList of
- L when is_list(L) ->
- (catch compile_set(SetBase,FileList,Options2));
- Err ->
- Err
- end;
- Err = {input_file_error,_Reason} ->
- {error,Err};
- Err2 -> Err2
- end.
-
+ Parent = self(),
+ Pid = spawn_link(fun() ->
+ compile_proc(File, Includes, Options2, Parent)
+ end),
+ receive {Pid, Result} -> Result end.
+
+compile_proc(File, Includes, Options, Parent) ->
+ Result = case (catch input_file_type(File, Includes)) of
+ {single_file, SuffixedFile} -> %% "e.g. "/tmp/File.asn"
+ (catch compile1(SuffixedFile, Options));
+ {multiple_files_file, SetBase, FileName} ->
+ case get_file_list(FileName, Includes) of
+ FileList when is_list(FileList) ->
+ (catch compile_set(SetBase, FileList, Options));
+ Err ->
+ Err
+ end;
+ Err = {input_file_error, _Reason} ->
+ {error, Err};
+ Err2 -> Err2
+ end,
+ Parent ! {self(), Result}.
compile1(File,Options) when is_list(Options) ->
verbose("Erlang ASN.1 version ~p compiling ~p ~n",[?vsn,File],Options),