diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-06-05 15:37:33 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-06-10 19:22:13 -0500 |
commit | 30cd559345853e3c057de10d3b21b577082a06c5 (patch) | |
tree | 617b6ab46a9d1f954daabd39fa1f674833e4e60b /include/asterisk/threadpool.h | |
parent | b23f33e7e5bc1524d3e2b3536174590db575055e (diff) |
DNS: Need to use the same serializer for a pjproject SIP transaction.
All send/receive processing for a SIP transaction needs to be done under
the same threadpool serializer to prevent reentrancy problems inside
pjproject when using an external DNS resolver to process messages for the
transaction.
* Add threadpool API call to get the current serializer associated with
the worker thread.
* Pick a serializer from a pool of default serializers if the caller of
res_pjsip.c:ast_sip_push_task() does not provide one.
This is a simple way to ensure that all outgoing SIP request messages are
processed under a serializer. Otherwise, any place where a pushed task is
done that would result in an outgoing out-of-dialog request would need to
be modified to supply a serializer. Serializers from the default
serializer pool are picked in a round robin sequence for simplicity.
A side effect is that the default serializer pool will limit the growth of
the thread pool from random tasks. This is not necessarily a bad thing.
* Made pjsip_resolver.c use the requesting thread's serializer to execute
the async callback.
* Made pjsip_distributor.c save the thread's serializer name on the
outgoing request tdata struct so the response can be processed under the
same serializer.
ASTERISK-25115 #close
Reported by: John Bigelow
Change-Id: Iea71c16ce1132017b5791635e198b8c27973f40a
Diffstat (limited to 'include/asterisk/threadpool.h')
-rw-r--r-- | include/asterisk/threadpool.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/asterisk/threadpool.h b/include/asterisk/threadpool.h index e1e7727f5..1c6705856 100644 --- a/include/asterisk/threadpool.h +++ b/include/asterisk/threadpool.h @@ -196,6 +196,22 @@ int ast_threadpool_push(struct ast_threadpool *pool, int (*task)(void *data), vo void ast_threadpool_shutdown(struct ast_threadpool *pool); /*! + * \brief Get the threadpool serializer currently associated with this thread. + * \since 14.0.0 + * + * \note The returned pointer is valid while the serializer + * thread is running. + * + * \note Use ao2_ref() on serializer if you are going to keep it + * for another thread. To unref it you must then use + * ast_taskprocessor_unreference(). + * + * \retval serializer on success. + * \retval NULL on error or no serializer associated with the thread. + */ +struct ast_taskprocessor *ast_threadpool_serializer_get_current(void); + +/*! * \brief Serialized execution of tasks within a \ref ast_threadpool. * * \since 12.0.0 |