Add apr_pool_mutex_set()

This commit allows adding a mutex to a pool to make low level
allocations thread-safe.

FreeSWITCH users running large production systems have been using this
technique for over five years without incident.

Since the fork, we've added in tree debugging code to check for
contentious use of a pool.  Here we're able to use those hooks to
reduce the size of the present commit.

TODO: Why not guard the destroy operation as well?

Signed-off-by: Anthony Minessale <anthm@freeswitch.org>
Signed-off-by: Travis Cross <tc@traviscross.com>
Return the tag from apr_pool_tag()

This allows the function to be used as an accessor when passed a NULL
tag.

TODO: Explain why this is useful.

Signed-off-by: Anthony Minessale <anthm@freeswitch.org>
Signed-off-by: Travis Cross <tc@traviscross.com>
Add thread priority support for unix and windows

TODO: Describe this mechanism in more detail.

Signed-off-by: Anthony Minessale <anthm@freeswitch.org>
Signed-off-by: Travis Cross <tc@traviscross.com>
Return success if socket is already closed

Prior to this commit, socket_cleanup would return an error if the
socket had already been closed.  With this commit we return success
instead.

TODO: Explain why this is a good idea.
Per Anthony: "fix some close on -1 issues"

Signed-off-by: Anthony Minessale <anthm@freeswitch.org>
Signed-off-by: Travis Cross <tc@traviscross.com>
Add apr_queue_pop_timeout()

This function will pop or get an object from the queue, blocking if
the queue is already empty for up to N microseconds.

Signed-off-by: Anthony Minessale <anthm@freeswitch.org>
Signed-off-by: Travis Cross <tc@traviscross.com>
Include apr_time.h in apr_queue.h

TODO: Explain why this is needed or a good idea.
Per Anthony: "sq queue"

Signed-off-by: Anthony Minessale <anthm@freeswitch.org>
Signed-off-by: Travis Cross <tc@traviscross.com>