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.