File 4101-Use-internal-wildcard-function-from-on_load.patch of Package erlang
From f52029c70fd113e87f628511f555fd4b36a33a92 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Fri, 10 Feb 2023 16:15:42 +0100
Subject: [PATCH] Use internal wildcard function from -on_load
The file server may not be started in embedded mode, so we have
to use our own undocumented option to filelib:wildcard/2
to avoid hanging, waiting fo the file server, in embedded mode...
---
lib/asn1/src/asn1rt_nif.erl | 12 ++++++++----
lib/crypto/src/crypto.erl | 13 +++++++++----
lib/public_key/src/pubkey_os_cacerts.erl | 7 +++++--
lib/runtime_tools/src/dyntrace.erl | 24 +++++++++++++++++++++++-
4 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/lib/asn1/src/asn1rt_nif.erl b/lib/asn1/src/asn1rt_nif.erl
index e724d60bae..753729c810 100644
--- a/lib/asn1/src/asn1rt_nif.erl
+++ b/lib/asn1/src/asn1rt_nif.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2022. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2023. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -47,13 +47,15 @@ load_nif() ->
filename:join(
[PrivDir,
"lib",
- LibTypeName ++ "*"])) /= []) orelse
+ LibTypeName ++ "*"]),
+ erl_prim_loader) /= []) orelse
(filelib:wildcard(
filename:join(
[PrivDir,
"lib",
erlang:system_info(system_architecture),
- LibTypeName ++ "*"])) /= []) of
+ LibTypeName ++ "*"]),
+ erl_prim_loader) /= []) of
true -> LibTypeName;
false -> LibBaseName
end
@@ -66,7 +68,9 @@ load_nif() ->
filename:join([PrivDir, "lib",
erlang:system_info(system_architecture)]),
Candidate =
- filelib:wildcard(filename:join([ArchLibDir,LibName ++ "*" ])),
+ filelib:wildcard(
+ filename:join([ArchLibDir,LibName ++ "*" ]),
+ erl_prim_loader),
case Candidate of
[] -> Error1;
_ ->
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 54fb719a04..69b01e6418 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -2126,13 +2126,15 @@ on_load() ->
filename:join(
[PrivDir,
"lib",
- LibTypeName ++ "*"])) /= []) orelse
+ LibTypeName ++ "*"]),
+ erl_prim_loader) /= []) orelse
(filelib:wildcard(
filename:join(
[PrivDir,
"lib",
erlang:system_info(system_architecture),
- LibTypeName ++ "*"])) /= []) of
+ LibTypeName ++ "*"]),
+ erl_prim_loader) /= []) of
true -> LibTypeName;
false -> LibBaseName
end
@@ -2147,7 +2149,10 @@ on_load() ->
filename:join([PrivDir, "lib",
erlang:system_info(system_architecture)]),
Candidate =
- filelib:wildcard(filename:join([ArchLibDir,LibName ++ "*" ]),erl_prim_loader),
+ filelib:wildcard(
+ filename:join(
+ [ArchLibDir,LibName ++ "*" ]),
+ erl_prim_loader),
case Candidate of
[] -> Error1;
_ ->
diff --git a/lib/public_key/src/pubkey_os_cacerts.erl b/lib/public_key/src/pubkey_os_cacerts.erl
index 61ded6d0cf..93f0e48353 100644
--- a/lib/public_key/src/pubkey_os_cacerts.erl
+++ b/lib/public_key/src/pubkey_os_cacerts.erl
@@ -204,7 +204,10 @@ load_nif() ->
{error, {load_failed, _}}=Error1 ->
Arch = erlang:system_info(system_architecture),
ArchLibDir = filename:join([PrivDir, "lib", Arch]),
- Candidate = filelib:wildcard(filename:join([ArchLibDir,LibName ++ "*" ])),
+ Candidate =
+ filelib:wildcard(
+ filename:join([ArchLibDir,LibName ++ "*" ]),
+ erl_prim_loader),
case Candidate of
[] -> Error1;
_ ->
diff --git a/lib/runtime_tools/src/dyntrace.erl b/lib/runtime_tools/src/dyntrace.erl
index d0861669e7..65a85ddb01 100644
--- a/lib/runtime_tools/src/dyntrace.erl
+++ b/lib/runtime_tools/src/dyntrace.erl
@@ -1,3 +1,23 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2011-2023. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
-module(dyntrace).
%%% @doc The Dynamic tracing interface module
@@ -100,7 +120,9 @@ on_load() ->
filename:join([PrivDir, "lib",
erlang:system_info(system_architecture)]),
Candidate =
- filelib:wildcard(filename:join([ArchLibDir,LibName ++ "*" ])),
+ filelib:wildcard(
+ filename:join([ArchLibDir,LibName ++ "*" ]),
+ erl_prim_loader),
case Candidate of
[] -> Error1;
_ ->
--
2.35.3