-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
I'm trying to use Transport:controlling_process(Sock, NewPid) inside process spawned by esockd:open(..., MFArgs), but it fails when using UDP with badarg. Sock argument is from
esockd/examples/udp/udp_echo_server.erl
Lines 34 to 35 in d0c3edc
| loop(Transport = {udp, Server, Sock}, Peer = {IP, Port}) -> | |
| receive |
It seems that gen_udp:controlling_process is not implemented.
esockd/src/esockd_transport.erl
Lines 89 to 96 in d0c3edc
| -spec(controlling_process(socket(), pid()) -> ok | {error, Reason} when | |
| Reason :: closed | not_owner | badarg | inet:posix()). | |
| controlling_process(Sock, NewOwner) when is_port(Sock) -> | |
| gen_tcp:controlling_process(Sock, NewOwner); | |
| controlling_process(#ssl_socket{ssl = SslSock}, NewOwner) -> | |
| ssl:controlling_process(SslSock, NewOwner); | |
| controlling_process(#proxy_socket{socket = Sock}, NewOwner) -> | |
| controlling_process(Sock, NewOwner); |
I can't simply use gen_udp:controlling_process() as workaround since socket is in a different process (error current process is not the owner of the socket)
I think we could fix it by updating the Pid assigned to a Peer with an exported function.
Lines 273 to 278 in d0c3edc
| handle_info({udp, Sock, IP, InPortNo, Packet}, | |
| State = #state{sock = Sock, peers = Peers, access_rules = Rules}) -> | |
| case maps:find(Peer = {IP, InPortNo}, Peers) of | |
| {ok, Pid} -> | |
| Pid ! {datagram, self(), Packet}, | |
| {noreply, State}; |
Metadata
Metadata
Assignees
Labels
No labels