From: sfd Date: Tue, 8 May 2018 04:31:50 +0000 (+1200) Subject: Use an _ex() accessor for detecting errors reading stats. X-Git-Tag: libpcap-1.9-bp~29^2~1 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/2e564ecbd719bc816d48029e99e4b751aa11071d Use an _ex() accessor for detecting errors reading stats. This avoids temporarily setting ps_drop to 0 on errors, however errors in reading stats are not currently reported. --- diff --git a/pcap-dag.c b/pcap-dag.c index 6610af46..661f7b41 100644 --- a/pcap-dag.c +++ b/pcap-dag.c @@ -1064,6 +1064,7 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours) static int dag_stats(pcap_t *p, struct pcap_stat *ps) { struct pcap_dag *pd = p->priv; + uint32_t stream_drop; /* * Packet records received (ps_recv) are counted in dag_read(). @@ -1073,10 +1074,14 @@ dag_stats(pcap_t *p, struct pcap_stat *ps) { */ if(pd->drop_attr != kNullAttributeUuid) { - /* Note this counter will wrap at UINT_MAX. + /* Note this counter is cleared at start of capture and will wrap at UINT_MAX. * The application is responsible for polling ps_drop frequently enough - * to detect each wrap and integrate drop with a wider counter */ - pd->stat.ps_drop = dag_config_get_uint32_attribute(pd->dag_ref, pd->drop_attr); + * to detect each wrap and integrate total drop with a wider counter */ + if (dag_config_get_uint32_attribute_ex(pd->dag_ref, pd->drop_attr, &stream_drop) == kDagErrNone) { + pd->stat.ps_drop = stream_drop; + } else { + /* Currently not reporting errors reading stats */ + } } *ps = pd->stat;