Skip to content

Commit d689f85

Browse files
committed
ovsdb-cs: Add coverage for full batch events.
When many update notifications arrive in a short time, it may happen that we only process the first 50 of them and have to wait until the next iteration to pick them up. Because previously, there was no way for an operator to observe how often this happened, we add a coverage metric for this event. Signed-off-by: Martin Morgenstern <martin.morgenstern@cloudandheat.com> (cherry picked from commit cf5bdb1a443551116d99e59427ba81a27167bf4e)
1 parent 7f2354e commit d689f85

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/ovsdb-cs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <errno.h>
2222

23+
#include "coverage.h"
2324
#include "hash.h"
2425
#include "jsonrpc.h"
2526
#include "openvswitch/dynamic-string.h"
@@ -40,6 +41,8 @@
4041

4142
VLOG_DEFINE_THIS_MODULE(ovsdb_cs);
4243

44+
COVERAGE_DEFINE(ovsdb_cs_run_batch_full);
45+
4346
/* Connection state machine.
4447
*
4548
* When a JSON-RPC session connects, the CS layer sends a "monitor_cond"
@@ -639,11 +642,13 @@ ovsdb_cs_run(struct ovsdb_cs *cs, struct ovs_list *events)
639642
}
640643
}
641644

645+
bool aborted = false;
642646
int ret;
643647
for (int i = 0; i < 50; i++) {
644648
struct jsonrpc_msg *msg = NULL;
645649
ret = jsonrpc_session_recv(cs->session, &msg);
646650
if (ret == EAGAIN) {
651+
aborted = true;
647652
break;
648653
}
649654
/* Even if we would not block we might not receive a message for two
@@ -655,6 +660,11 @@ ovsdb_cs_run(struct ovsdb_cs *cs, struct ovs_list *events)
655660
jsonrpc_msg_destroy(msg);
656661
}
657662
}
663+
664+
if (!aborted) {
665+
COVERAGE_INC(ovsdb_cs_run_batch_full);
666+
}
667+
658668
ovs_list_push_back_all(events, &cs->data.events);
659669
}
660670

0 commit comments

Comments
 (0)