|
|
|
|
@ -337,6 +337,43 @@ int queue_entry_count(struct ll_queue* q) {
|
|
|
|
|
return q ? q->count : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Функция проверки консистентности count и total_bytes
|
|
|
|
|
// Возвращает 0 если ok, -1 если есть несоответствия
|
|
|
|
|
int queue_check_consistency(struct ll_queue* q) { |
|
|
|
|
if (!q) return -1; // Недопустимая очередь
|
|
|
|
|
|
|
|
|
|
int actual_count = 0; |
|
|
|
|
size_t actual_bytes = 0; |
|
|
|
|
struct ll_entry* current = q->head; |
|
|
|
|
|
|
|
|
|
while (current) { |
|
|
|
|
actual_count++; |
|
|
|
|
actual_bytes += current->int_len; |
|
|
|
|
if (current->next) { |
|
|
|
|
if (current->next->prev != current) { |
|
|
|
|
// Несоответствие в связях prev/next
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_LL_QUEUE, "Prev/next error"); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
current = current->next; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Проверить хвост
|
|
|
|
|
if (q->tail && q->tail->next != NULL) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_LL_QUEUE, "Tail error"); |
|
|
|
|
return -1; // Хвост должен иметь next == NULL
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Сравнить с сохранёнными значениями
|
|
|
|
|
if (actual_count != q->count || actual_bytes != q->total_bytes) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_LL_QUEUE, " count error entries: %d!=%d or bytes: %d!=%d", actual_count, q->count, actual_bytes, q->total_bytes); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ==================== Асинхронное ожидание ====================
|
|
|
|
|
|
|
|
|
|
struct queue_waiter* queue_wait_threshold(struct ll_queue* q, int max_packets, size_t max_bytes, |
|
|
|
|
|