On 10/23/26 2:22 PM, Ilya Maximets wrote:
> On 10/23/26 8:34 AM, 이규영 wrote:
>> On 10/22/26 Ilya Maximets wrote:
>>> While the old code suggested that the select.poll() can be used as a
>>> drop-in replacement, it is not really the case, it seems.  The problem
>>> is that a second select.poll.register() call overwrites the event
>>> flags for the file descriptor.  So, if we first register for POLLOUT
>>> and then for POLLIN, then we will not actually wait for POLLOUT, which
>>> may be a problem on a congested connection where the application will
>>> never wake up to send if there is nothing to receive.
>>>
>>> We may need to have a separate class similar to the _SelectSelect to
>>> accumulate the flags and only actually register in the poll() call
>>> itself when we have all the event flags.
>>>
>>> WDYT?
>>
>> Thanks, Ilya, good catch, and thanks, Terry, for testing.
>>
>> You're right.  With a bare select.poll, registering POLLOUT and then
>> POLLIN on the same fd leaves only POLLIN, and Idl.wait() does exactly
>> that when the jsonrpc connection has output pending: Session.wait()
>> ends up in send_wait() and Session.recv_wait() follows.  I could
>> reproduce it with a socketpair: a Poller waiting for POLLOUT and then
>> POLLIN on the writable end, with a 2 second timer, sleeps the full 2
>> seconds instead of waking up right away.
>>
>> I have a v4 ready with a small class that keeps the accumulated mask
>> per fd, the way poll_fd_wait() does in lib/poll-loop.c.  It registers
>> the merged mask on every register() call rather than deferring it to
>> poll().  select.poll only builds the pollfd array when poll() is called,
>> so the result is the same and the class stays a bit simpler.  Does that
>> work for you, or would you rather have it the other way?  I'll send v4
>> once we agree on it.
> 
> There is also another issue.  The file descriptors are never actually
> unregistered, AFAICT.  This may cause the poll() to error out on every
> call if the registered fd gets closed.  The API doesn't expect the
> persistence.  We may need to unregister all descriptors after each call...

Ah, nevermind.  The Poller object calls reset and creates a new poll
object after every block().  So, that already unregisters everything.
Sorry for the noise.

> 
>>
>> Terry, since the code changes, I won't carry your Acked-by and
>> Tested-by over to v4.  The same problem is also in the workaround that
>> went into neutron, I'll fix it there as well.
>>
>> Best regards,
>> Kyuyeong
> 

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to