-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement non blocking cgi #362
Implement non blocking cgi #362
Conversation
…s also the PID of the child process
… go back where we read the buffer with the response and we send it
@552020 It does not compile according to GitHub actions Ubuntu |
… possible 500 from the CGI
…GI don't wait and read the CGI output but pass the fd of the pipe to the resoponse object
…ildResponse/buildCGIResponse
…m-multiple-sockets tests(Dockerfile): upload Dockerfile for multi socket and upload Dock…
@lmangall Stefano and I made it work!! Now we have proper CGI timeout and it is non-blocking! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Did you test after I left?
We were testing in the main therefore it was failing. But I didn't test the branch, soon to be main. |
Nice, great job ! |
Did you test with the "parallel CGI" test ? |
I tried but we have some issues: https://linear.app/web-serv/issue/WEB-330/cgi-bug-in-main-%F0%9F%9A%A8 |
If you want to take a look at the code, this is a first draft, it compiles, and most of the logic is there.
The only part is missing is when the CGI returns successfully (or not). We will not wait in executeCGI anymore but we will wait in startPollEventLoop: the wait in executeCGI has not been removed yet. After the CGI returned successfully in startPollEventLoop, where we wait for all processes (-1) without blocking (WNOHANG), we go back to poll, the event we listen for for that connection will be POLLOUT. And then we need a flag like CGIhasFinished. We already collect the exitStatus of the CGI which is set in the Connection object.
The code to read the buffer written by the CGI is in handleConnection > buildResponse > routeRequest > handleRequest > executeCGI. We should re-enter handleConnection and buildResponse, but skip the whole logic we already executed the first time we entered it to execute the CGI. Alternatively we could also pass the fd of the pipe when we execute _connection.addCGI(pid); but this is dirtier.
I don't know if you @lmangall has capacity to think about it. I guess with a flag like _CGIhasTerminated (which means it has been executed or kill) we could skip all the unnecessary part of the code, and come to the point where we check the status and read from the buffer. Probably the first step should be just split executeCGI in two function: executeCGI and processExecutedCGI (or something like this), where we read from the buffer or depending on the status code we send back some error.