]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: use proper name for packet in worker_submit()
authorTomas Krizek <tomas.krizek@nic.cz>
Tue, 8 Sep 2020 08:28:51 +0000 (10:28 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Wed, 23 Sep 2020 11:08:11 +0000 (13:08 +0200)
The variable name query is misleading, since the passed in packet
can actually be a response as well (or a malformed packet).

daemon/session.c
daemon/worker.c
daemon/worker.h

index d606fa451f91f5cd77c67e7cae15bd22de8f439e..5e0df70bef9074aefa21d26cf6db26d559ea1d5b 100644 (file)
@@ -713,17 +713,17 @@ int session_wirebuf_process(struct session *session, const struct sockaddr *peer
        size_t wirebuf_data_size = session->wire_buf_end_idx - session->wire_buf_start_idx;
        uint32_t max_iterations = (wirebuf_data_size /
                (KNOT_WIRE_HEADER_SIZE + KNOT_WIRE_QUESTION_MIN_SIZE)) + 1;
-       knot_pkt_t *query = NULL;
+       knot_pkt_t *pkt = NULL;
 
-       while (((query = session_produce_packet(session, &the_worker->pkt_pool)) != NULL) &&
+       while (((pkt = session_produce_packet(session, &the_worker->pkt_pool)) != NULL) &&
               (ret < max_iterations)) {
                assert (!session_wirebuf_error(session));
-               int res = worker_submit(session, peer, query);
+               int res = worker_submit(session, peer, pkt);
                /* Errors from worker_submit() are intetionally *not* handled in order to
                 * ensure the entire wire buffer is processed. */
                if (res == kr_ok())
                        ret += 1;
-               if (session_discard_packet(session, query) < 0) {
+               if (session_discard_packet(session, pkt) < 0) {
                        /* Packet data isn't stored in memory as expected.
                         * something went wrong, normally should not happen. */
                        break;
index 45ab8133d76be1dcb9518aa861885bf3e248db0a..97a2feeb858b5d220242cc810b1d4f0984b9c751 100644 (file)
@@ -1569,7 +1569,7 @@ static int parse_packet(knot_pkt_t *query)
        return ret;
 }
 
-int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt_t *query)
+int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt_t *pkt)
 {
        if (!session) {
                assert(false);
@@ -1583,14 +1583,14 @@ int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt
                return kr_error(EINVAL);
        }
 
-       int ret = parse_packet(query);
+       int ret = parse_packet(pkt);
 
-       const bool is_query = (knot_wire_get_qr(query->wire) == 0);
+       const bool is_query = (knot_wire_get_qr(pkt->wire) == 0);
        const bool is_outgoing = session_flags(session)->outgoing;
        /* Ignore badly formed queries. */
        if ((ret != kr_ok() && ret != kr_error(EMSGSIZE)) ||
            (is_query == is_outgoing)) {
-               if (query && !is_outgoing) the_worker->stats.dropped += 1;
+               if (pkt && !is_outgoing) the_worker->stats.dropped += 1;
                return kr_error(EILSEQ);
        }
 
@@ -1600,12 +1600,12 @@ int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt
        const struct sockaddr *addr = NULL;
        if (!is_outgoing) { /* request from a client */
                struct request_ctx *ctx = request_create(the_worker, session, peer,
-                                                        knot_wire_get_id(query->wire));
+                                                        knot_wire_get_id(pkt->wire));
                if (!ctx) {
                        return kr_error(ENOMEM);
                }
 
-               ret = request_start(ctx, query);
+               ret = request_start(ctx, pkt);
                if (ret != 0) {
                        request_free(ctx);
                        return kr_error(ENOMEM);
@@ -1620,8 +1620,8 @@ int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt
                if (handle->type == UV_TCP && qr_task_register(task, session)) {
                        return kr_error(ENOMEM);
                }
-       } else if (query) { /* response from upstream */
-               const uint16_t id = knot_wire_get_id(query->wire);
+       } else if (pkt) { /* response from upstream */
+               const uint16_t id = knot_wire_get_id(pkt->wire);
                task = session_tasklist_del_msgid(session, id);
                if (task == NULL) {
                        VERBOSE_MSG(NULL, "=> ignoring packet with mismatching ID %d\n",
@@ -1637,7 +1637,7 @@ int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt
         * Task was created (found). */
        session_touch(session);
        /* Consume input and produce next message */
-       return qr_task_step(task, addr, query);
+       return qr_task_step(task, addr, pkt);
 }
 
 static int map_add_tcp_session(map_t *map, const struct sockaddr* addr,
index bce451cc08341ac6218e9423133d19544462d32c..a93a168fe774af3d283bd552e89166d6683613f4 100644 (file)
@@ -33,10 +33,10 @@ void worker_deinit(void);
  *
  * @param session  session the packet came from
  * @param peer     address the packet came from
- * @param query    the packet, or NULL on an error from the transport layer
+ * @param pkt      the packet, or NULL on an error from the transport layer
  * @return 0 or an error code
  */
-int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt_t *query);
+int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt_t *pkt);
 
 /**
  * End current DNS/TCP session, this disassociates pending tasks from this session