]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/http: rename struct http_ctx
authorTomas Krizek <tomas.krizek@nic.cz>
Fri, 14 Aug 2020 12:18:58 +0000 (14:18 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 13 Oct 2020 10:55:24 +0000 (12:55 +0200)
daemon/http.c
daemon/http.h
daemon/io.c
daemon/session.c
daemon/session.h
daemon/worker.c

index 60d444f112f05d5502829321cf6d42d6c73031a9..f62fab143d9528d1e560835daa7bb51a9b2084ab 100644 (file)
@@ -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;
index 87c89463aa6275ae468df0e2cbba334daa24f84d..fe9cfeac8d01b94b9aaaed6e66c26e5650612bd5 100644 (file)
@@ -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);
index a49607ba46bac4769a92d37ebacdcdeed788e4e5..65d2cf1f4a1416533e76b05f9bc30780b23cdfc0 100644 (file)
@@ -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);
index 92890eb8371f93c74c5cb4938b308767510b4e3e..978230483d1a57517f49e3399c2d373064e0c143 100644 (file)
@@ -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;
 }
index e71653fb315905e5af1416c2d678778bcfd09eb9..22a86e90feb3e9863079dc46fbdda9ba99e469b1 100644 (file)
@@ -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);
index 5a54e4947bacf2574239be926fcff6df4f665e35..47817b4dae496ac19a202de2e11498199c91053b 100644 (file)
@@ -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);