src/server/safs/cgi.c

changeset 521
536a2305f3fa
parent 520
0b09f0cb6098
child 522
317cd83fa3df
--- a/src/server/safs/cgi.c	Thu May 23 14:56:33 2024 +0200
+++ b/src/server/safs/cgi.c	Thu May 23 15:11:38 2024 +0200
@@ -308,6 +308,10 @@
 int cgi_stdout_readevent(EventHandler *ev, Event *event) {
     CGIHandler *handler = event->cookie;
     
+    if(handler->debug_finished) {
+        log_ereport(LOG_DEBUG, "cgi-send: req: %p debug_finished: 1 cgi_stdout_readevent events: %d", handler->parser.rq, handler->events);
+    }
+    
     event->finish = cgi_event_finish;
     handler->writeev->finish = NULL;
     CgiIOResult ret = cgi_read_output(handler, ev);
@@ -327,7 +331,6 @@
                 handler->result = REQ_ABORTED;
             } else {
                 handler->poll_out = TRUE;
-                handler->events++;
                 log_ereport(LOG_DEBUG, "cgi-send: req: %p enable poll out", handler->parser->rq);
                 return 1; // keep readevent active
             }
@@ -559,9 +562,16 @@
         event_fn = "stderr";
     } else if(event->fn == cgi_writeevent) {
         event_fn = "httpout";
+        log_ereport(LOG_DEBUG, "cgi-send: req: %p finish: pid: %d", rq, handler->process.pid);
     }
     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(--handler->events > 0) {
+        return 0;
+    }
+    
     if(handler->poll_out) {
         // write event registered, however it will not be activated anymore
         // we can safely remove the event
@@ -569,14 +579,9 @@
         if(event_removepoll(ev, sn->csd)) {
             log_ereport(LOG_FAILURE, "cgi_event_finish: event_removepoll: %s", strerror(errno));
         }
-        handler->events--;
         handler->poll_out = FALSE;
     }
     
-    if(--handler->events > 0) {
-        return 0;
-    }
-    
     /*
     if(--handler->events > 0) {
         if(handler->events == 1) {

mercurial