--- parser3/src/targets/cgi/parser3.C 2026/10/28 01:17:38 1.389 +++ parser3/src/targets/cgi/parser3.C 2026/10/30 17:15:10 1.391 @@ -5,7 +5,7 @@ Authors: Konstantin Morshnev , Alexandr Petrosian */ -volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.389 2026/10/28 01:17:38 moko Exp $"; +volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.391 2026/10/30 17:15:10 moko Exp $"; #include "pa_config_includes.h" @@ -20,6 +20,7 @@ volatile const char * IDENT_PARSER3_C="$ #include "pa_code_cache.h" #include "pa_websocket.h" #include "pa_os.h" +#include "pa_exec.h" #ifdef _MSC_VER #include @@ -332,6 +333,11 @@ private: if(!timeout) return; +#ifndef _MSC_VER + if(pa_exec_active_pid) + kill(-pa_exec_active_pid, SIGKILL); // kill the whole process group so nothing is left orphaned +#endif + if(timeout->expired && timeout->kill_process){ // the request is still running after the grace period pa_log_at(timeout->stamp, "response timeout (%d s) exceeded, process killed", timeout->seconds); @@ -462,6 +468,10 @@ static void reject_connection(HTTPD_Conn SAPI_Info_HTTPD info(connection); SAPI::send_error(info, "too many connections", "503"); + + // closing the socket with unread request resets the connection and the response can be lost: non-blocking reading for what has arrived + char buf[4096]; + for(int i=0; i<16 && pa_sock_ready(connection.sock, false, 0)>0 && connection.receive(buf, sizeof(buf)); i++); } static void httpd_mode() {