[ovs-git] [openvswitch/ovs] fcb7e3: ovsdb-idl.c: Update conditions when handling chang...

GitHub noreply at github.com
Tue Aug 14 21:36:31 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: fcb7e398e079fc8fa9e5f1ecc04ad6dcac0fd56e
      https://github.com/openvswitch/ovs/commit/fcb7e398e079fc8fa9e5f1ecc04ad6dcac0fd56e
  Author: Han Zhou <zhouhan at gmail.com>
  Date:   2018-08-14 (Tue, 14 Aug 2018)

  Changed paths:
    M lib/ovsdb-idl.c

  Log Message:
  -----------
  ovsdb-idl.c: Update conditions when handling change tracking list.

There are places with the pattern:
    if (!ovs_list_is_empty(&row->track_node)) {
  ovs_list_remove(&row->track_node);
    }
    ovs_list_push_back(&row->table->track_list,
                 &row->track_node);

It seems to be trying to prevent double removing the node from a list,
but actually it doesn't, and may be misleading.

The function ovs_list_is_empty() returns true only if the node has been
initialized with ovs_list_init(). If a node is deleted but not
initialized, the check will return false and the above code will continue
deleting it again. But if a node is already initialized, calling
ovs_list_remove() is a no-op. So the check is not necessary and misleading.

In fact there is already a double removal resulted by this code: the function
ovsdb_idl_db_clear() removes the node but it then calls ovsdb_idl_row_destroy()
immediately which removes the node again. It should not result in any real
issue yet since the list was not changed so the second removal just
assigns the pointers with same value.

It is in fact not necessary to remove and then add back to the list, because
the purpose of the change tracking is just to tell if a row is changed
or not. So this patch removes the "check and remove" code before adding
the node to a list, but instead, adding it to the list only if it is
not in a list. This way it ensures the node is added to a list only once
in one idl loop. (ovsdb_idl_db_track_clear() will be called in each
iteration and the check ovs_list_is_empty() will return true at the first
check in next iteration).

Signed-off-by: Han Zhou <hzhou8 at ebay.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>



      **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the git mailing list