From e34faccb131507986f8d28930e9d46c3d9ab65df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alf-Andr=C3=A9=20Walla?= Date: Mon, 22 Oct 2018 14:15:38 +0200 Subject: [PATCH] virtionet: Fix a few issues with sendq --- src/drivers/virtionet.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/drivers/virtionet.cpp b/src/drivers/virtionet.cpp index 4437f6fe03..42351947c0 100644 --- a/src/drivers/virtionet.cpp +++ b/src/drivers/virtionet.cpp @@ -265,9 +265,9 @@ void VirtioNet::msix_xmit_handler() while (tx_q.new_incoming()) { auto res = tx_q.dequeue(); - // get packet offset, and call destructor - auto* packet = (net::Packet*) (res.data() - sizeof(net::Packet)); - delete packet; // call deleter on Packet to release it + assert(res.data() != nullptr); + // get packet offset, and call placement Packet deleter directly + net::Packet::operator delete(res.data() - sizeof(net::Packet)); dequeued_tx++; } tx_q.enable_interrupts(); @@ -339,14 +339,13 @@ VirtioNet::create_packet(int link_offset) void VirtioNet::transmit(net::Packet_ptr pckt) { - assert(pckt != nullptr); - VDBG_TX("[virtionet] tx: Transmitting %#zu sized packet \n", - pckt->size()); while (pckt != nullptr) { if (not Nic::sendq_still_available(sendq.size())) { - stat_sendq_limit_dropped_++; - return; + stat_sendq_limit_dropped_ += pckt->chain_length(); + break; } + VDBG_TX("[virtionet] tx: Transmitting %#zu sized packet \n", + pckt->size()); auto tail = pckt->detach_tail(); sendq.emplace_back(std::move(pckt)); pckt = std::move(tail); @@ -363,7 +362,7 @@ void VirtioNet::transmit(net::Packet_ptr pckt) sendq.size()); // Transmit all we can directly - while (tx_q.num_free() > 1 and sendq.size() > 0) + while (tx_q.num_free() > 1 and !sendq.empty()) { VDBG_TX("[virtionet] tx: %u tokens left in TX ring \n", tx_q.num_free());