I've been searching for a webserver to do something which I'v e
wanted for a really long time. Namely, an async i/o front-end which
handles persistant connections and output buffering in front of
external CGI (forking or prefork modules).
After some non-success with Boa, I tried mathopd. The code is very
clean and easy to understand!
While mathopd handles CGI and chunking out of the box, for me it does
not allow the persistant connection to stay open after the CGI
finishes. After some investigation, I made the following change which
seems to have fixed the problem. I'm still trying to fully understand
the code, so I'd appreciate comments on whether this is the correct
fix.
Does the fix below look right?
This is a context-diff, but my mailer is likely going to wrap it
badly, so don't try to apply it. Just look at the 3 line change.
------------------------
diff -c -r mathopd-1.5p2/src/stub.c mathopd-1.5p2-jeske/src/stub.c
*** mathopd-1.5p2/src/stub.c Tue Dec 23 02:21:26 2003
--- mathopd-1.5p2-jeske/src/stub.c Mon Mar 22 22:07:50 2004
***************
*** 570,578 ****return;
}
if (pevents & POLLERR || pevents == POLLHUP) {
! close_connection(p);
! return;
}
canwritetoclient = cevents & POLLOUT || p->output.end ==
p->output.floor;
canwritetochild = pevents & POLLOUT || p->client_input.end ==
p->client_input.floor;
if (cevents & POLLIN)
--- 570,586 ----return;
}
if (pevents & POLLERR || pevents == POLLHUP) {
! // close_connection(p);
! // return;
!
! p->script_input.state = 2; // do lastchunk copy!
}
+
canwritetoclient = cevents & POLLOUT || p->output.end ==
p->output.floor;
canwritetochild = pevents & POLLOUT || p->client_input.end ==
p->client_input.floor;
if (cevents & POLLIN)