]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/http: immediately set handle to write_req in http_write()
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 20 Aug 2020 14:13:43 +0000 (16:13 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 13 Oct 2020 10:55:26 +0000 (12:55 +0200)
This seems to be safe to do, since libuv handles tcp write in
a very similar way.

daemon/http.c

index 757226a524e7ccd219ce428d61e3ad8cf71b333b..c1b7983efba0373b7ea7dffb0cf052953bb908fb 100644 (file)
@@ -462,6 +462,7 @@ int http_write(uv_write_t *req, uv_handle_t *handle, knot_pkt_t *pkt, int32_t st
 
        if (!req || !pkt || !handle || !handle->data || stream_id < 0)
                return kr_error(EINVAL);
+       req->handle = (uv_stream_t *)handle;
 
        session = handle->data;
        if (session_flags(session)->outgoing)
@@ -471,7 +472,6 @@ int http_write(uv_write_t *req, uv_handle_t *handle, knot_pkt_t *pkt, int32_t st
        if (!ctx || !ctx->h2)
                return kr_error(EINVAL);
 
-       req->handle = (uv_stream_t *)handle;  // TODO does this have side effects when write fails?
        ret = http_write_pkt(ctx->h2, pkt, stream_id, req, on_write);
        if (ret < 0)
                return ret;