[ovs-dev] [PATCH] ovsdb-server: Write manager status information to Manager table.

Andrew Evans aevans at nicira.com
Tue Feb 1 17:44:32 UTC 2011


On 1/31/11 5:05 PM, Andrew Evans wrote:

I don't need split_remote_spec() as a separate function any more. I've
backed it out in my tree, so please ignore.

-Andrew

> diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
> index b4f2e42..577fbd5 100644
> --- a/ovsdb/ovsdb-server.c
> +++ b/ovsdb/ovsdb-server.c
> @@ -173,38 +186,51 @@ main(int argc, char *argv[])
>  }
>  
>  static void
> +split_remote_spec(const char *name_, char **proto,
> +                  char **table_name, char **column_name)
> +{
> +    char *name, *save_ptr = NULL;
> +
> +    name = xstrdup(name_);
> +    *proto = xstrdup(strtok_r(name, ":", &save_ptr)); /* "db:" */
> +    *table_name = xstrdup(strtok_r(NULL, ",", &save_ptr));
> +    *column_name = strtok_r(NULL, ",", &save_ptr);
> +    if (*column_name) {
> +        *column_name = xstrdup(*column_name);
> +    }
> +    free(name);
> +}
> +
> +static void
>  parse_db_column(const struct ovsdb *db,
> -                const char *name_,
> +                const char *name,
>                  const struct ovsdb_table **tablep,
>                  const struct ovsdb_column **columnp)
>  {
> -    char *name, *table_name, *column_name;
> -    const struct ovsdb_column *column;
> -    const struct ovsdb_table *table;
> -    char *save_ptr = NULL;
> +    char *proto, *table_name, *column_name;
>  
> -    name = xstrdup(name_);
> -    strtok_r(name, ":", &save_ptr); /* "db:" */
> -    table_name = strtok_r(NULL, ",", &save_ptr);
> -    column_name = strtok_r(NULL, ",", &save_ptr);
> -    if (!table_name || !column_name) {
> -        ovs_fatal(0, "\"%s\": invalid syntax", name_);
> -    }
> +    split_remote_spec(name, &proto, &table_name, &column_name);
>  
> -    table = ovsdb_get_table(db, table_name);
> -    if (!table) {
> -        ovs_fatal(0, "\"%s\": no table named %s", name_, table_name);
> -    }
> +    if (!strcmp(proto, "db")) {
> +        if (!table_name || !column_name) {
> +            ovs_fatal(0, "\"%s\": invalid syntax", name);
> +        }
>  
> -    column = ovsdb_table_schema_get_column(table->schema, column_name);
> -    if (!column) {
> -        ovs_fatal(0, "\"%s\": table \"%s\" has no column \"%s\"",
> -                  name_, table_name, column_name);
> +        *tablep = ovsdb_get_table(db, table_name);
> +        if (!*tablep) {
> +            ovs_fatal(0, "\"%s\": no table named %s", name, table_name);
> +        }
> +
> +        *columnp = ovsdb_table_schema_get_column((*tablep)->schema, column_name);
> +        if (!*columnp) {
> +            ovs_fatal(0, "\"%s\": table \"%s\" has no column \"%s\"",
> +                      name, table_name, column_name);
> +        }
>      }
> -    free(name);
>  
> -    *columnp = column;
> -    *tablep = table;
> +    free(proto);
> +    free(table_name);
> +    free(column_name);
>  }
>  
>  static void
>




More information about the dev mailing list