Does the thin core support asynchronous method call replies?

asked 2015-07-30 06:37:28 -0700

iamwillj gravatar image

updated 2015-07-30 09:35:12 -0700

mathewm gravatar image

Hi All,

I'm working on writing an Alljoyn service using the Thin Core (14.12b), and I ran across an issue when I tried to handle messages asynchronously. My devices often take seconds to respond to queries, so, in order to not tie up the alljoyn message bus, I wanted to be able to handle multiple messages asynchronously.

The 1st issue I came across, during a debug build (ie, NDEBUG is not defined) was, in aj_msg.c about line 996, there is a check "AJ_ASSERT(!currentMsg);" that prevents only a single message being handled at once. I was able to remove that check (either by building a release variant or commenting out that line) and I got past that problem.

The bigger issue is how the message headers are stored. Currently, in aj_msg.h, line 177, the header is defined as a pointer (AJ_MsgHeader* hdr;), and, in aj_msg.c, after a header is received, that header points to the receive buffer, aj_msg.c line 960 (msg->hdr = (AJ_MsgHeader*)ioBuf->bufStart;)

However, if another messages comes in before a previous message has been handled (ie, AJ_CloseMsg() is called), then that receive buffer is over written with the new data, and the previous message's hdr pointer will not have the incorrect serialNum. This is an obvious bug, and causes the wrong replySerial to be sent for the initial message's reply.

My temporary fix was to add another item in the _AJ_Message, aj_msg.h line 178 (AJ_MsgHeader hdrMem;) and, copy the received header data from the receive buffer into there, and pointer hdr to that location.

Please correct this in the next release.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-07-30 08:55:16 -0700

mathewm gravatar image

updated 2015-07-30 09:06:20 -0700

For a use case like yours, you would need to parse the message, close it, and pass the data to your system to handle the query. When the query results are available later, you would send the response. The thin library is designed to work with limited resources (and only on a single thread), so the normal function used for sending replies (AJ_MarchalReplyMsg) does assume you still have the original message available - but there's nothing in the AllJoyn protocol itself that would prevent an asynchronous message reply. I'll see if there are any established techniques for asynchronous replies.

The best place to file bug reports is https://jira.allseenalliance.org/brow... - anything you file there will be reviewed by the core team within a few days.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-07-30 06:37:28 -0700

Seen: 118 times

Last updated: Jul 30 '15