]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: fix TLS rehandshakes
authorOto Šťáva <oto.stava@nic.cz>
Fri, 24 Feb 2023 11:17:54 +0000 (12:17 +0100)
committerOto Šťáva <oto.stava@nic.cz>
Fri, 24 Feb 2023 11:17:54 +0000 (12:17 +0100)
Move send_waiting call to DNS protolayer, where it should have been in
the first place.

daemon/tls.c
daemon/worker.c

index f30bd83f6f68bae0975a840bf21ba0d61d13e39c..36a7eaa7f39dee111bdad6515853a97e55d3d91d 100644 (file)
@@ -51,6 +51,7 @@ typedef enum tls_client_hs_state {
 struct pl_tls_sess_data {
        PROTOLAYER_DATA_HEADER();
        bool client_side;
+       bool first_handshake_done;
        gnutls_session_t tls_session;
        tls_hs_state_t handshake_state;
        protolayer_iter_ctx_queue_t unwrap_queue;
@@ -256,7 +257,11 @@ static void tls_handshake_success(struct pl_tls_sess_data *tls,
                        }
                }
        }
-       session2_event_after(session, PROTOLAYER_TLS, PROTOLAYER_EVENT_CONNECT, NULL);
+       if (!tls->first_handshake_done) {
+               session2_event_after(session, PROTOLAYER_TLS,
+                               PROTOLAYER_EVENT_CONNECT, NULL);
+               tls->first_handshake_done = true;
+       }
 }
 
 /** Perform TLS handshake and handle error codes according to the documentation.
index ae9081b106b855d3edd85991b104febae0602f5e..f14273629c77e096fd3c2ba66f3bbad5ff879dbe 100644 (file)
@@ -805,12 +805,6 @@ static void on_connect(uv_connect_t *req, int status)
 
        session2_event(session, PROTOLAYER_EVENT_CONNECT, NULL);
        session2_start_read(session);
-
-       int ret = send_waiting(session);
-       if (ret != 0) {
-               return;
-       }
-
        session2_timer_stop(session);
        session2_timer_start(session, PROTOLAYER_EVENT_GENERAL_TIMEOUT,
                        MAX_TCP_INACTIVITY, MAX_TCP_INACTIVITY);
@@ -1909,6 +1903,8 @@ static enum protolayer_event_cb_result pl_dns_stream_connected(
        }
 
        worker_add_tcp_connected(peer, session);
+
+       send_waiting(session);
        return PROTOLAYER_EVENT_PROPAGATE;
 }