Description
I have been struggling with an issue where more than occasionally the delayedResponseQueue will be filled with empty responses until the server eventually runs out of memory. The client is JSJac but I am not really focused on that implementation, I just want to try and protect the server from being over run by any client.
So here is what is happening:
Here are the RIDs 318 never made it through.
Last sent response = 316
Highest Read = 317
Current = 319
Window = 319
The coding of
requestExpired {
... ...
while(!requestsWindow.isEmpty() && requestsWindow.firstKey() <= req.getRid())
{ write0(boshHandler.getEmptyResponse()); }Coupled with
write0 {
if (requestsWindow.isEmpty() || requestsWindow.firstKey() > highestReadRid) {
delayedResponseQueue.offer(response);
Can easily lead to an infinite loop writing empty response to the delayedResponseQueue.
So in trying to fix this I am having trouble understanding why this would be done in a loop ?
My first instinct is to change the while loop to an if statement but I assume there is a good reason it was implemented this way, I just cannot see it.
Is is not sufficient to write a single empty response when the request expires in the continuation?
The spec is of very little help here so any thoughts would be greatly appreciated.