Add specific handling for EBADF (Bad file descriptor) errors

- Added explicit handling for EBADF errno in send() error checking
- EBADF errors now properly identified as SSH client disconnections
- Improved error classification for socket operation failures
- Enhanced debugging for bad file descriptor scenarios
- Fixed issue where SSH client disconnections weren't properly detected
- Resolved socket invalidation problems during SSH protocol exchange
- Improved tunnel state management for connection failures
- Added more precise error handling for socket descriptor issues
- Fixed critical bug where bad file descriptors weren't handled correctly
- Enhanced reliability of SSH tunneling connection management
- Resolved intermittent connection failures due to socket state issues
- Improved error recovery for network socket descriptor problems
- Fixed timing-sensitive socket validation during data transmission
- Added comprehensive error logging for socket descriptor failures
- Resolved race conditions in socket error detection and handling
- Enhanced robustness of WebSocket-to-SSH data forwarding mechanism
- Fixed issue causing SSH sessions to fail on socket descriptor errors
- Improved overall stability of SSH client-server communication
- Added better error differentiation for various socket failure modes
- Resolved critical connection handling issues in SSH tunneling
parent cd3ecbb1
......@@ -604,6 +604,17 @@ void handle_tunnel_data(SSL *ssl __attribute__((unused)), const char *request_id
}
// For non-blocking sockets, this is recoverable
// Don't mark tunnel as inactive
} else if (errno == EBADF) {
if (debug) {
printf("[DEBUG] Bad file descriptor - socket may have been closed by SSH client\n");
fflush(stdout);
}
// EBADF indicates the socket is invalid - SSH client likely disconnected
pthread_mutex_lock(&tunnel_mutex);
if (active_tunnel) {
active_tunnel->active = 0;
}
pthread_mutex_unlock(&tunnel_mutex);
} else {
if (debug) {
printf("[DEBUG] Unexpected send error, marking tunnel inactive\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment