| 356 | } |
| 357 | |
| 358 | void DRR::Enqueue(Flow *f, bess::Packet *newpkt, int *err) { |
| 359 | // if the queue is full. drop the packet. |
| 360 | if (llring_count(f->queue) >= max_queue_size_) { |
| 361 | bess::Packet::Free(newpkt); |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | // creates a new queue if there is not enough space for the new packet |
| 366 | // in the old queue |
| 367 | if (llring_full(f->queue)) { |
| 368 | uint32_t slots = |
| 369 | RoundToPowerTwo(llring_count(f->queue) * kQueueGrowthFactor); |
| 370 | f->queue = ResizeQueue(f->queue, slots, err); |
| 371 | if (*err != 0) { |
| 372 | bess::Packet::Free(newpkt); |
| 373 | return; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | *err = llring_enqueue(f->queue, reinterpret_cast<void *>(newpkt)); |
| 378 | if (*err == 0) { |
| 379 | f->timer = get_epoch_time(); |
| 380 | } else { |
| 381 | bess::Packet::Free(newpkt); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | llring *DRR::ResizeQueue(llring *old_queue, uint32_t new_size, int *err) { |
| 386 | llring *new_queue = AddQueue(new_size, err); |
nothing calls this directly
no test coverage detected