From: Tomas Krizek Date: Thu, 20 Aug 2020 14:13:43 +0000 (+0200) Subject: daemon/http: immediately set handle to write_req in http_write() X-Git-Tag: v5.2.0~15^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37bbed38850ca91c4658bb16ef7a4b7a3497ceb3;p=thirdparty%2Fknot-resolver.git daemon/http: immediately set handle to write_req in http_write() This seems to be safe to do, since libuv handles tcp write in a very similar way. --- diff --git a/daemon/http.c b/daemon/http.c index 757226a52..c1b7983ef 100644 --- a/daemon/http.c +++ b/daemon/http.c @@ -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;