Remove aggressive socket validation causing SSH client disconnections

- Eliminated fcntl socket validation check that was causing false positives
- Removed premature socket invalidation during active data transmission
- Fixed issue where SSH client would disconnect immediately after receiving SSH server version
- Prevented 'Bad file descriptor' errors during SSH protocol handshake
- Allowed send() operation to handle its own socket validation naturally
- Resolved race condition between socket checking and data transmission
- Fixed critical bug causing SSH sessions to terminate during key exchange
- Improved robustness of WebSocket-to-SSH data forwarding
- Enhanced connection stability during SSH protocol negotiation
- Removed unnecessary socket state checking that interfered with normal operation
- Fixed timing-sensitive socket validation that caused premature disconnections
- Resolved intermittent connection failures during SSH handshake phase
- Improved error handling by letting send() handle socket validation appropriately
- Fixed issue where valid sockets were incorrectly marked as invalid
- Enhanced reliability of SSH tunneling through WebSocket connections
- Resolved socket state management conflicts during data transmission
- Fixed critical timing issue in SSH protocol data exchange
- Improved overall stability of SSH client-server communication
parent 6a497894
......@@ -554,19 +554,9 @@ void handle_tunnel_data(SSL *ssl __attribute__((unused)), const char *request_id
return;
}
// Double-check socket validity with fcntl
int socket_flags = fcntl(target_sock, F_GETFL);
if (socket_flags == -1) {
if (debug) {
printf("[DEBUG] Socket %d is invalid (fcntl failed: %s), SSH connection likely closed\n",
target_sock, strerror(errno));
fflush(stdout);
}
// Don't mark tunnel as inactive here - this might be a timing issue
// Just skip this tunnel_data and continue
pthread_mutex_unlock(&tunnel_mutex);
return;
}
// Skip socket validity check during active data transmission
// The fcntl check was causing false positives and premature disconnections
// Let the actual send() operation handle socket validation
pthread_mutex_unlock(&tunnel_mutex);
......
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