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 support for CGI #618

Merged
merged 17 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
detect close of fcgi connection and terminate the CGI process
  • Loading branch information
kazuho committed Dec 9, 2015
commit b8cbd425b848c5685d054062f37ede6d3a32599e
10 changes: 10 additions & 0 deletions misc/fastcgi-cgi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ sub handle_connection {
if $stdout_rfh;
vec($rin, fileno $stderr_rfh, 1) = 1
if $stderr_rfh;
vec($rin, fileno $sock, 1) = 1;
if (select($rin, undef, undef, undef) <= 0) {
next;
}
Expand All @@ -189,6 +190,15 @@ sub handle_connection {
transfer($sock, FCGI_STDERR, $cur_req_id, $stderr_rfh)
or undef $stderr_rfh;
}
if (vec($rin, fileno $sock, 1)) {
# atually means that the client has closed the connection, terminate the CGI process the same way apache does
kill 'TERM', $pid;
$SIG{ALRM} = sub {
kill 'KILL', $pid;
};
alarm 3;
last;
}
}

# close (closing without sending FCGI_END_REQUEST indicates to the client that the connection is not persistent)
Expand Down
10 changes: 10 additions & 0 deletions share/h2o/fastcgi-cgi
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ sub handle_connection {
if $stdout_rfh;
vec($rin, fileno $stderr_rfh, 1) = 1
if $stderr_rfh;
vec($rin, fileno $sock, 1) = 1;
if (select($rin, undef, undef, undef) <= 0) {
next;
}
Expand All @@ -250,6 +251,15 @@ sub handle_connection {
transfer($sock, FCGI_STDERR, $cur_req_id, $stderr_rfh)
or undef $stderr_rfh;
}
if (vec($rin, fileno $sock, 1)) {
# atually means that the client has closed the connection, terminate the CGI process the same way apache does
kill 'TERM', $pid;
$SIG{ALRM} = sub {
kill 'KILL', $pid;
};
alarm 3;
last;
}
}

# close (closing without sending FCGI_END_REQUEST indicates to the client that the connection is not persistent)
Expand Down