]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: server: Flush and check output for errors after uncorking.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 17 Feb 2018 13:44:49 +0000 (14:44 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 12 Mar 2018 08:42:26 +0000 (10:42 +0200)
Otherwise, a disconnection event may be missed.

src/lib-http/http-server-response.c

index 1f9c09f04e8b86626361ec3f2b2fce05f4ce59e2..f340ab09bbc082fc4fddf1e25a379d49bac4087c 100644 (file)
@@ -684,8 +684,16 @@ static int http_server_response_send_real(struct http_server_response *resp,
                        http_server_response_finish_payload_out(resp);
                }
        }
-       if (!resp->payload_corked)
-               o_stream_uncork(output);
+       if (ret >= 0 && !resp->payload_corked &&
+           o_stream_uncork_flush(output) < 0) {
+               if (output->stream_errno != EPIPE &&
+                   output->stream_errno != ECONNRESET) {
+                       *error_r = t_strdup_printf("flush(%s) failed: %s",
+                               o_stream_get_name(output),
+                               o_stream_get_error(output));
+               }
+               ret = -1;
+       }
        o_stream_unref(&output);
        return ret;
 }