[ovs-dev] [PATCH 00/23] Don't use ctl_fatal() in command handlers from db-ctl-base

Jakub Sitnicki jkbs at redhat.com
Mon Jul 2 10:57:47 UTC 2018


This patch series is preparatory work for turning any of the tools from db-ctl
family (ovs-vsctl, vtep-ctl, ovn-nbctl, or ovn-sbctl) into a long-lived
server/daemon that processes database commands on client request.

The goal of this patch set it to prevent dying (terminating the process) when
running one of the commands implemented by the db-ctl-base module (get, list,
find, set, add, remove, clear, create, destroy, and wait-until).

Our approach is to propagate the error all the way to up the {ovs,vtep,ovn}-*clt
client main loop so that it can be handled from there.  We use the return value
and the command context object for this purpose.

The amount of newly introduced error checks might cause mild eye bleeds.
However, I see no other way around it without resorting to macros that alter the
program flow (i.e. contain a 'return' statement).  Alternative ideas are most
welcome.

Also, error propagation forces us to to free up any resources that previously
went unreleased because we were terminating the process.  This could be avoided
with help of the compiler and the __attribute__((cleanup)) annotation. Has this
been considered in the past?

Thanks,
Jakub


Jakub Sitnicki (23):
  db-ctl-base: Don't die in parse_column_names() on error.
  db-ctl-base: Don't die in get_table() on error.
  db-ctl-base: Don't die in is_condition_satisfied() on error.
  db-ctl-base: Don't die in check_mutable() on error.
  db-ctl-base: Don't die in set_column() on error.
  db-ctl-base: Don't die in create_symbol() on error.
  db-ctl-base: Don't die in get_row_by_id() on multiple matches.
  db-ctl-base: Don't die in ctl_get_row() on error.
  db-ctl-base: Don't die in pre_get_column() on error.
  db-ctl-base: Don't die in pre_get_table() on error.
  db-ctl-base: Don't die in pre_parse_column_key_value() on error.
  db-ctl-base: Don't die in pre_list_columns() on error.
  db-ctl-base: Don't die in ctl_set_column() on error.
  db-ctl-base: Extend ctl_context with an error message.
  db-ctl-base: Stop using die_if_error().
  db-ctl-base: Fix resource deallocation on error path in cmd_get().
  db-ctl-base: Fix resource deallocation on error path in cmd_list().
  db-ctl-base: Fix resource deallocation on error path in cmd_find().
  db-ctl-base: Kill die_if_error() helper.
  db-ctl-base: Don't die in cmd_get() on error.
  db-ctl-base: Don't die in cmd_remove() on error.
  db-ctl-base: Don't die in cmd_clear() on error.
  db-ctl-base: Don't die in cmd_destroy() on error.

 lib/db-ctl-base.c         | 667 ++++++++++++++++++++++++++++++++++------------
 lib/db-ctl-base.h         |  15 +-
 ovn/utilities/ovn-nbctl.c |  16 +-
 ovn/utilities/ovn-sbctl.c |  20 +-
 utilities/ovs-vsctl.c     |  16 +-
 vtep/vtep-ctl.c           |   9 +
 6 files changed, 555 insertions(+), 188 deletions(-)

--
2.14.4


More information about the dev mailing list