[erlang-questions] prim_inet:ignorefd/2 affecting erts_poll_wait()

Tony Rogvall tony@REDACTED
Sun Aug 24 21:38:58 CEST 2014

I made a afunix version of the inet driver. You can find it here:


It will register it self as a socket so that afunix/gen_tcp/inet api is available.

The reason I implemented it was the very same reason you had.


On 23 aug 2014, at 03:01, Michael Truog <mjtruog@REDACTED> wrote:

> To be a little clearer, my prim_inet:ignorefd/2 usage is to use a file descriptor created in the inet source code after passing it through gen_tcp:fdopen/2. So, the sequence is:
> ...
> {ok, FileDescriptorInternal} = prim_inet:getfd(Socket),
> ok = prim_inet:ignorefd(Socket, true),
> {ok, NewSocket} = gen_tcp:fdopen(FileDescriptorInternal, SocketOptions),
> ...
> While this might seem odd, this allows me to dup2 the file descriptor without causing obvious problems and handle UNIX domain sockets, which are currently unsupported within inet (by avoiding the internal checking that prevents their use).
> On 08/22/2014 05:46 PM, Michael Truog wrote:
>> I have been seeing the erts_poll_wait() thread consume 100% CPU when my configuration makes prim_inet:ignorefd/2 ignore a fd (inet_descriptor has is_ignored set to true) created external to inet (10 file descriptors created this way).  I don't have this problem when using the inet code to create tcp sockets, when prim_inet:ignorefd/2 is not used with the same configuration. When setting "#define INET_DRV_DEBUG 1" in "./erts/emulator/drivers/common/inet_drv.c" and "#define ERTS_POLL_DEBUG_PRINT" in "./erts/emulator/sys/common/erl_poll.c" all the debugging output looks the same when exercising the file descriptors in the same way.  The only difference seems to be the "Entering erts_poll_wait(), timeout=NUMBER" output has non-zero timeout values more often when prim_inet:ignorefd/2 is not used when compare to the output when it is being used.  Also, the NUMBER doesn't seem to go about 1000 for me when prim_inet:ignorefd/2 is used, but it can go above 1000 when prim_inet:ignorefd/2 is not used.
>> Why would the erts_poll_wait() loop be refusing to timeout?  Is this expected behaviour?  Is there an erts configuration flag which is meant to address the problem?
>> Thanks,
>> Michael
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

"Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140824/a8c21210/attachment.htm>

More information about the erlang-questions mailing list