mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
Fix a potential race condition when creating a software based mixing bridge.
It was possible for no timer to become available between creating the bridge and starting it. We now open a timer when creating it and keep it open until the bridge is destroyed. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184628 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -91,7 +91,7 @@ static int softmix_bridge_create(struct ast_bridge *bridge)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_timer_close(timingfd);
|
bridge->bridge_pvt = (void*)(unsigned long)timingfd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -199,11 +199,7 @@ static int softmix_bridge_poke(struct ast_bridge *bridge, struct ast_bridge_chan
|
|||||||
/*! \brief Function which acts as the mixing thread */
|
/*! \brief Function which acts as the mixing thread */
|
||||||
static int softmix_bridge_thread(struct ast_bridge *bridge)
|
static int softmix_bridge_thread(struct ast_bridge *bridge)
|
||||||
{
|
{
|
||||||
int timingfd;
|
int timingfd = (unsigned short)(unsigned long)bridge->bridge_pvt;
|
||||||
|
|
||||||
if ((timingfd = ast_timer_open()) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ast_timer_set_rate(timingfd, (1000 / SOFTMIX_INTERVAL));
|
ast_timer_set_rate(timingfd, (1000 / SOFTMIX_INTERVAL));
|
||||||
|
|
||||||
@@ -267,7 +263,6 @@ static int softmix_bridge_thread(struct ast_bridge *bridge)
|
|||||||
ao2_lock(bridge);
|
ao2_lock(bridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_timer_set_rate(timingfd, 0);
|
|
||||||
ast_timer_close(timingfd);
|
ast_timer_close(timingfd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user