diff --git a/lib/core-net/wsi-timeout.c b/lib/core-net/wsi-timeout.c index 5b882ba41..e95e84805 100644 --- a/lib/core-net/wsi-timeout.c +++ b/lib/core-net/wsi-timeout.c @@ -156,7 +156,9 @@ lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs) if (secs == LWS_TO_KILL_ASYNC) secs = 0; - assert(!secs || !wsi->h2_stream_immortal); + // assert(!secs || !wsi->h2_stream_immortal); + if (secs && wsi->h2_stream_immortal) + lwsl_err("%s: on immortal stream %d %d\n", __func__, reason, secs); lws_pt_lock(pt, __func__); __lws_set_timeout(wsi, reason, secs); diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c index 3513bbcf9..0940d2f9c 100644 --- a/lib/roles/cgi/cgi-server.c +++ b/lib/roles/cgi/cgi-server.c @@ -925,22 +925,6 @@ agin: n = lws_get_socket_fd(wsi->http.cgi->stdwsi[LWS_STDOUT]); if (n < 0) return -1; - if (m) { - uint8_t term[LWS_PRE + 6]; - - lwsl_info("%s: zero chunk\n", __func__); - - memcpy(term + LWS_PRE, (uint8_t *)"0\x0d\x0a\x0d\x0a", 5); - - if (lws_write(wsi, term + LWS_PRE, 5, - LWS_WRITE_HTTP_FINAL) != 5) - return -1; - - wsi->http.cgi->cgi_transaction_over = 1; - - return 0; - } - n = read(n, start, sizeof(buf) - LWS_PRE); if (n < 0 && errno != EAGAIN) { @@ -948,7 +932,8 @@ agin: return -1; } if (n > 0) { -/* + // lwsl_hexdump_notice(buf, n); + if (!wsi->http2_substream && m) { char chdr[LWS_HTTP_CHUNK_HDR_SIZE]; m = lws_snprintf(chdr, LWS_HTTP_CHUNK_HDR_SIZE - 3, @@ -958,7 +943,7 @@ agin: memcpy(start + m + n, "\x0d\x0a", 2); n += m + 2; } - */ + #if defined(LWS_WITH_HTTP2) if (wsi->http2_substream) { @@ -986,6 +971,23 @@ agin: } wsi->http.cgi->content_length_seen += n; } else { + + if (m) { + uint8_t term[LWS_PRE + 6]; + + memcpy(term + LWS_PRE, (uint8_t *)"0\x0d\x0a\x0d\x0a", 5); + + if (lws_write(wsi, term + LWS_PRE, 5, + LWS_WRITE_HTTP_FINAL) != 5) + return -1; + + wsi->http.cgi->cgi_transaction_over = 1; + + return 0; + } + + + if (wsi->cgi_stdout_zero_length) { lwsl_debug("%s: stdout is POLLHUP'd\n", __func__); if (wsi->http2_substream)