Subject: | AnyEvent::MessagePack read type corrupts responses |
Date: | Sun, 29 Jan 2012 21:33:32 +0000 |
To: | bug-AnyEvent-MPRPC [...] rt.cpan.org |
From: | Adam Guthrie <asguthrie [...] gmail.com> |
I'm using AnyEvent::MPRPC::Client and the deserialization of responses
occasionally corrupts as described below. I get errors message like:
Can't use string ("462") as an ARRAY ref while "strict refs" in use at
[...]AnyEvent/MPRPC/Client.pm line 151.
or
Use of uninitialized value in delete at [...]AnyEvent/MPRPC/Client.pm line
151.
Invalid response from server at [...]AnyEvent/MPRPC/Client.pm line 164.
I believe this happens when the response is split between two on_read
callbacks from the AnyEvent::Handle. In this case, the first half is
forgotten and deserialization of the second half is attempted causing the
messages above.
Constructing a simple test case is a little difficult without a server but
I attach a patch that seems to fix the issue for me. I've chosen to use
the Handle's rbuf rather than Data::MessagePack::Unpacker's internal buffer
as the latter is harder to use and imcomplete in some cases.
I'm running perl 5.14.2 on Mac OS X 10.6.8
Adam
Message body is not shown because sender requested not to inline it.