experimental cut of dropping source mutexes for rwlocks

To make sure this works, several things have been done

per-source outgoing bitrate stats removed, needs checking as listeners can race on this.

source queue does not shrink, but expands to the queue-size limit

listeners stay on the intial worker for now, may have some migration eventually.

listeners don't change counts on queue blocks as that requires locking, but they still
drop if the lag is greater than queue size.
Fixup listener switching to source client worker.

listener moves to the other worker provided moving there won't be too many
clients on that worker.  Having listeners on the same worker as the source
eases contention issues but a single stream with many listeners would max
out a worker fairly easy, so we only do this if there are no more than 1000
clients difference.  source clients can also move so this should allow for
a reasonable balance (hope!).

The balance is more like we had before, but now the rwlocks should have less
impact when listeners are spread out over workers.
worker balance work.

The main bits here are to allow for clients to switch workers if the load
differences is worth it.  This means that listeners will move to the source
client worker if not on already but also that it will move away if there is
sufficiently less.  The levels to prevent them happening are initial guesses

To help the routines, a number of underlying changes are done. The least busy
worker is maintained in a global and only updated from the slave thread each
second, saves multiple scanning.   Each worker will attempt to move N clients
when notified by the slave thread, which cycles through the workers 1 per
second.
add per-source outgoing_kbitrate stat

To avoid multiple listeners updating between workers, we use a spin lock
worker balancing tweaks.

make find least busy worker account for pending count and call it
from worker_selected if sufficiently larger from last update.
allow source client to move more easily, may require tighening up
later.

update the use of the find least busy worker routine to account for
pending clients as well. worker_selected may call it if the
increase the level before source will move.

To at least the point where listeners would move away.
fix segv at server exit, null deref
limiter tweaks for high load

don't add more than 1 block on the reader side
force send limiter to be half it was or 4k, which ever is the higher
Merge branch 'master' of github.com:karlheyes/icecast-kh into rwlock-demo
don't use a fix offset from the source client time.

Most of the time, listeners are at the beginning of the queue and are
currently scheduled at the same time for processing the send. This works
well to get data out but can trigger a large number of sends all at the
same time, so introduce a small offset that disperses a listener schedule
time within a small range. This should allow a smaller set to go straight
away and some shortly after.
experimental cut of dropping source mutexes for rwlocks

To make sure this works, several things have been done

per-source outgoing bitrate stats removed, needs checking as listeners can race on this.

source queue does not shrink, but expands to the queue-size limit

listeners stay on the intial worker for now, may have some migration eventually.

listeners don't change counts on queue blocks as that requires locking, but they still
drop if the lag is greater than queue size.
Fixup listener switching to source client worker.

listener moves to the other worker provided moving there won't be too many
clients on that worker.  Having listeners on the same worker as the source
eases contention issues but a single stream with many listeners would max
out a worker fairly easy, so we only do this if there are no more than 1000
clients difference.  source clients can also move so this should allow for
a reasonable balance (hope!).

The balance is more like we had before, but now the rwlocks should have less
impact when listeners are spread out over workers.
worker balance work.

The main bits here are to allow for clients to switch workers if the load
differences is worth it.  This means that listeners will move to the source
client worker if not on already but also that it will move away if there is
sufficiently less.  The levels to prevent them happening are initial guesses

To help the routines, a number of underlying changes are done. The least busy
worker is maintained in a global and only updated from the slave thread each
second, saves multiple scanning.   Each worker will attempt to move N clients
when notified by the slave thread, which cycles through the workers 1 per
second.
add per-source outgoing_kbitrate stat

To avoid multiple listeners updating between workers, we use a spin lock
worker balancing tweaks.

make find least busy worker account for pending count and call it
from worker_selected if sufficiently larger from last update.
allow source client to move more easily, may require tighening up
later.

update the use of the find least busy worker routine to account for
pending clients as well. worker_selected may call it if the
increase the level before source will move.

To at least the point where listeners would move away.
try to skip entity decoding if none required.

This is mainly for cases where source material may have either &amp; or &
in them. If it looks like a code to translate then it lets libxml2 try it.
fix segv at server exit, null deref
limiter tweaks for high load

don't add more than 1 block on the reader side
force send limiter to be half it was or 4k, which ever is the higher
don't use a fix offset from the source client time.

Most of the time, listeners are at the beginning of the queue and are
currently scheduled at the same time for processing the send. This works
well to get data out but can trigger a large number of sends all at the
same time, so introduce a small offset that disperses a listener schedule
time within a small range. This should allow a smaller set to go straight
away and some shortly after.