mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 10:22:46 +00:00
Merge "pjsip: Fix deadlock with suspend taskprocessor on masquerade" into 13
This commit is contained in:
@@ -241,6 +241,38 @@ struct ast_taskprocessor_local {
|
||||
int ast_taskprocessor_push_local(struct ast_taskprocessor *tps,
|
||||
int (*task_exe)(struct ast_taskprocessor_local *local), void *datap);
|
||||
|
||||
/*!
|
||||
* \brief Indicate the taskprocessor is suspended.
|
||||
*
|
||||
* \since 13.12.0
|
||||
*
|
||||
* \param tps Task processor.
|
||||
* \retval 0 success
|
||||
* \retval -1 failure
|
||||
*/
|
||||
int ast_taskprocessor_suspend(struct ast_taskprocessor *tps);
|
||||
|
||||
/*!
|
||||
* \brief Indicate the taskprocessor is unsuspended.
|
||||
*
|
||||
* \since 13.12.0
|
||||
*
|
||||
* \param tps Task processor.
|
||||
* \retval 0 success
|
||||
* \retval -1 failure
|
||||
*/
|
||||
int ast_taskprocessor_unsuspend(struct ast_taskprocessor *tps);
|
||||
|
||||
/*!
|
||||
* \brief Get the task processor suspend status
|
||||
*
|
||||
* \since 13.12.0
|
||||
*
|
||||
* \param tps Task processor.
|
||||
* \retval non-zero if the task processor is suspended
|
||||
*/
|
||||
int ast_taskprocessor_is_suspended(struct ast_taskprocessor *tps);
|
||||
|
||||
/*!
|
||||
* \brief Pop a task off the taskprocessor and execute it.
|
||||
*
|
||||
|
@@ -91,6 +91,8 @@ struct ast_taskprocessor {
|
||||
unsigned int high_water_warned:1;
|
||||
/*! Indicates that a high water alert is active on this taskprocessor */
|
||||
unsigned int high_water_alert:1;
|
||||
/*! Indicates if the taskprocessor is currently suspended */
|
||||
unsigned int suspended:1;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -910,6 +912,33 @@ int ast_taskprocessor_push_local(struct ast_taskprocessor *tps, int (*task_exe)(
|
||||
return taskprocessor_push(tps, tps_task_alloc_local(task_exe, datap));
|
||||
}
|
||||
|
||||
int ast_taskprocessor_suspend(struct ast_taskprocessor *tps)
|
||||
{
|
||||
if (tps) {
|
||||
ao2_lock(tps);
|
||||
tps->suspended = 1;
|
||||
ao2_unlock(tps);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ast_taskprocessor_unsuspend(struct ast_taskprocessor *tps)
|
||||
{
|
||||
if (tps) {
|
||||
ao2_lock(tps);
|
||||
tps->suspended = 0;
|
||||
ao2_unlock(tps);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ast_taskprocessor_is_suspended(struct ast_taskprocessor *tps)
|
||||
{
|
||||
return tps ? tps->suspended : -1;
|
||||
}
|
||||
|
||||
int ast_taskprocessor_execute(struct ast_taskprocessor *tps)
|
||||
{
|
||||
struct ast_taskprocessor_local local;
|
||||
|
@@ -1559,6 +1559,11 @@ void ast_sip_session_suspend(struct ast_sip_session *session)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ast_taskprocessor_is_suspended(session->serializer)) {
|
||||
/* The serializer already suspended. */
|
||||
return;
|
||||
}
|
||||
|
||||
suspender = ao2_alloc(sizeof(*suspender), sip_session_suspender_dtor);
|
||||
if (!suspender) {
|
||||
/* We will just have to hope that the system does not deadlock */
|
||||
@@ -1583,6 +1588,8 @@ void ast_sip_session_suspend(struct ast_sip_session *session)
|
||||
ast_cond_wait(&suspender->cond_suspended, ao2_object_get_lockaddr(suspender));
|
||||
}
|
||||
ao2_unlock(suspender);
|
||||
|
||||
ast_taskprocessor_suspend(session->serializer);
|
||||
}
|
||||
|
||||
void ast_sip_session_unsuspend(struct ast_sip_session *session)
|
||||
@@ -1602,6 +1609,8 @@ void ast_sip_session_unsuspend(struct ast_sip_session *session)
|
||||
ao2_unlock(suspender);
|
||||
|
||||
ao2_ref(suspender, -1);
|
||||
|
||||
ast_taskprocessor_unsuspend(session->serializer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Reference in New Issue
Block a user