You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2019/05/30 17:38:15 UTC
[qpid-dispatch] branch master updated: DISPATCH-1348 - Allocate
qdr_error_t objects only when necessary. Previously,
these objects were always getting created even in the absence of an error.
This closes #515.
This is an automated email from the ASF dual-hosted git repository.
gmurthy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new 21ee691 DISPATCH-1348 - Allocate qdr_error_t objects only when necessary. Previously, these objects were always getting created even in the absence of an error. This closes #515.
21ee691 is described below
commit 21ee691eb0066d8061bf612f2fffa4c226ae7abb
Author: Ganesh Murthy <gm...@apache.org>
AuthorDate: Thu May 30 09:24:55 2019 -0400
DISPATCH-1348 - Allocate qdr_error_t objects only when necessary. Previously, these objects were always getting created even in the absence of an error. This closes #515.
---
src/router_core/error.c | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/src/router_core/error.c b/src/router_core/error.c
index 6ab04bf..1e0a243 100644
--- a/src/router_core/error.c
+++ b/src/router_core/error.c
@@ -34,19 +34,34 @@ qdr_error_t *qdr_error_from_pn(pn_condition_t *pn)
if (!pn)
return 0;
- qdr_error_t *error = new_qdr_error_t();
- ZERO(error);
+ qdr_error_t *error = 0;
const char *name = pn_condition_get_name(pn);
- if (name && *name)
- error->name = qdr_field(name);
-
const char *desc = pn_condition_get_description(pn);
- if (desc && *desc)
- error->description = qdr_field(desc);
+ pn_data_t *info = pn_condition_info(pn);
+ bool is_byt_size_gt_zero = false;
+
+ if (info) {
+ pn_bytes_t byt = pn_data_get_bytes(info);
+ if (byt.size > 0)
+ is_byt_size_gt_zero = true;
+ }
+
+ if ((name && *name) || (desc && *desc) || is_byt_size_gt_zero) {
+ error = new_qdr_error_t();
+ ZERO(error);
+
+ if (name && *name)
+ error->name = qdr_field(name);
- error->info = pn_data(0);
- pn_data_copy(error->info, pn_condition_info(pn));
+ if (desc && *desc)
+ error->description = qdr_field(desc);
+
+ if (is_byt_size_gt_zero) {
+ error->info = pn_data(0);
+ pn_data_copy(error->info, info);
+ }
+ }
return error;
}
@@ -80,6 +95,9 @@ void qdr_error_free(qdr_error_t *error)
void qdr_error_copy(qdr_error_t *from, pn_condition_t *to)
{
+ if (from == 0)
+ return;
+
if (from->name) {
unsigned char *name = qd_iterator_copy(from->name->iterator);
pn_condition_set_name(to, (char*) name);
@@ -122,6 +140,9 @@ char *qdr_error_name(const qdr_error_t *err)
pn_data_t *qdr_error_info(const qdr_error_t *err)
{
+ if (err == 0)
+ return 0;
+
return err->info;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org