For FCGI_END_REQUEST reset the clt struct similar to what is done in the
authorclaudio <claudio@openbsd.org>
Mon, 15 Aug 2022 10:29:03 +0000 (10:29 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 15 Aug 2022 10:29:03 +0000 (10:29 +0000)
file and other cases. Especially when the session uses keep-alive it is
important to set TOREAD_HTTP_HEADER so that the state machine knows what's
next.
OK op@

usr.sbin/httpd/server_fcgi.c

index e29ad99..2e5e647 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: server_fcgi.c,v 1.93 2022/08/12 08:40:25 claudio Exp $        */
+/*     $OpenBSD: server_fcgi.c,v 1.94 2022/08/15 10:29:03 claudio Exp $        */
 
 /*
  * Copyright (c) 2014 Florian Obser <florian@openbsd.org>
@@ -584,12 +584,24 @@ server_fcgi_read(struct bufferevent *bev, void *arg)
                                    ((struct http_descriptor *)
                                    clt->clt_descreq)->http_method
                                    == HTTP_METHOD_HEAD)
-                                       break;
-                               if (server_fcgi_writechunk(clt) == -1) {
+                                       /* nothing */ ;
+                               else if (server_fcgi_writechunk(clt) == -1) {
                                        server_abort_http(clt, 500,
                                            "encoding error");
                                        return;
                                }
+                               if (clt->clt_fcgi.type == FCGI_END_REQUEST) {
+                                       bufferevent_enable(clt->clt_bev,
+                                           EV_READ|EV_WRITE);
+                                       if (clt->clt_persist)
+                                               clt->clt_toread =
+                                                   TOREAD_HTTP_HEADER;
+                                       else
+                                               clt->clt_toread =
+                                                   TOREAD_HTTP_NONE;
+                                       clt->clt_done = 0;
+                                       server_reset_http(clt);
+                               }
                                break;
                        }
                        evbuffer_drain(clt->clt_srvevb,