Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0272-Use-monitor-ref-for-all-iterations.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0272-Use-monitor-ref-for-all-iterations.patch of Package erlang
From 71a52d970623e6fba2f8eba6bc49bc06fe782ada Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Wed, 24 Apr 2024 11:25:10 +0200 Subject: [PATCH 2/2] Use monitor ref for all iterations --- erts/preloaded/ebin/prim_inet.beam | Bin 102468 -> 102432 bytes erts/preloaded/src/prim_inet.erl | 33 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/erts/preloaded/src/prim_inet.erl b/erts/preloaded/src/prim_inet.erl index 8e0ecf0a72..77171c0f04 100644 --- a/erts/preloaded/src/prim_inet.erl +++ b/erts/preloaded/src/prim_inet.erl @@ -562,24 +562,26 @@ peeloff(S, AssocId) -> %% NOT delegating this task to any back-end. For SCTP, this function MUST NOT %% be called directly -- use "sendmsg" instead: %% +send(S, Data) -> + send(S, Data, []). + send(S, Data, OptList) when is_port(S), is_list(OptList) -> ?DBG_FORMAT("prim_inet:send(~p, _, ~p)~n", [S,OptList]), - send(S, Data, OptList, monitor(port, S), make_ref()). - -send(S, Data, OptList, Mref, Sref) -> - SrefBin = term_to_binary(Sref, [local]), - SrefBinSize = byte_size(SrefBin), - SrefBinSize = SrefBinSize band 16#FFFF, - try - erlang:port_command( - S, [<<SrefBinSize:16,SrefBin/binary>>, Data], OptList) - of + Mref = monitor(port, S), + MrefBin = term_to_binary(Mref, [local]), + MrefBinSize = byte_size(MrefBin), + MrefBinSize = MrefBinSize band 16#FFFF, + HdrAndData = [<<MrefBinSize:16,MrefBin/binary>>, Data], + send(S, HdrAndData, OptList, Mref). + +send(S, HdrAndData, OptList, Mref) -> + try erlang:port_command(S, HdrAndData, OptList) of false -> % Port busy when nosuspend option was passed ?DBG_FORMAT("prim_inet:send() -> {error,busy}~n", []), {error,busy}; true -> receive - {inet_reply,S,Sref} -> + {inet_reply,S,Mref} -> %% This causes a wait even though nosuspend was used. %% It only happens when the OS send operation returns %% that it would block, which should only happen @@ -593,15 +595,15 @@ send(S, Data, OptList, Mref, Sref) -> "prim_inet:send(~p,,,) Waiting~n", [S]), receive - {inet_reply,S,ok,Sref} -> - send(S, Data, OptList, Mref, make_ref()); + {inet_reply,S,ok,Mref} -> + send(S, HdrAndData, OptList, Mref); {'DOWN',Mref,_,_,_Reason} -> ?DBG_FORMAT( "prim_inet:send(~p,,,) 'DOWN' ~p~n", [S,_Reason]), {error,closed} end; - {inet_reply,S,Status,Sref} -> + {inet_reply,S,Status,Mref} -> demonitor(Mref, [flush]), Status; {'DOWN',Mref,_,_,_Reason} -> @@ -615,9 +617,6 @@ send(S, Data, OptList, Mref, Sref) -> {error,einval} end. -send(S, Data) -> - send(S, Data, []). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% SENDTO(insock(), IP, Port, Data) -> ok | {error, Reason} -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor