{
struct pl_quic_conn_sess_data *conn = sess_data;
conn->state = 0;
+ conn->disconnected = false;
conn->path = calloc(1, sizeof(ngtcp2_path));
if (!conn->path) {
return kr_error(ENOMEM);
struct pl_quic_conn_sess_data *conn = sess_data;
while (session2_tasklist_del_first(session, false) != NULL);
+ session2_timer_stop(session);
struct pl_quic_stream_sess_data *s_node;
WALK_LIST_FIRST(s_node, conn->streams) {
struct pl_quic_stream_sess_data *s =
ngtcp2_conn_del(conn->conn);
conn->conn = NULL;
- session2_timer_stop(session);
return kr_ok();
}
if (event == PROTOLAYER_EVENT_DISCONNECT ||
event == PROTOLAYER_EVENT_CLOSE ||
event == PROTOLAYER_EVENT_FORCE_CLOSE) {
- session2_dec_refs(session);
+ if (!conn->disconnected) {
+ conn->disconnected = true;
+ session2_dec_refs(session);
+ }
return PROTOLAYER_EVENT_CONSUME;
}
queue_t(struct pl_quic_stream_sess_data *) pending_unwrap;
bool is_server;
bool retry_sent;
+ /* defer can keep the session alive even if the connection timed out or
+ * terminated. To avoid decreasing the refcount more than once in
+ * quic_conn:pl_quic_event_unwrap this boolean value is used. */
+ bool disconnected;
ngtcp2_cid dcid;
ngtcp2_cid scid;
ngtcp2_cid odcid;
continue;
}
kr_quic_table_rem2(pcid, table);
+ conn->cid_pointers--;
}
- conn->cid_pointers--;
free(scids);
- } else {
- kr_quic_cid_t **pcid = kr_quic_table_lookup2(&conn->dcid, table);
- if (pcid != NULL) {
- kr_quic_table_rem2(pcid, table);
- }
}
-
+
int pos = heap_find(table->expiry_heap, (heap_val_t *)conn);
- heap_delete(table->expiry_heap, pos);
- table->usage--;
+ /* Since deferred iteration context increases the session ref_count
+ * it is possible that the session will exist after being removed
+ * from the expiry heap. In such case no cid is found and the
+ * the heap_find function returns 0, which is not a valid value
+ * because the heap index starts at 1. */
+ if (pos != 0) {
+ heap_delete(table->expiry_heap, pos);
+ table->usage--;
+ }
}
void kr_quic_table_free(kr_quic_table_t *table)
#pragma once
#include <ngtcp2/ngtcp2.h>
+#include "quic_common.h"
#include "session2.h"
typedef struct pl_quic_demux_sess_data {