Hi.
I think I've found a solution. I attach a patch.
After some debugging hours, I think I've found was going on. amulegui has a PollTimer that does roughly this: 1. Sends a EC_OP_STAT_REQ request. 2. Sends again another EC_OP_STAT_REQ request. 3. If download view is active, it sends a EC_OP_GET_DLOAD_QUEUE request to get active files. If everything goes OK, amuled replies to these requests in the same order.
But it turns out that sometimes, I don't know why, amuled replies in wrong order, sending first the EC_OP_STAT_REQ reply, even if EC_OP_GET_DLOAD_QUEUE was requested before. When this happens the handler in charge of proccess the EC_OP_GET_DLOAD_QUEUE request receives instead the answer to EC_OP_STAT_REQ, and as it doesn't know what to do with it, it gets lost. But the worst thing is that since then all the protocol gets broken because the amuled responses are handled by the incorrect functions.
The patch I submit is a workaround to solve this situation when it happens. It does not solve the real problem, which is that packets are sent in wrong order. Anyway, to correct the problem the patch does the following:
In amule-remote-gui.h:
- HandlePacket in CRemoteContainer now detects if an "improper" response was sent, and if so it resend it again to the right handler.
- When a DLOAD/ULOAD request is lost, the state machine used by HandlePacket and DoRequery is getting stacked with m_state = STATUS_REQ_SENT. I've add a counter that reset the state to IDLE when DoRequery is called twice for the same request.
In amule-remote-gui.cpp:
- In PollTimer, I've removed the second request to EC_OP_STAT_REQ. This way we save some bandwidth. The info is now partially handled on the second state of PollTimer.
Finally, I've included two new functions to RemoteConnect in the EC lib: ResendLastPacket and FifoRemoveOne. Only the first one is actually used by the patch, and it resends the last packet to the last handler in the fifo, which should be the right one. The other funcion just removes that handler (not sending the packet again), and corrects the de-synchronization, but the packet is lost.
The patch was applied to the clean aMule-2.2.1 source code.
I hope this works for you people too!