File 0468-kernel-Fix-race-when-closing-delayed-and-compressed-.patch of Package erlang

From 93ca3c1def97b5e8fcde5f82393f03671f9641bb Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Tue, 20 Aug 2019 09:36:06 +0200
Subject: [PATCH] kernel: Fix race when closing delayed and compressed files

If two file:close commands are issues after each other it is possible
for the second command to actually setup the monitor and then get
a normal DOWN instead of the expected noproc. Both error codes mean that
the file has already been closed to we return einval.
---
 lib/kernel/src/raw_file_io_compressed.erl | 1 +
 lib/kernel/src/raw_file_io_delayed.erl    | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/kernel/src/raw_file_io_compressed.erl b/lib/kernel/src/raw_file_io_compressed.erl
index d5ab042d25..f6ac6eaffc 100644
--- a/lib/kernel/src/raw_file_io_compressed.erl
+++ b/lib/kernel/src/raw_file_io_compressed.erl
@@ -123,6 +123,7 @@ wrap_call(Fd, Command) ->
     try gen_statem:call(Pid, Command, infinity) of
         Result -> Result
     catch
+        exit:{normal, _StackTrace} -> {error, einval};
         exit:{noproc, _StackTrace} -> {error, einval}
     end.
 
diff --git a/lib/kernel/src/raw_file_io_delayed.erl b/lib/kernel/src/raw_file_io_delayed.erl
index d2ad7550a1..5644717aaa 100644
--- a/lib/kernel/src/raw_file_io_delayed.erl
+++ b/lib/kernel/src/raw_file_io_delayed.erl
@@ -309,6 +309,7 @@ wrap_call(Fd, Command) ->
     try gen_statem:call(Pid, Command, infinity) of
         Result -> Result
     catch
+        exit:{normal, _StackTrace} -> {error, einval};
         exit:{noproc, _StackTrace} -> {error, einval}
     end.
 
-- 
2.16.4

openSUSE Build Service is sponsored by