Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag NEXT_ON_MULTIPLEX #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/fcgiapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 11 additions & 1 deletion libfcgi/fcgiapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions perl/FCGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down