From 814eec6950bbf5c1dc153d7a767ddd1c61b41510 Mon Sep 17 00:00:00 2001 From: proller Date: Fri, 7 Sep 2018 02:22:04 +0300 Subject: [PATCH 1/2] NEXT_ON_MULTIPLEX --- include/fcgiapp.h | 1 + libfcgi/fcgiapp.c | 2 +- perl/FCGI.pm | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/fcgiapp.h b/include/fcgiapp.h index 07022b1..a901232 100644 --- a/include/fcgiapp.h +++ b/include/fcgiapp.h @@ -82,6 +82,7 @@ typedef char **FCGX_ParamArray; * restarting upon being interrupted. */ #define FCGI_FAIL_ACCEPT_ON_INTR 1 +#define NEXT_ON_MULTIPLEX 2 /* * FCGX_Request -- State associated with a request. diff --git a/libfcgi/fcgiapp.c b/libfcgi/fcgiapp.c index 0f7946c..4e1ed52 100644 --- a/libfcgi/fcgiapp.c +++ b/libfcgi/fcgiapp.c @@ -1531,7 +1531,7 @@ static int ProcessBeginRecord(int requestId, FCGX_Stream *stream) if(requestId == 0 || data->contentLen != sizeof(body)) { return FCGX_PROTOCOL_ERROR; } - if(data->reqDataPtr->isBeginProcessed) { + if(data->reqDataPtr->isBeginProcessed && !(data->reqDataPtr->flags & NEXT_ON_MULTIPLEX)) { /* * The Web server is multiplexing the connection. This library * doesn't know how to handle multiplexing, so respond with diff --git a/perl/FCGI.pm b/perl/FCGI.pm index b1ae3c2..39bb00a 100644 --- a/perl/FCGI.pm +++ b/perl/FCGI.pm @@ -9,6 +9,7 @@ BEGIN { } sub FAIL_ACCEPT_ON_INTR () { 1 }; +sub NEXT_ON_MULTIPLEX () { 2 }; sub Request(;***$*$) { my @defaults = (\*STDIN, \*STDOUT, \*STDERR, \%ENV, 0, FAIL_ACCEPT_ON_INTR); @@ -140,6 +141,13 @@ It not set, it will just keep on waiting. =back +=item FCGI::NEXT_ON_MULTIPLEX + +If set, do not wait message with current requestId, start processing next request +It not set, wait finishing current request with correct requestId - this can produce lot of 500 errors with IIS + +=back + =back Example usage: From 6db1975cb79a854905c2430d1f37749d2d440f2a Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 31 Oct 2018 02:32:51 +0300 Subject: [PATCH 2/2] Also answer error --- libfcgi/fcgiapp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libfcgi/fcgiapp.c b/libfcgi/fcgiapp.c index 4e1ed52..251055a 100644 --- a/libfcgi/fcgiapp.c +++ b/libfcgi/fcgiapp.c @@ -1604,6 +1604,16 @@ static int ProcessHeader(FCGI_Header header, FCGX_Stream *stream) return ProcessManagementRecord(header.type, stream); } if(requestId != data->reqDataPtr->requestId) { + if(data->reqDataPtr->flags & NEXT_ON_MULTIPLEX) { + FCGI_EndRequestRecord endRequestRecord; + endRequestRecord.header = MakeHeader(FCGI_END_REQUEST, requestId, sizeof(endRequestRecord.body), 0); + endRequestRecord.body = MakeEndRequestBody(0, FCGI_CANT_MPX_CONN); + if(write_it_all(data->reqDataPtr->ipcFd, (char *)&endRequestRecord, sizeof(endRequestRecord)) < 0) { + SetError(stream, OS_Errno); + return -1; + } + } + return SKIP; } if(header.type != data->type) {