[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] socket: do not enable POLLOUT for empty out buffer


Hi Aris,

Sorry, may be I'm wrong with this patch and didn't quite understand the purpose of this function.

But I'm currently encountering a problem when working with libssh in async non-blocking mode.
I have multiple ssh connections and I do polling in the following way:

while (1) {
  // adding ssh session sockets to eventloop
  // with events taken from ssh_get_poll_flags()
  // also operating with my other sockets here
  ssh_event_dopoll(eventloop, timeout)
  // removing ssh session sockets from eventloop
}

In ssh socket event callback:
if (revents != 0) {
  if (!session_connected_and_authorized) {
    call_ssh_connect_or_auth_again();
  } else {
    ssh_channel_select(session channels for read, write and except);
    // open/exec/close on channels of this session
  }
}

The problem is that when I close the last channel in session, ssh_channel_close() sends a packet with ssh_socket_unbuffered_write() and enabled POLLOUT on this session socket. Then my program gets stuck in socket event callback getting POLLOUT over and over again. Because the session have no channels now, ssh_channel_exec() doesn't do anything with session socket and it keeps receiving POLLOUT event. May be you know any hint how to avoid this? Except creating a dummy channel :-)
Or may be I'm doing it all wrong?

Thank you in advance!


Best regards, Nikolay Karikh.


Hi Nikolay,

Thanks for your patch. Is there a particular reason it had to be
changed? The current behavior of the POLLOUT is to avoid a poll() call
when sending a new packet. I think the new behavior will force buffering
+ return to the main loop + poll() + send() instead of send() + main
loop + poll() + main loop again. It can look nasty in debug logs but I
think it's better for latency.

Aris



Attachment: smime.p7s
Description: Криптографическая подпись S/MIME


Follow-Ups:
Re: [PATCH] socket: do not enable POLLOUT for empty out bufferAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org