Refactor: Add dgram fields to ll_queue, remove ref_count, integrate pkt_normalizer
- ll_queue: Add dgram, dgram_free_fn, dgram_pool, len fields to ll_entry - ll_queue: Remove ref_count, simplify memory management - etcp: Add normalizer pointer to ETCP_CONN struct - pkt_normalizer: Major refactoring for queue integration - tests: Update for new ll_entry structure - cleanup: Remove backup files
This commit is contained in:
1 parent
fbc8e3d9e4
commit
dd4644776d
11 files changed
+1488
-2329
No files matched your search
+6
-16
@@ -114,7 +114,7 @@ void* queue_data_new(size_t data_size) {
|
||||
|
||||
memset(entry, 0, sizeof(struct ll_entry) + data_size);
|
||||
entry->size = data_size;
|
||||
entry->ref_count = 1; // Единственная ссылка - на сам элемент
|
||||
entry->len = 0;
|
||||
entry->pool = NULL; // Выделено через malloc
|
||||
|
||||
// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_new: created entry %p, size=%zu", entry, data_size);
|
||||
@@ -130,7 +130,7 @@ void* queue_data_new_from_pool(struct memory_pool* pool) {
|
||||
|
||||
memset(entry, 0, pool->object_size);
|
||||
entry->size = pool->object_size - sizeof(struct ll_entry);
|
||||
entry->ref_count = 1; // Единственная ссылка - на сам элемент
|
||||
entry->len = 0;
|
||||
entry->pool = pool; // Выделено из пула
|
||||
|
||||
// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_new_from_pool: created entry %p from pool %p", entry, pool);
|
||||
@@ -143,14 +143,10 @@ 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);
|
||||
|
||||
if (--entry->ref_count <= 0) {
|
||||
if (entry->pool) {
|
||||
memory_pool_free(entry->pool, entry);
|
||||
} else {
|
||||
free(entry);
|
||||
}
|
||||
if (entry->pool) {
|
||||
memory_pool_free(entry->pool, entry);
|
||||
} else {
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +222,6 @@ int queue_data_put(struct ll_queue* q, void* data, uint32_t id) {
|
||||
|
||||
q->count++;
|
||||
q->total_bytes += entry->size;
|
||||
// ВАЖНО: НЕ увеличиваем ref_count - элемент просто находится в очереди
|
||||
|
||||
size_t send_q_bytes = queue_total_bytes(q);
|
||||
// DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "check total bytes: new_q_len=%d element_size:%d", send_q_bytes, entry->size);
|
||||
@@ -270,7 +265,6 @@ int queue_data_put_first(struct ll_queue* q, void* data, uint32_t id) {
|
||||
|
||||
q->count++;
|
||||
q->total_bytes += entry->size;
|
||||
// ВАЖНО: НЕ увеличиваем ref_count - элемент просто находится в очереди
|
||||
|
||||
add_to_hash(q, entry);
|
||||
|
||||
@@ -304,8 +298,6 @@ void* queue_data_get(struct ll_queue* q) {
|
||||
|
||||
remove_from_hash(q, entry);
|
||||
|
||||
// ВАЖНО: НЕ уменьшаем ref_count - просто удаляем из очереди
|
||||
|
||||
// DEBUG_DEBUG(DEBUG_CATEGORY_LL_QUEUE, "queue_data_get: got entry %p (id=%u), count=%d", entry, entry->id, q->count);
|
||||
|
||||
// Приостановить коллбэки для предотвращения рекурсии
|
||||
@@ -390,8 +382,6 @@ int queue_remove_data(struct ll_queue* q, void* data) {
|
||||
q->count--;
|
||||
q->total_bytes -= entry->size;
|
||||
|
||||
// ВАЖНО: НЕ уменьшаем ref_count - просто удаляем из очереди
|
||||
|
||||
entry->next = NULL;
|
||||
entry->prev = NULL;
|
||||
|
||||
|
||||
Reference in new issue
Block a user