[ovs-dev] [mointor2 1/9] ovsdb: refactor, add ovsdb_monitor_max_columns()

Andy Zhou azhou at nicira.com
Thu Oct 22 04:49:05 UTC 2015


I have also pushed the patches to my github account:

https://github.com/azhou-nicira/ovs-review/tree/monitor2

On Wed, Oct 21, 2015 at 9:45 PM, Andy Zhou <azhou at nicira.com> wrote:
> This function will have multiple callers in later patches.
>
> Signed-off-by: Andy Zhou <azhou at nicira.com>
> ---
>  ovsdb/monitor.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
> index 8a64fc1..f978960 100644
> --- a/ovsdb/monitor.c
> +++ b/ovsdb/monitor.c
> @@ -547,6 +547,21 @@ ovsdb_monitor_compose_row_update(
>      return row_json;
>  }
>
> +static size_t
> +ovsdb_monitor_max_columns(struct ovsdb_monitor *dbmon)
> +{
> +    struct shash_node *node;
> +    size_t max_columns = 0;
> +
> +    SHASH_FOR_EACH (node, &dbmon->tables) {
> +        struct ovsdb_monitor_table *mt = node->data;
> +
> +        max_columns = MAX(max_columns, mt->n_columns);
> +    }
> +
> +    return max_columns;
> +}
> +
>  /* Constructs and returns JSON for a <table-updates> object (as described in
>   * RFC 7047) for all the outstanding changes within 'monitor', starting from
>   * 'transaction'.  */
> @@ -555,17 +570,9 @@ ovsdb_monitor_compose_update(struct ovsdb_monitor *dbmon,
>                               bool initial, uint64_t transaction)
>  {
>      struct shash_node *node;
> -    unsigned long int *changed;
>      struct json *json;
> -    size_t max_columns;
> -
> -    max_columns = 0;
> -    SHASH_FOR_EACH (node, &dbmon->tables) {
> -        struct ovsdb_monitor_table *mt = node->data;
> -
> -        max_columns = MAX(max_columns, mt->n_columns);
> -    }
> -    changed = xmalloc(bitmap_n_bytes(max_columns));
> +    size_t max_columns = ovsdb_monitor_max_columns(dbmon);
> +    unsigned long int *changed = xmalloc(bitmap_n_bytes(max_columns));
>
>      json = NULL;
>      SHASH_FOR_EACH (node, &dbmon->tables) {
> --
> 1.9.1
>



More information about the dev mailing list