--- parser3/src/main/pa_http.C 2024/11/23 00:36:40 1.130 +++ parser3/src/main/pa_http.C 2024/12/24 02:58:47 1.132 @@ -14,7 +14,7 @@ #include "pa_vfile.h" #include "pa_random.h" -volatile const char * IDENT_PA_HTTP_C="$Id: pa_http.C,v 1.130 2024/11/23 00:36:40 moko Exp $" IDENT_PA_HTTP_H; +volatile const char * IDENT_PA_HTTP_C="$Id: pa_http.C,v 1.132 2024/12/24 02:58:47 moko Exp $" IDENT_PA_HTTP_H; // defines @@ -1189,11 +1189,12 @@ size_t HTTPD_Connection::read_post(char size_t HTTPD_Connection::send_body(const void *buf, size_t size) { LOG(pa_log("httpd [%d] response %d bytes", sock, size)); LOG(pa_log("httpd [%d] %s", sock, buf)); - if((size=pa_send(sock, (const char*)buf, size)) < 0) { + ssize_t result=pa_send(sock, (const char*)buf, size); + if(result < 0) { int no=pa_socks_errno(); throw Exception("httpd.write", 0, "error sending response: %s (%d)", pa_socks_strerr(no), no); } - return size; + return result; } HTTPD_Connection::~HTTPD_Connection(){ @@ -1203,21 +1204,17 @@ HTTPD_Connection::~HTTPD_Connection(){ } } -static int sock_ready(SOCKET fd, int operation, int timeout_value){ +static int sock_ready(SOCKET fd, int timeout_value){ struct timeval timeout = {0, timeout_value * 1000}; fd_set fds; FD_ZERO(&fds); FD_SET(fd, &fds); int nfds = (int)fd + 1; /* typecast as nfds is ignored in MSVC anyway */ - switch (operation){ - case 0: return select(nfds, &fds, NULL, NULL, &timeout)>0; /* read */ - case 1: return select(nfds, NULL, &fds, NULL, &timeout)>0; /* write */ - default: return select(nfds, &fds, &fds, NULL, &timeout)>0; /* both */ - } + return select(nfds, &fds, NULL, NULL, &timeout)>0; /* read */ } bool HTTPD_Connection::accept(SOCKET server_sock, int timeout_value) { - int ready = sock_ready(server_sock, 0, timeout_value); + int ready = sock_ready(server_sock, timeout_value); if (ready < 0) { int no=pa_socks_errno(); if(no == EINTR)