stop cgi read-event processing if an error occured

Sun, 02 Jun 2024 16:02:36 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 02 Jun 2024 16:02:36 +0200
changeset 532
d8212d4f24f2
parent 531
9b15b1f72bef
child 533
2d6099ba2a7c

stop cgi read-event processing if an error occured

src/server/safs/cgi.c file | annotate | diff | comparison | revisions
--- a/src/server/safs/cgi.c	Sun Jun 02 14:28:17 2024 +0200
+++ b/src/server/safs/cgi.c	Sun Jun 02 16:02:36 2024 +0200
@@ -313,7 +313,7 @@
         log_ereport(LOG_DEBUG, "cgi-send: req: %p debug_finished: 1 cgi_stdout_readevent events: %d", handler->parser->rq, handler->events);
     }
     
-    if(handler->cgi_eof) {
+    if(handler->cgi_eof || handler->result == REQ_ABORTED) {
         // cgi_eof will be set to true by cgi_read_output
         // if it is true here, the cgi handling was finished by cgi_writeevent
         // in that case, cgi_writeevent will finish the request processing
@@ -358,8 +358,8 @@
 int cgi_writeevent(EventHandler *ev, Event *event) {
     CGIHandler *handler = event->cookie;
     
-    if(handler->cgi_eof) {
-        log_ereport(LOG_DEBUG, "cgi-send: req: %p writeevent cgi_eof = TRUE", handler->parser->rq);
+    if(handler->cgi_eof || handler->result == REQ_ABORTED) {
+        log_ereport(LOG_DEBUG, "cgi-send: req: %p writeevent cgi_eof = TRUE result: %d", handler->parser->rq, handler->result);
     }
     
     event->finish = cgi_event_finish;
@@ -582,6 +582,9 @@
     log_ereport(LOG_DEBUG, "cgi-send: req: %p finish: event: %d pollout: %d wait_read: %d cgi_eof: %d fn: %s", rq, handler->events, handler->poll_out, handler->wait_read, handler->cgi_eof, event_fn);
     
     handler->debug_finished = TRUE;
+    if(event->fn != cgi_stderr_readevent) {
+        handler->cgi_eof = TRUE;
+    }
     
     if(handler->result == REQ_ABORTED && handler->process.pid != 0 && handler->cgi_kill == 0) {
         log_ereport(LOG_FAILURE, "cgi-send: kill script: %s pid: %d", handler->path, (int)handler->process.pid);

mercurial