Add timeout to response reading to prevent hanging on wsssht

- Use select with 10-second timeout in response read loop
- Prevents proxy threads from hanging indefinitely waiting for data
parent 07d6e9b0
...@@ -596,7 +596,25 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss ...@@ -596,7 +596,25 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
// Read response from wsssht daemon and forward to client // Read response from wsssht daemon and forward to client
char buffer[8192]; char buffer[8192];
ssize_t total_sent = 0; ssize_t total_sent = 0;
fd_set read_fds;
struct timeval tv;
while (1) { while (1) {
FD_ZERO(&read_fds);
FD_SET(tunnel_fd, &read_fds);
tv.tv_sec = 10; // 10 second timeout
tv.tv_usec = 0;
int activity = select(tunnel_fd + 1, &read_fds, NULL, NULL, &tv);
if (activity < 0) {
if (errno == EINTR) continue;
break;
}
if (activity == 0) {
// Timeout
printf("[WEB-PROXY] Timeout waiting for response from wsssht\n");
break;
}
ssize_t bytes_recv; ssize_t bytes_recv;
if (use_ssl) { if (use_ssl) {
bytes_recv = SSL_read(tunnel_ssl, buffer, sizeof(buffer)); bytes_recv = SSL_read(tunnel_ssl, buffer, sizeof(buffer));
......
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