diff options
author | ncteisen <ncteisen@gmail.com> | 2018-09-08 10:19:26 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-09-08 10:19:26 -0700 |
commit | 5946ae5eff6cb97d0f5aed2bceda34811c6290fc (patch) | |
tree | 3325a2d8b304364a5f06b133c91afb22e440a85f /src/core/lib/iomgr/error.cc | |
parent | fe1f7f58139a3ccafb7b8e8ca92d5d209880a3e5 (diff) | |
parent | 2f76fd452ebd796945b29f4ad1d10471dfac3346 (diff) |
Merge branch 'channelz-subchannels' into channelz-server
Diffstat (limited to 'src/core/lib/iomgr/error.cc')
-rw-r--r-- | src/core/lib/iomgr/error.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index 90ed34da11..13bc69ffb6 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -513,9 +513,24 @@ bool grpc_error_get_str(grpc_error* err, grpc_error_strs which, grpc_error* grpc_error_add_child(grpc_error* src, grpc_error* child) { GPR_TIMER_SCOPE("grpc_error_add_child", 0); - grpc_error* new_err = copy_error_and_unref(src); - internal_add_error(&new_err, child); - return new_err; + if (src != GRPC_ERROR_NONE) { + if (child == GRPC_ERROR_NONE) { + /* \a child is empty. Simply return the ref to \a src */ + return src; + } else if (child != src) { + grpc_error* new_err = copy_error_and_unref(src); + internal_add_error(&new_err, child); + return new_err; + } else { + /* \a src and \a child are the same. Drop one of the references and return + * the other */ + GRPC_ERROR_UNREF(child); + return src; + } + } else { + /* \a src is empty. Simply return the ref to \a child */ + return child; + } } static const char* no_error_string = "\"No Error\""; |