On Fri, Apr 17, 2015 at 8:09 AM, Adam Wynne <awy...@gmail.com> wrote:

> Sorry for the cross-post but I didn't get any hits on the user list and I
> now
> think this could be a bug.
>
> I think I am seeing a race condition with Messenger on Android only:
>
> When I do the typical put/send sequence in a Thread started from an Android
> Activity, the message is not received by a subscribed peer.  If I kill the
> Activity, the peer will complain that the connection is broken.  So it
> seems that the connection is being made but the data is not sent.  Here is
> an example code snippet:
>
>     Messenger messenger = Messenger.Factory.create();
>     // do other things like create a message
>     messenger.put(msg)
>    // Thread.sleep(200)
>     messenger.send()
>
> However when  I uncomment the sleep statement above, the message is
> received without any problem.   The message is also received if I attempt
> to debug to see what is happening in put().
>
> I noticed that put() does not simply add the message to a queue, it also
> uses nio methods to do some encoding of the message.  I'm wondering if
> since it is not blocking, is there some encoding method happening while the
> send() is being processed, causing the message to be lost.
>
> We also noticed that there is a big CPU usage (up to 40%) spike during the
> put/send process, which seems extreme for just a tcp send.
>

Hi Adam,

Apologies in advance for the barrage of questions, but  some additional
information would be helpful.

What version of the code are you working with?
Is your thread a long running thread or does it terminate shortly after the
code you have posted?
What exactly is receiving the message at the other end of the connection?
Does a similar thread arrangement reproduce the issue outside of Android,
and if so would it be possible to post a reproducer?

Thanks,

--Rafael

Reply via email to