OTP socket.erl, unexpected interaction when receiving from errqueue
Andreas Schultz
andreas.schultz@REDACTED
Mon Nov 23 17:42:23 CET 2020
Hi,
If setup a socket with:
socket:setopt(Socket, ip, recverr, true)
If then started a asynchronous recvmsg with:
{select, SelectInfo} = socket:recvfrom(Socket, 0, [], nowait)
When now something arrives in the error queue, I'll get a select info
message with:
{'$socket', Socket, select, SelectInfo}
The problem is, nothing in there tells me to read from the error queue. The
underlying OS poll/epoll call would have this information, but it is lost
in the Erlang message.
When I now try to read from the socket with:
socket:recvfrom(Socket, 0, [], nowait)
all I get is another `{select, SelectInfo}` tuple, followed by another
`{'$socket', Socket, select, SelectInfo}` messages.
This can actually end up in an endless busy loop.
To actually clear this I would to do a:
socket:recvmsg(Socket, [errqueue], nowait)
On an POSIX socket, I would have to actually poll for POLLIN | POLLERR to
get a similar behavior. But the return of the poll would tell me whether it
was POLLIN or POLLERR (similar for epoll).
For the Erlang API it might sense to always poll for both conditions, but
we then should get an indication what exactly it was.
Would it be possible to change the $socket message to something like:
{'$socket', Socket, error, SelectInfo}
for POLLERR/EPOLLERR ???
Regards
Andreas
--
Andreas Schultz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20201123/6192f735/attachment.htm>
More information about the erlang-questions
mailing list