--- parser3/src/targets/cgi/parser3.C 2020/12/31 19:48:47 1.342 +++ parser3/src/targets/cgi/parser3.C 2021/12/22 21:52:49 1.346 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.342 2020/12/31 19:48:47 moko Exp $"; +volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.346 2021/12/22 21:52:49 moko Exp $"; #include "pa_config_includes.h" @@ -77,7 +77,7 @@ static void pa_log(const char* fmt, va_l if(!opened && filespec_4log) { char beside_config_path[MAX_STRING]; - strncpy(beside_config_path, filespec_4log, MAX_STRING-1); beside_config_path[MAX_STRING-1]=0; + pa_strncpy(beside_config_path, filespec_4log, MAX_STRING); if(!(rsplit(beside_config_path, '/') || rsplit(beside_config_path, '\\'))) { // strip filename // no path, just filename strcpy(beside_config_path, "."); @@ -186,7 +186,7 @@ static void full_disk_path(const char* f || file_name[0] && file_name[1]==':' #endif ){ - strncpy(buf, file_name, buf_size-1); buf[buf_size-1]=0; + pa_strncpy(buf, file_name, buf_size); } else { char cwd[MAX_STRING]; snprintf(buf, buf_size, "%s/%s", getcwd(cwd, MAX_STRING) ? cwd : "", file_name); @@ -378,11 +378,8 @@ static void *connection_thread(void *arg static void httpd_mode() { config_handler(*sapiInfo); - int sock = HTTPD_Server::bind(httpd_host_port); + SOCKET sock = HTTPD_Server::bind(httpd_host_port); -#ifdef SIGCHLD - signal(SIGCHLD, SIG_IGN); -#endif #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif @@ -390,10 +387,12 @@ static void httpd_mode() { while(1){ #ifndef _MSC_VER pid_t pid=1; + if(HTTPD_Server::mode == HTTPD_Server::PARALLEL) + while (waitpid((pid_t)(-1), 0, WNOHANG) > 0); #endif try { HTTPD_Connection connection; - if(!connection.accept(sock, 5)) + if(!connection.accept(sock, 500)) continue; switch (HTTPD_Server::mode) { @@ -401,7 +400,7 @@ static void httpd_mode() { #ifdef _MSC_VER if (!GC_CreateThread(0, 0, connection_thread, new HTTPD_Connection(connection), 0, 0)) throw Exception("httpd.fork", 0, "thread creation failed"); - connection.sock = -1; + connection.sock=INVALID_SOCKET; break; #else #ifdef HAVE_TLS @@ -412,7 +411,7 @@ static void httpd_mode() { if(int result=GC_pthread_create(&thread, &attr, connection_thread, new HTTPD_Connection(connection))) throw Exception("httpd.fork", 0, "thread creation failed (%d)", result); - connection.sock=-1; + connection.sock=INVALID_SOCKET; break; #endif case HTTPD_Server::PARALLEL: