Avoid ssh_socket_exception_callback: Socket exception callback: 1 (0) warnings from libssh#591
Conversation
Wait until we receiver SSH EOF from the peer, which avoids needlessly printing socket exception callbacks from libssh. 100ms should be more than enough to receive this message, if not just free as before. Also possibly fix some race conditions by locking io_lock before sending the EOF. Fixes #589
|
I understand based on the comments from #589, this fix is done in libnetconf library. |
Yes, you should wait, but honestly it's just the warning logs and it doesn't break anything. But we found out that it is not that simple to remove the warning logs, so it might take a bit longer to finish. |
507eb36 to
718d608
Compare
If we receiver SSH_EOF in nc_write, it means that the peer won't be sending anything anymore, but it can still receive, so we shouldn't fail. This doesn't apply to nc_read, where it's still valid to fail.
Perform SSH connection aliveness check just like with other transports and don't rely on libssh internal state tracking.
When a client DCs, send <close-session> + SSH EOF before waiting for <ok> reply. When server goes to free its session it polls for the SSH_EOF and this avoids socket exception warnings from libssh.
There was a problem hiding this comment.
Pull request overview
This PR updates libnetconf2 session teardown to perform a more graceful SSH/TLS shutdown (including waiting briefly for SSH channel EOF) so that libssh does not emit warnings during normal disconnect cleanup (fixing #589).
Changes:
- Refactors client session free path to send
<close-session>, signal transport shutdown (SSH EOF / TLS close_notify), and optionally wait for the close-session reply. - Adjusts SSH transport cleanup to poll briefly for peer EOF before freeing the SSH channel.
- Improves/clarifies some SSH server-side disconnect error messages and bumps project version.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/session.c |
Introduces new close-session + transport-shutdown sequencing and SSH EOF polling during teardown. |
src/io.c |
Changes SSH “connected” detection to be fd/poll-based and tweaks SSH write checks; adds RPC context validation in nc_write_msg_io(). |
src/session_client.c |
Extracts client message-queue and notification-thread teardown helpers; fixes pthread error reporting; switches RPC send to nc_write_msg_io(). |
src/session_server_ssh.c |
Uses ssh_is_connected() for server-side SSH loops and improves related error messages. |
src/session_p.h |
Adds teardown helper prototypes and a new SSH EOF poll timeout constant. |
CMakeLists.txt |
Increments micro version and SOVERSION micro. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
718d608 to
c3c443b
Compare
Wait until EOF is received from the peer or timeout of 100ms elapses while waiting until the underlying SSH channel is closed. libssh should then update its internal state correctly and not print any warnings about normal disconnects.
Fixes #589