apache/qpid — pull request #4 by ChugR (2014-11-24 21:40:05+00:00)
Title: QPID-6213: fix queue cleaner connection timeouts

Here's a patch that solves a windows issue and possibly is a general solution the base problem.

1. On windows the queue cleaner runs before there are any queues. This causes an empty list of queues to get posted by the task which exits without rescheduling itself. Then the pollable queue never fires because nothing ever got added. Finally the original task never gets rescheduled and the process is deadlocked. The solution is to add a null pointer to pollable queue in the event that the pollable queue appears empty. This makes sure that the task on the other side of the pollable queue runs. Note that this null may get added even though a batch is already in flight. That will not break anything.

2. This patch adds a timeout, currently one second, which when exceeded gets the purge function to reschedule it's pending work and exit. This gives the other i/o tasks a shot at running before the queue cleaning starts again. In my testing I had 2000 queues and in its current form the queue cleaner will clean all 2000 before releasing the thread regardless of the batch size presented to the fire function. With this patch the 2000 queues are processed but in chunks that are called by the pollable queue.