On 5/7/25 3:41 PM, Martin Morgenstern via dev wrote:
> Add timing based variants of ovsdb_idl_run() and ovsdb_idl_loop_run(),
> which accept an additional 'deadline' parameter.
> 
> This parameter instructs the ovsdb-cs and jsonrpc layers below to
> process messages as long as the deadline isn't reached, allowing clients
> to process more OVSDB updates in one batch.
> 
> Signed-off-by: Martin Morgenstern <martin.morgenst...@cloudandheat.com>
> ---
>  lib/ovsdb-idl.c | 24 ++++++++++++++++++++++--
>  lib/ovsdb-idl.h |  3 +++
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index 4c2a3e3aa..1d2d5f119 100644
> --- a/lib/ovsdb-idl.c
> +++ b/lib/ovsdb-idl.c
> @@ -441,11 +441,21 @@ ovsdb_idl_clear(struct ovsdb_idl *db)
>   * ovsdb_idl_get_seqno(). */
>  void
>  ovsdb_idl_run(struct ovsdb_idl *idl)
> +{
> +    ovsdb_idl_run_until(idl, 0);
> +}
> +
> +void
> +ovsdb_idl_run_until(struct ovsdb_idl *idl, long long deadline)
>  {
>      ovs_assert(!idl->txn);
>  
>      struct ovs_list events;
> -    ovsdb_cs_run(idl->cs, &events);
> +    if (deadline) {
> +        ovsdb_cs_run_until(idl->cs, &events, deadline);
> +    } else {
> +        ovsdb_cs_run(idl->cs, &events);
> +    }
>  
>      struct ovsdb_cs_event *event;
>      LIST_FOR_EACH_POP (event, list_node, &events) {
> @@ -4374,7 +4384,17 @@ ovsdb_idl_loop_destroy(struct ovsdb_idl_loop *loop)
>  struct ovsdb_idl_txn *
>  ovsdb_idl_loop_run(struct ovsdb_idl_loop *loop)
>  {
> -    ovsdb_idl_run(loop->idl);
> +    return ovsdb_idl_loop_run_until(loop, 0);
> +}
> +
> +struct ovsdb_idl_txn *
> +ovsdb_idl_loop_run_until(struct ovsdb_idl_loop *loop, long long deadline)
> +{
> +    if (deadline) {
> +        ovsdb_idl_run_until(loop->idl, deadline);
> +    } else {
> +        ovsdb_idl_run(loop->idl);
> +    }
>  
>      /* See if the 'committing_txn' succeeded in the meantime. */
>      if (loop->committing_txn && loop->committing_txn->status == TXN_SUCCESS) 
> {
> diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
> index 86fd2bd36..be9bf146d 100644
> --- a/lib/ovsdb-idl.h
> +++ b/lib/ovsdb-idl.h
> @@ -74,6 +74,7 @@ void ovsdb_idl_destroy(struct ovsdb_idl *);
>  void ovsdb_idl_set_leader_only(struct ovsdb_idl *, bool leader_only);
>  
>  void ovsdb_idl_run(struct ovsdb_idl *);
> +void ovsdb_idl_run_until(struct ovsdb_idl *, long long);

There should be a name for the non-descriptive 'long long' variable.

>  void ovsdb_idl_wait(struct ovsdb_idl *);
>  
>  void ovsdb_idl_get_memory_usage(struct ovsdb_idl *, struct simap *usage);
> @@ -409,6 +410,8 @@ struct ovsdb_idl_loop {
>  
>  void ovsdb_idl_loop_destroy(struct ovsdb_idl_loop *);
>  struct ovsdb_idl_txn *ovsdb_idl_loop_run(struct ovsdb_idl_loop *);
> +struct ovsdb_idl_txn *ovsdb_idl_loop_run_until(struct ovsdb_idl_loop *,
> +                                               long long);

Ditto.

>  int ovsdb_idl_loop_commit_and_wait(struct ovsdb_idl_loop *);
>  
>  /* Conditional Replication

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to