Skip to content

Commit 5a34b94

Browse files
committed
ovsdb-idl: Add _until variants of run functions.
Signed-off-by: Martin Morgenstern <martin.morgenstern@cloudandheat.com>
1 parent eb52b3b commit 5a34b94

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/ovsdb-idl.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,21 @@ ovsdb_idl_clear(struct ovsdb_idl *db)
441441
* ovsdb_idl_get_seqno(). */
442442
void
443443
ovsdb_idl_run(struct ovsdb_idl *idl)
444+
{
445+
ovsdb_idl_run_until(idl, 0);
446+
}
447+
448+
void
449+
ovsdb_idl_run_until(struct ovsdb_idl *idl, long long deadline)
444450
{
445451
ovs_assert(!idl->txn);
446452

447453
struct ovs_list events;
448-
ovsdb_cs_run(idl->cs, &events);
454+
if (deadline) {
455+
ovsdb_cs_run_until(idl->cs, &events, deadline);
456+
} else {
457+
ovsdb_cs_run(idl->cs, &events);
458+
}
449459

450460
struct ovsdb_cs_event *event;
451461
LIST_FOR_EACH_POP (event, list_node, &events) {
@@ -4374,7 +4384,17 @@ ovsdb_idl_loop_destroy(struct ovsdb_idl_loop *loop)
43744384
struct ovsdb_idl_txn *
43754385
ovsdb_idl_loop_run(struct ovsdb_idl_loop *loop)
43764386
{
4377-
ovsdb_idl_run(loop->idl);
4387+
return ovsdb_idl_loop_run_until(loop, 0);
4388+
}
4389+
4390+
struct ovsdb_idl_txn *
4391+
ovsdb_idl_loop_run_until(struct ovsdb_idl_loop *loop, long long deadline)
4392+
{
4393+
if (deadline) {
4394+
ovsdb_idl_run_until(loop->idl, deadline);
4395+
} else {
4396+
ovsdb_idl_run(loop->idl);
4397+
}
43784398

43794399
/* See if the 'committing_txn' succeeded in the meantime. */
43804400
if (loop->committing_txn && loop->committing_txn->status == TXN_SUCCESS) {

lib/ovsdb-idl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void ovsdb_idl_destroy(struct ovsdb_idl *);
7474
void ovsdb_idl_set_leader_only(struct ovsdb_idl *, bool leader_only);
7575

7676
void ovsdb_idl_run(struct ovsdb_idl *);
77+
void ovsdb_idl_run_until(struct ovsdb_idl *, long long);
7778
void ovsdb_idl_wait(struct ovsdb_idl *);
7879

7980
void ovsdb_idl_get_memory_usage(struct ovsdb_idl *, struct simap *usage);
@@ -409,6 +410,8 @@ struct ovsdb_idl_loop {
409410

410411
void ovsdb_idl_loop_destroy(struct ovsdb_idl_loop *);
411412
struct ovsdb_idl_txn *ovsdb_idl_loop_run(struct ovsdb_idl_loop *);
413+
struct ovsdb_idl_txn *ovsdb_idl_loop_run_until(struct ovsdb_idl_loop *,
414+
long long);
412415
int ovsdb_idl_loop_commit_and_wait(struct ovsdb_idl_loop *);
413416

414417
/* Conditional Replication

0 commit comments

Comments
 (0)