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.

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.  This is useful for e.g. debugging printf's.

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

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.

This is useful, for example, if a socket is closed manually and we
then try to close it again as part of the cleanup of a pool.

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>