[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] socket: do not enable POLLOUT for empty out buffer
[Thread Prev] | [Thread Next]
- Subject: Re: [PATCH] socket: do not enable POLLOUT for empty out buffer
- From: Nikolay <nitro@xxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 2 Aug 2017 17:14:45 +0200
- To: libssh@xxxxxxxxxx
Thank you, Aris.
No problem, as I understand you're using revents as a kind of a flag to detect when the output buffer is totally empty. It's not exactly how it was designed :)
= No, I do understand that POLLOUT is either a connect-attempt-finished or outgoing-buffer-available event. This is why I suppose the patch - in my mind we don't need to wait for POLLOUT if we have already passed all the data to send(). I do not quite understand the reason why we need to wait for POLLOUT unconditionally...
POLLOUT will only mean that there is space available in output buffer.But I do not analyze revent value in socket callback function. I simply check if session is established and do ssh_channel_select() or ssh_connect()/ssh_auth...() otherwise.
I'm not sure I fully understand the sequence of actions here. Are we somewhere in (backtrace) ssh_event_dopoll() ____ssh_socket_event_callback() ________ssh_channel_select()
= Yes, backtrace seems like the one I have in mind.
Are the parameters to these functions SSH sessions? Because if so you may enter in reentrancy zone and you may have unexpected results.
= I only pass session socket to ssh_event_dopoll().But you are possibly correct, as ssh_channel_select() seems to be working with the channels' sessions' sockets.
The best way to handle the spurious POLLOUT is to add the current ssh session into an ssh_event LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session); and then call ssh_event_dopoll() with timeout=0 I'm not sure how it would fit into your architecture though. Maybe you should use the channel callbacks instead of ssh_channel_select() inside of global socket callbacks.
Yes, I did try to use ssh_event_add_session() and set some callbacks.But I strongly need it all to work in non-blocking mode. But the documentation for ssh_event_add_session() says: > remove the poll handle from session and assign them to a event, when used in *blocking mode*
I think it's the reason I failed with using ssh_event_add_session() and session callbacks. I did get some SIGSEGV during those experiments.
I'm connecting in the following way: if (session_not_connected && ssh_connect() == SSH_AGAIN)return to eventloop and wait for event on session socket, then run ssh_connect() again
My thread should not block in waiting for particular socket/session/channel I/O. I should be able to connect to multiple ssh server in non-blocking async mode.
Best regards, Nikolay Karikh
Attachment:
smime.p7s
Description: Криптографическая подпись S/MIME
Re: [PATCH] socket: do not enable POLLOUT for empty out buffer | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
[PATCH] socket: do not enable POLLOUT for empty out buffer | Nikolay <nitro@xxxxxxxxxxx> |
Re: [PATCH] socket: do not enable POLLOUT for empty out buffer | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
Re: [PATCH] socket: do not enable POLLOUT for empty out buffer | Nikolay <nitro@xxxxxxxxxxx> |
Re: [PATCH] socket: do not enable POLLOUT for empty out buffer | Aris Adamantiadis <aris@xxxxxxxxxxxx> |