sign: Fix crash when doing TX on a streamless port
Ensure packetListSize_ is non zero to avoid division by zero. Also reset packetListSize_ to 0 in the constructor - call clearPacketList() to do this
This commit is contained in:
parent
eed4f8eb1d
commit
de503d8d96
@ -38,9 +38,8 @@ PcapTxThread::PcapTxThread(const char *device)
|
|||||||
"This Win32 platform does not support performance counter");
|
"This Win32 platform does not support performance counter");
|
||||||
#endif
|
#endif
|
||||||
state_ = kNotStarted;
|
state_ = kNotStarted;
|
||||||
returnToQIdx_ = -1;
|
|
||||||
loopDelay_ = 0;
|
|
||||||
stop_ = false;
|
stop_ = false;
|
||||||
|
clearPacketList();
|
||||||
handle_ = pcap_open_live(device, 64 /* FIXME */, 0, 1000 /* ms */, errbuf);
|
handle_ = pcap_open_live(device, 64 /* FIXME */, 0, 1000 /* ms */, errbuf);
|
||||||
|
|
||||||
if (handle_ == NULL)
|
if (handle_ == NULL)
|
||||||
@ -441,7 +440,11 @@ int PcapTxThread::sendQueueTransmit(pcap_t *p,
|
|||||||
|
|
||||||
void PcapTxThread::updateStreamStats()
|
void PcapTxThread::updateStreamStats()
|
||||||
{
|
{
|
||||||
// Number of tx packets sent during last transmit
|
// If no packets in list, nothing to be done
|
||||||
|
if (!packetListSize_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get number of tx packets sent during last transmit
|
||||||
quint64 pkts = stats_->pkts > lastStats_.pkts ?
|
quint64 pkts = stats_->pkts > lastStats_.pkts ?
|
||||||
stats_->pkts - lastStats_.pkts :
|
stats_->pkts - lastStats_.pkts :
|
||||||
stats_->pkts + (ULLONG_MAX - lastStats_.pkts);
|
stats_->pkts + (ULLONG_MAX - lastStats_.pkts);
|
||||||
@ -458,6 +461,7 @@ void PcapTxThread::updateStreamStats()
|
|||||||
|
|
||||||
qDebug("%s:", __FUNCTION__);
|
qDebug("%s:", __FUNCTION__);
|
||||||
qDebug("txPkts = %" PRIu64, pkts);
|
qDebug("txPkts = %" PRIu64, pkts);
|
||||||
|
qDebug("packetListSize_ = %" PRIu64, packetListSize_);
|
||||||
qDebug("c = %d, d = %d\n", c, d);
|
qDebug("c = %d, d = %d\n", c, d);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user