From: Tomas Krizek Date: Fri, 14 Aug 2020 12:18:58 +0000 (+0200) Subject: daemon/http: rename struct http_ctx X-Git-Tag: v5.2.0~15^2~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2111c4d3f1e1ec2d13fbde0740e85820f2b3addc;p=thirdparty%2Fknot-resolver.git daemon/http: rename struct http_ctx --- diff --git a/daemon/http.c b/daemon/http.c index 60d444f11..f62fab143 100644 --- a/daemon/http.c +++ b/daemon/http.c @@ -41,13 +41,13 @@ struct http_data_buffer { static ssize_t send_callback(nghttp2_session *session, const uint8_t *data, size_t length, int flags, void *user_data) { - struct http_ctx_t *ctx = (struct http_ctx_t *)user_data; + struct http_ctx *ctx = (struct http_ctx *)user_data; return ctx->send_cb(data, length, ctx->user_ctx); } static int header_callback(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, uint8_t flags, void *user_data) { - struct http_ctx_t *ctx = (struct http_ctx_t *)user_data; + struct http_ctx *ctx = (struct http_ctx *)user_data; static const char key[] = "dns="; int32_t stream_id = frame->hd.stream_id; @@ -89,7 +89,7 @@ static int header_callback(nghttp2_session *session, const nghttp2_frame *frame, /* This method is called for data received via POST. */ static int data_chunk_recv_callback(nghttp2_session *session, uint8_t flags, int32_t stream_id, const uint8_t *data, size_t len, void *user_data) { - struct http_ctx_t *ctx = (struct http_ctx_t *)user_data; + struct http_ctx *ctx = (struct http_ctx *)user_data; if (ctx->incomplete_stream) { if (queue_len(ctx->streams) <= 0) { @@ -129,7 +129,7 @@ static int data_chunk_recv_callback(nghttp2_session *session, uint8_t flags, int static int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { - struct http_ctx_t *ctx = (struct http_ctx_t *)user_data; + struct http_ctx *ctx = (struct http_ctx *)user_data; if ((frame->hd.flags & NGHTTP2_FLAG_END_STREAM) && ctx->buf_pos != 0) { ctx->incomplete_stream = false; @@ -149,7 +149,7 @@ static int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame return 0; } -struct http_ctx_t* http_new(http_send_callback cb, void *user_ctx) +struct http_ctx* http_new(http_send_callback cb, void *user_ctx) { assert(cb != NULL); @@ -160,7 +160,7 @@ struct http_ctx_t* http_new(http_send_callback cb, void *user_ctx) nghttp2_session_callbacks_set_on_data_chunk_recv_callback(callbacks, data_chunk_recv_callback); nghttp2_session_callbacks_set_on_frame_recv_callback(callbacks, on_frame_recv_callback); - struct http_ctx_t *ctx = calloc(1UL, sizeof(struct http_ctx_t)); + struct http_ctx *ctx = calloc(1UL, sizeof(struct http_ctx)); ctx->send_cb = cb; ctx->user_ctx = user_ctx; queue_init(ctx->streams); @@ -181,7 +181,7 @@ struct http_ctx_t* http_new(http_send_callback cb, void *user_ctx) ssize_t http_process_input_data(struct session *s, const uint8_t *in_buf, ssize_t in_buf_len) { - struct http_ctx_t *http_p = session_http_get_server_ctx(s); + struct http_ctx *http_p = session_http_get_server_ctx(s); if (!http_p->session) { return kr_error(ENOSYS); } @@ -230,7 +230,7 @@ int http_write(uv_write_t *req, uv_handle_t *handle, int32_t stream_id, knot_pkt } struct session *s = handle->data; - struct http_ctx_t *http_ctx = session_http_get_server_ctx(s); + struct http_ctx *http_ctx = session_http_get_server_ctx(s); assert (http_ctx); assert (!session_flags(s)->outgoing); @@ -279,7 +279,7 @@ int http_write(uv_write_t *req, uv_handle_t *handle, int32_t stream_id, knot_pkt return kr_ok(); } -void http_free(struct http_ctx_t *ctx) +void http_free(struct http_ctx *ctx) { if (ctx == NULL || ctx->session == NULL) { return; diff --git a/daemon/http.h b/daemon/http.h index 87c89463a..fe9cfeac8 100644 --- a/daemon/http.h +++ b/daemon/http.h @@ -21,7 +21,7 @@ typedef ssize_t(*http_send_callback)(const uint8_t *buffer, const size_t buffer_ typedef queue_t(int32_t) queue_int32_t; -struct http_ctx_t { +struct http_ctx { struct nghttp2_session *session; http_send_callback send_cb; void *user_ctx; @@ -33,7 +33,7 @@ struct http_ctx_t { ssize_t buf_size; }; -struct http_ctx_t* http_new(http_send_callback cb, void *user_ctx); +struct http_ctx* http_new(http_send_callback cb, void *user_ctx); ssize_t http_process_input_data(struct session *s, const uint8_t *buf, ssize_t nread); int http_write(uv_write_t *req, uv_handle_t *handle, int32_t stream_id, knot_pkt_t *pkt, uv_write_cb cb); -void http_free(struct http_ctx_t *ctx); +void http_free(struct http_ctx *ctx); diff --git a/daemon/io.c b/daemon/io.c index a49607ba4..65d2cf1f4 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -442,7 +442,7 @@ static void _tcp_accept(uv_stream_t *master, int status, bool tls, bool http) } } if (http) { - struct http_ctx_t *ctx = session_http_get_server_ctx(s); + struct http_ctx *ctx = session_http_get_server_ctx(s); if (!ctx) { if (!tls) { // TODO plain HTTP not supported yet session_close(s); diff --git a/daemon/session.c b/daemon/session.c index 92890eb83..978230483 100644 --- a/daemon/session.c +++ b/daemon/session.c @@ -36,7 +36,7 @@ struct session { struct tls_ctx *tls_ctx; /**< server side tls-related data. */ struct tls_client_ctx *tls_client_ctx; /**< client side tls-related data. */ - struct http_ctx_t *http_ctx; /**< server side http-related data. */ + struct http_ctx *http_ctx; /**< server side http-related data. */ trie_t *tasks; /**< list of tasks assotiated with given session. */ queue_t(struct qr_task *) waiting; /**< list of tasks waiting for sending to upstream. */ @@ -291,12 +291,12 @@ struct tls_common_ctx *session_tls_get_common_ctx(const struct session *session) return tls_ctx; } -struct http_ctx_t *session_http_get_server_ctx(const struct session *session) +struct http_ctx *session_http_get_server_ctx(const struct session *session) { return session->http_ctx; } -void session_http_set_server_ctx(struct session *session, struct http_ctx_t *ctx) +void session_http_set_server_ctx(struct session *session, struct http_ctx *ctx) { session->http_ctx = ctx; } diff --git a/daemon/session.h b/daemon/session.h index e71653fb3..22a86e90f 100644 --- a/daemon/session.h +++ b/daemon/session.h @@ -97,9 +97,9 @@ void session_tls_set_client_ctx(struct session *session, struct tls_client_ctx * struct tls_common_ctx *session_tls_get_common_ctx(const struct session *session); /** Get pointer to server-side http-related data. */ -struct http_ctx_t *session_http_get_server_ctx(const struct session *session); +struct http_ctx *session_http_get_server_ctx(const struct session *session); /** Set pointer to server-side http-related data. */ -void session_http_set_server_ctx(struct session *session, struct http_ctx_t *ctx); +void session_http_set_server_ctx(struct session *session, struct http_ctx *ctx); /** Get pointer to underlying libuv handle for IO operations. */ uv_handle_t *session_get_handle(struct session *session); diff --git a/daemon/worker.c b/daemon/worker.c index 5a54e4947..47817b4da 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -300,7 +300,7 @@ static struct request_ctx *request_create(struct worker_ctx *worker, req->qsource.flags.http = session_flags(session)->has_http; req->qsource.stream_id = -1; if (req->qsource.flags.http) { - struct http_ctx_t *http_ctx = session_http_get_server_ctx(session); + struct http_ctx *http_ctx = session_http_get_server_ctx(session); // TODO maybe assert? if (http_ctx && queue_len(http_ctx->streams) > 0) { req->qsource.stream_id = queue_head(http_ctx->streams);