File 2252-Add-tag-to-response-message.patch of Package erlang

From b092f750bd736d4eccf889eba52a5ea6658ffea9 Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Fri, 13 Dec 2019 14:34:31 +0100
Subject: [PATCH 2/2] Add tag to response message

Since users may now inspect the message queue between,
'send_req' and 'wait_response' which may contain the reply message
which is a bit non-descriptive, a tag is added to explain it.

This doesn't mean that the message interface is set in stone or
documented, it can still be changed.
---
 lib/stdlib/src/gen.erl               | 6 +++---
 lib/stdlib/test/gen_server_SUITE.erl | 7 +++++--
 lib/wx/test/wx_basic_SUITE.erl       | 4 ++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/stdlib/src/gen.erl b/lib/stdlib/src/gen.erl
index 34b87e9025..c51ddee011 100644
--- a/lib/stdlib/src/gen.erl
+++ b/lib/stdlib/src/gen.erl
@@ -214,7 +214,7 @@ send_request(Process, Label, Request) ->
 
 do_send_request(Process, Label, Request) ->
     Mref = erlang:monitor(process, Process),
-    erlang:send(Process, {Label, {self(), Mref}, Request}, [noconnect]),
+    erlang:send(Process, {Label, {self(), {'$gen_request_id', Mref}}, Request}, [noconnect]),
     Mref.
 
 %%
@@ -226,7 +226,7 @@ do_send_request(Process, Label, Request) ->
 wait_response(Mref, Timeout)
   when is_reference(Mref) ->
     receive
-        {Mref, Reply} ->
+        {{'$gen_request_id', Mref}, Reply} ->
             erlang:demonitor(Mref, [flush]),
             {reply, Reply};
         {'DOWN', Mref, _, Object, Reason} ->
@@ -240,7 +240,7 @@ wait_response(Mref, Timeout)
 check_response(Msg, Mref)
   when is_reference(Mref) ->
     case Msg of
-        {Mref, Reply} ->
+        {{'$gen_request_id', Mref}, Reply} ->
             erlang:demonitor(Mref, [flush]),
             {reply, Reply};
         {'DOWN', Mref, _, Object, Reason} ->
diff --git a/lib/stdlib/test/gen_server_SUITE.erl b/lib/stdlib/test/gen_server_SUITE.erl
index 788fa5b93c..7c24f60261 100644
--- a/lib/stdlib/test/gen_server_SUITE.erl
+++ b/lib/stdlib/test/gen_server_SUITE.erl
@@ -489,9 +489,12 @@ send_request(Config) when is_list(Config) ->
 
     Promise3 = gen_server:send_request(my_test_name, {call_within, 1000}),
     no_reply = gen_server:check_response({foo, bar}, Promise3),
-    receive {Ref,_} = Msg when is_reference(Ref) ->
+    receive {{'$gen_request_id',Ref},_} = Msg when is_reference(Ref) ->
             {reply, ok} = gen_server:check_response(Msg, Promise3)
-    after 1000 -> exit(api_changed)
+    after 1000 ->
+            %% Format not yet doumented so it might be ok
+            %% This test is just to make you aware that you have changed it
+            exit(message_format_changed)
     end,
     timer:sleep(1500),
 
diff --git a/lib/wx/test/wx_basic_SUITE.erl b/lib/wx/test/wx_basic_SUITE.erl
index 16b531be6c..433b705673 100644
--- a/lib/wx/test/wx_basic_SUITE.erl
+++ b/lib/wx/test/wx_basic_SUITE.erl
@@ -397,11 +397,11 @@ wx_object(Config) ->
     flush(),
     ReqId = wx_object:send_request(Frame, fun(_US) -> timer:sleep(10), yes end),
     timeout = wx_object:wait_response(ReqId, 0),
-    {reply, {call, yes, {Me,ReqId}}} = wx_object:wait_response(ReqId, 1000),
+    {reply, {call, yes, {Me,{_,ReqId}}}} = wx_object:wait_response(ReqId, 1000),
     ReqId2 = wx_object:send_request(Frame, yes),
     [Msg] = flush(),
     no_reply = wx_object:check_response(Msg, ReqId),
-    {reply, {call, yes, {Me,ReqId2}}} = wx_object:check_response(Msg, ReqId2),
+    {reply, {call, yes, {Me,{_,ReqId2}}}} = wx_object:check_response(Msg, ReqId2),
 
     FramePid = wx_object:get_pid(Frame),
     io:format("wx_object pid ~p~n",[FramePid]),
-- 
2.16.4

openSUSE Build Service is sponsored by