diff --git a/lib/debug_config.c b/lib/debug_config.c index f799cdf..0c99857 100644 --- a/lib/debug_config.c +++ b/lib/debug_config.c @@ -38,10 +38,10 @@ void log_dump(const char* prefix, const uint8_t* data, size_t len) { DEBUG_INFO(DEBUG_CATEGORY_ETCP, "%s: len=%zu hex=%s", prefix, len, hex_buf); // Additional debug info for first few bytes - if (len >= 2) { - DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "%s: first_bytes=%02x%02x last_bytes=%02x%02x", - prefix, data[0], data[1], data[len-2], data[len-1]); - } +// if (len >= 2) { +// DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "%s: first_bytes=%02x%02x last_bytes=%02x%02x", +// prefix, data[0], data[1], data[len-2], data[len-1]); +// } } diff --git a/lib/ll_queue.c b/lib/ll_queue.c index dce4628..c392684 100755 --- a/lib/ll_queue.c +++ b/lib/ll_queue.c @@ -117,7 +117,7 @@ void* queue_data_new(size_t data_size) { entry->ref_count = 1; // Единственная ссылка - на сам элемент entry->pool = NULL; // Выделено через malloc - DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_new: created entry %p, size=%zu", entry, data_size); +// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_new: created entry %p, size=%zu", entry, data_size); return (void*)(entry + xxx); } @@ -133,7 +133,7 @@ void* queue_data_new_from_pool(struct memory_pool* pool) { entry->ref_count = 1; // Единственная ссылка - на сам элемент entry->pool = pool; // Выделено из пула - DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_new_from_pool: created entry %p from pool %p", entry, pool); +// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_new_from_pool: created entry %p from pool %p", entry, pool); return (void*)(entry + xxx); } @@ -143,7 +143,7 @@ void queue_data_free(void* data) { struct ll_entry* entry = data_to_entry(data); - DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_free: freeing entry %p, ref_count=%d", entry, entry->ref_count); +// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_free: freeing entry %p, ref_count=%d", entry, entry->ref_count); if (--entry->ref_count <= 0) { if (entry->pool) { @@ -185,8 +185,7 @@ static void remove_from_hash(struct ll_queue* q, struct ll_entry* entry) { static void check_waiters(struct ll_queue* q) { if (!q) return; - DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "check_waiters: checking waiters, count=%d, bytes=%zu", - q->count, q->total_bytes); +// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "check_waiters: checking waiters, count=%d, bytes=%zu", q->count, q->total_bytes); struct queue_waiter* waiter = &q->waiter; @@ -230,7 +229,7 @@ int queue_data_put(struct ll_queue* q, void* data, uint32_t id) { // ВАЖНО: НЕ увеличиваем ref_count - элемент просто находится в очереди size_t send_q_bytes = queue_total_bytes(q); - DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "qqqq check total bytes: new_q_len=%d element_size:%d", send_q_bytes, entry->size); +// DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check total bytes: new_q_len=%d element_size:%d", send_q_bytes, entry->size); add_to_hash(q, entry); @@ -398,7 +397,7 @@ int queue_remove_data(struct ll_queue* q, void* data) { remove_from_hash(q, entry); - DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_remove_data: removed entry %p (id=%u), count=%d", entry, entry->id, q->count); +// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_remove_data: removed entry %p (id=%u), count=%d", entry, entry->id, q->count); return 0; } \ No newline at end of file diff --git a/src/etcp_connections.c b/src/etcp_connections.c index d1357df..45cf940 100644 --- a/src/etcp_connections.c +++ b/src/etcp_connections.c @@ -546,6 +546,11 @@ static void etcp_connections_read_callback(int fd, void* arg) { char buf[128]; addr_to_string(&addr, buf, sizeof(buf)); DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "New connection from %s peer_id=%ld etcp=%p", buf, peer_id, conn); + // Add connection to instance list + conn->next = e_sock->instance->connections; + e_sock->instance->connections = conn; + e_sock->instance->connections_count++; + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "Added incoming connection %p to instance, total count: %d", conn, e_sock->instance->connections_count); } else {// check keys если существующее подключение if (memcmp(conn->crypto_ctx.peer_public_key, sc.peer_public_key, SC_PUBKEY_SIZE)) { errorcode=5; DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "etcp_connections_read_callback: peer key mismatch for node %llu", (unsigned long long)peer_id); goto ec_fr; }// коллизия - peer id совпал а ключи разные. diff --git a/tests/test_config_debug b/tests/test_config_debug deleted file mode 100755 index a1321c9..0000000 Binary files a/tests/test_config_debug and /dev/null differ diff --git a/tests/test_crypto b/tests/test_crypto deleted file mode 100755 index 6ebbe9d..0000000 Binary files a/tests/test_crypto and /dev/null differ diff --git a/tests/test_debug_categories b/tests/test_debug_categories deleted file mode 100755 index 634ee65..0000000 Binary files a/tests/test_debug_categories and /dev/null differ diff --git a/tests/test_ecc_encrypt b/tests/test_ecc_encrypt deleted file mode 100755 index 11a709f..0000000 Binary files a/tests/test_ecc_encrypt and /dev/null differ diff --git a/tests/test_etcp_crypto b/tests/test_etcp_crypto deleted file mode 100755 index 24fb7f2..0000000 Binary files a/tests/test_etcp_crypto and /dev/null differ diff --git a/tests/test_etcp_minimal b/tests/test_etcp_minimal deleted file mode 100755 index f65c8a0..0000000 Binary files a/tests/test_etcp_minimal and /dev/null differ diff --git a/tests/test_etcp_simple_traffic b/tests/test_etcp_simple_traffic index 0b45566..d4a9ceb 100755 Binary files a/tests/test_etcp_simple_traffic and b/tests/test_etcp_simple_traffic differ diff --git a/tests/test_etcp_simple_traffic.c b/tests/test_etcp_simple_traffic.c index d774906..613bded 100644 --- a/tests/test_etcp_simple_traffic.c +++ b/tests/test_etcp_simple_traffic.c @@ -155,25 +155,31 @@ static void check_packet_received(void) { DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check_packet_received: Server output_queue count: %d", queue_entry_count(conn->output_queue)); // Check if there's any packet in output queue - void* data = queue_data_get(conn->output_queue); - if (data) { + struct ETCP_FRAGMENT* pkt = queue_data_get(conn->output_queue); + if (pkt) { DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check_packet_received: Found packet in output queue"); - - // В новом API размер данных нужно получать из структуры - struct ll_entry* entry = (struct ll_entry*)data - 1; - size_t size = entry->size; - + + // ETCP_FRAGMENT содержит ll_entry в начале, данные в pkt_data + size_t size = pkt->ll.size; + uint8_t* data = pkt->pkt_data; + DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check_packet_received: Packet size=%zu, expected=%d", size, PACKET_SIZE); - DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check_packet_received: First byte received=%02X, expected=%02X", - ((uint8_t*)data)[0], test_packet_data[0]); - - if (size == PACKET_SIZE && memcmp(data, test_packet_data, PACKET_SIZE) == 0) { + DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check_packet_received: First byte received=%02X, expected=%02X", + data[0], test_packet_data[0]); + + // Проверяем только данные (первые PACKET_SIZE байт), размер может включать ETCP заголовки + if (size >= PACKET_SIZE && memcmp(data, test_packet_data, PACKET_SIZE) == 0) { packet_received = 1; DEBUG_INFO(DEBUG_CATEGORY_ETCP, "check_packet_received: SUCCESS - Packet received in server output queue (%zu bytes), data matches", size); } else { - DEBUG_WARN(DEBUG_CATEGORY_ETCP, "check_packet_received: Packet received but size mismatch or data differs (expected %d, got %zu)", PACKET_SIZE, size); + DEBUG_WARN(DEBUG_CATEGORY_ETCP, "check_packet_received: Packet received but data differs (expected %d bytes, got %zu)", PACKET_SIZE, size); + } + + // Освобождаем ETCP_FRAGMENT и данные + if (pkt->pkt_data) { + memory_pool_free(conn->instance->data_pool, pkt->pkt_data); } - queue_data_free(data); + queue_data_free(pkt); } else { DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "check_packet_received: No packet found in output queue"); } diff --git a/tests/test_etcp_two_instances b/tests/test_etcp_two_instances deleted file mode 100755 index 454d294..0000000 Binary files a/tests/test_etcp_two_instances and /dev/null differ diff --git a/tests/test_intensive_memory_pool b/tests/test_intensive_memory_pool deleted file mode 100755 index f4d27e9..0000000 Binary files a/tests/test_intensive_memory_pool and /dev/null differ diff --git a/tests/test_ll_queue b/tests/test_ll_queue deleted file mode 100755 index 243883a..0000000 Binary files a/tests/test_ll_queue and /dev/null differ diff --git a/tests/test_memory_pool_and_config b/tests/test_memory_pool_and_config deleted file mode 100755 index 558cf74..0000000 Binary files a/tests/test_memory_pool_and_config and /dev/null differ diff --git a/tests/test_packet_dump b/tests/test_packet_dump deleted file mode 100755 index d445c69..0000000 Binary files a/tests/test_packet_dump and /dev/null differ diff --git a/tests/test_u_async_comprehensive b/tests/test_u_async_comprehensive deleted file mode 100755 index f6b8731..0000000 Binary files a/tests/test_u_async_comprehensive and /dev/null differ diff --git a/tests/test_u_async_performance b/tests/test_u_async_performance deleted file mode 100755 index 82719ac..0000000 Binary files a/tests/test_u_async_performance and /dev/null differ