You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2012/09/26 03:55:28 UTC
svn commit: r1390260 - /qpid/proton/trunk/proton-c/src/codec/codec.c
Author: rhs
Date: Wed Sep 26 01:55:27 2012
New Revision: 1390260
URL: http://svn.apache.org/viewvc?rev=1390260&view=rev
Log:
fixed bug where pn_data_scan gets trapped in descriptors
Modified:
qpid/proton/trunk/proton-c/src/codec/codec.c
Modified: qpid/proton/trunk/proton-c/src/codec/codec.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/codec/codec.c?rev=1390260&r1=1390259&r2=1390260&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/codec/codec.c (original)
+++ qpid/proton/trunk/proton-c/src/codec/codec.c Wed Sep 26 01:55:27 2012
@@ -1971,6 +1971,23 @@ int pn_data_fill(pn_data_t *data, const
return err;
}
+static bool pn_scan_next(pn_data_t *data, pn_type_t *type, bool suspend)
+{
+ if (suspend) return false;
+ bool found = pn_data_next(data, type);
+ if (found) {
+ return true;
+ } else {
+ pn_node_t *parent = pn_data_node(data, data->parent);
+ if (parent && parent->atom.type == PN_DESCRIPTOR) {
+ pn_data_exit(data);
+ return pn_scan_next(data, type, suspend);
+ } else {
+ return false;
+ }
+ }
+}
+
int pn_data_vscan(pn_data_t *data, const char *fmt, va_list ap)
{
pn_data_rewind(data);
@@ -1991,7 +2008,7 @@ int pn_data_vscan(pn_data_t *data, const
switch (code) {
case 'n':
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_NULL) {
scanned = true;
} else {
@@ -2002,7 +2019,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'o':
{
bool *value = va_arg(ap, bool *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_BOOL) {
pn_data_get_bool(data, value);
scanned = true;
@@ -2016,7 +2033,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'B':
{
uint8_t *value = va_arg(ap, uint8_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_UBYTE) {
pn_data_get_ubyte(data, value);
scanned = true;
@@ -2030,7 +2047,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'b':
{
int8_t *value = va_arg(ap, int8_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_BYTE) {
pn_data_get_byte(data, value);
scanned = true;
@@ -2044,7 +2061,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'H':
{
uint16_t *value = va_arg(ap, uint16_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_USHORT) {
pn_data_get_ushort(data, value);
scanned = true;
@@ -2058,7 +2075,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'h':
{
int16_t *value = va_arg(ap, int16_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_SHORT) {
pn_data_get_short(data, value);
scanned = true;
@@ -2072,7 +2089,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'I':
{
uint32_t *value = va_arg(ap, uint32_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_UINT) {
pn_data_get_uint(data, value);
scanned = true;
@@ -2086,7 +2103,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'i':
{
int32_t *value = va_arg(ap, int32_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_INT) {
pn_data_get_int(data, value);
scanned = true;
@@ -2100,7 +2117,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'L':
{
uint64_t *value = va_arg(ap, uint64_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_ULONG) {
pn_data_get_ulong(data, value);
scanned = true;
@@ -2114,7 +2131,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'l':
{
int64_t *value = va_arg(ap, int64_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_LONG) {
pn_data_get_long(data, value);
scanned = true;
@@ -2128,7 +2145,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'f':
{
float *value = va_arg(ap, float *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_FLOAT) {
pn_data_get_float(data, value);
scanned = true;
@@ -2142,7 +2159,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'd':
{
double *value = va_arg(ap, double *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_DOUBLE) {
pn_data_get_double(data, value);
scanned = true;
@@ -2156,7 +2173,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'z':
{
pn_bytes_t *bytes = va_arg(ap, pn_bytes_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_BINARY) {
pn_data_get_binary(data, bytes);
scanned = true;
@@ -2170,7 +2187,7 @@ int pn_data_vscan(pn_data_t *data, const
case 'S':
{
pn_bytes_t *bytes = va_arg(ap, pn_bytes_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_STRING) {
pn_data_get_string(data, bytes);
scanned = true;
@@ -2184,7 +2201,7 @@ int pn_data_vscan(pn_data_t *data, const
case 's':
{
pn_bytes_t *bytes = va_arg(ap, pn_bytes_t *);
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_SYMBOL) {
pn_data_get_symbol(data, bytes);
scanned = true;
@@ -2196,7 +2213,7 @@ int pn_data_vscan(pn_data_t *data, const
if (resume_count && level == count_level) resume_count--;
break;
case 'D':
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_DESCRIPTOR) {
pn_data_enter(data);
scanned = true;
@@ -2217,7 +2234,7 @@ int pn_data_vscan(pn_data_t *data, const
if (atoms) pn_atoms_ltrim(atoms, 1);
return 0;*/
case '@':
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_ARRAY) {
pn_data_enter(data);
scanned = true;
@@ -2233,7 +2250,7 @@ int pn_data_vscan(pn_data_t *data, const
scanned = true;
at = false;
} else {
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_LIST) {
pn_data_enter(data);
scanned = true;
@@ -2245,7 +2262,7 @@ int pn_data_vscan(pn_data_t *data, const
level++;
break;
case '{':
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
if (found && type == PN_MAP) {
pn_data_enter(data);
scanned = true;
@@ -2263,7 +2280,7 @@ int pn_data_vscan(pn_data_t *data, const
if (resume_count && level == count_level) resume_count--;
break;
case '.':
- found = suspend ? false : pn_data_next(data, &type);
+ found = pn_scan_next(data, &type, suspend);
scanned = found;
if (resume_count && level == count_level) resume_count--;
break;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org