There's no reason to print counters of given port after every
packet received. Print counters only when screen update is needed.
This lowers CPU utilization from 7% to 4% for roughly the same
workload.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/serv.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/serv.c b/src/serv.c
index 513cc94..a955d5c 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -348,7 +348,7 @@ static void destroyportlist(struct portlist *list)
static void updateportent(struct portlist *list, unsigned int protocol,
in_port_t sport, in_port_t dport, int br,
- unsigned int idx, struct porttab *ports)
+ struct porttab *ports)
{
struct portlistent *sport_listent = NULL;
struct portlistent *dport_listent = NULL;
@@ -384,10 +384,6 @@ static void updateportent(struct portlist *list, unsigned int
protocol,
update_proto_counter(&dport_listent->serv_count, PORT_INCOMING, br);
update_proto_counter(&dport_listent->span, PORT_INCOMING, br);
}
- if (sport_listent != NULL)
- printportent(list, sport_listent, idx);
- if (dport_listent != NULL && dport_listent != sport_listent)
- printportent(list, dport_listent, idx);
}
/*
@@ -915,6 +911,8 @@ void servmon(char *ifname, time_t facilitytime)
}
if (screen_update_needed(&tv, &updtime)) {
+ refresh_serv_screen(&list, idx);
+
update_panels();
doupdate();
@@ -1064,7 +1062,7 @@ void servmon(char *ifname, time_t facilitytime)
case IPPROTO_TCP:
case IPPROTO_UDP:
updateportent(&list, ip_protocol, sport,
- dport, iplen, idx, ports);
+ dport, iplen, ports);
break;
default:
/* unknown L4 protocol */
--
1.7.8.4