Merged revisions 41768,41827,41830,41880,41882,41989,42014,42054 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r41768 | file | 2006-09-01 18:49:07 -0400 (Fri, 01 Sep 2006) | 2 lines

Only wipe the redirected audio & video IP/port if it's specified, and trigger a reinvite.

........
r41827 | bweschke | 2006-09-03 10:16:08 -0400 (Sun, 03 Sep 2006) | 3 lines

 Setting a retry of 0 is generally not a good idea and shouldn't be allowed. (#7574 - reported by regin)


........
r41830 | bweschke | 2006-09-03 10:50:59 -0400 (Sun, 03 Sep 2006) | 3 lines

 Let's NOT spy on Zap/psuedo channels, mmmmmmmmk? 


........
r41880 | bweschke | 2006-09-03 13:13:38 -0400 (Sun, 03 Sep 2006) | 3 lines

 Don't keep trying the same member in certain strategies when members of the queue are unavailable (#7278 - diLLec reported and patched) - This should have been patched here first and then merged into /trunk. My bad!


........
r41882 | bweschke | 2006-09-03 13:38:22 -0400 (Sun, 03 Sep 2006) | 3 lines

 Make sure the forwarded channel inherits variables appropriately when we receive a call forward in the queue. (#7867 - raarts reported and patched)


........
r41989 | oej | 2006-09-04 11:46:07 -0400 (Mon, 04 Sep 2006) | 2 lines

Don't kill the pvt before we have sent ACK on CANCEL (needs more testing before making a release)

........
r42014 | qwell | 2006-09-05 12:27:46 -0400 (Tue, 05 Sep 2006) | 4 lines

Small typo in zapata.conf.sample

Reported by ppyy in 7881

........
r42054 | file | 2006-09-05 16:02:48 -0400 (Tue, 05 Sep 2006) | 2 lines

Merge in last round of spy fixes. This should hopefully eliminate all the issues people have been seeing by distinctly separating what each component (core/spy) is responsible for. Core is responsible for adding a spy to a channel, feeding frames to the spy, removing the spy from a channel, and telling the spy to stop. Spy is responsible for reading frames in, and cleaning up after itself.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@42081 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2006-09-05 23:48:48 +00:00
parent e9cce1551a
commit 6480d28862
7 changed files with 137 additions and 99 deletions

111
channel.c
View File

@@ -1017,22 +1017,59 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
return 0;
}
/* Clean up a channel's spy information */
static void spy_cleanup(struct ast_channel *chan)
{
if (AST_LIST_EMPTY(&chan->spies->list))
return;
if (chan->spies->read_translator.path)
ast_translator_free_path(chan->spies->read_translator.path);
if (chan->spies->write_translator.path)
ast_translator_free_path(chan->spies->write_translator.path);
free(chan->spies);
chan->spies = NULL;
return;
}
/* Detach a spy from it's channel */
static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan)
{
ast_mutex_lock(&spy->lock);
/* We only need to poke them if they aren't already done */
if (spy->status != CHANSPY_DONE) {
spy->status = CHANSPY_STOP;
spy->chan = NULL;
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
ast_cond_signal(&spy->trigger);
}
/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
ast_mutex_unlock(&spy->lock);
return;
}
void ast_channel_spy_stop_by_type(struct ast_channel *chan, const char *type)
{
struct ast_channel_spy *spy;
struct ast_channel_spy *spy = NULL;
if (!chan->spies)
return;
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
ast_mutex_lock(&spy->lock);
if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) {
spy->status = CHANSPY_STOP;
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
ast_cond_signal(&spy->trigger);
}
ast_mutex_unlock(&spy->lock);
ast_mutex_unlock(&spy->lock);
AST_LIST_REMOVE_CURRENT(&chan->spies->list, list);
spy_detach(spy, chan);
} else
ast_mutex_unlock(&spy->lock);
}
AST_LIST_TRAVERSE_SAFE_END
spy_cleanup(chan);
}
void ast_channel_spy_trigger_wait(struct ast_channel_spy *spy)
@@ -1049,65 +1086,59 @@ void ast_channel_spy_trigger_wait(struct ast_channel_spy *spy)
void ast_channel_spy_remove(struct ast_channel *chan, struct ast_channel_spy *spy)
{
struct ast_frame *f;
if (!chan->spies)
return;
AST_LIST_REMOVE(&chan->spies->list, spy, list);
ast_mutex_lock(&spy->lock);
spy_detach(spy, chan);
spy_cleanup(chan);
}
spy->chan = NULL;
void ast_channel_spy_free(struct ast_channel_spy *spy)
{
struct ast_frame *f = NULL;
for (f = spy->read_queue.head; f; f = spy->read_queue.head) {
spy->read_queue.head = f->next;
ast_frfree(f);
}
if (spy->status == CHANSPY_DONE)
return;
/* Switch status to done in case we get called twice */
spy->status = CHANSPY_DONE;
/* Drop any frames in the queue */
for (f = spy->write_queue.head; f; f = spy->write_queue.head) {
spy->write_queue.head = f->next;
ast_frfree(f);
}
for (f = spy->read_queue.head; f; f= spy->read_queue.head) {
spy->read_queue.head = f->next;
ast_frfree(f);
}
/* Destroy the condition if in use */
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
ast_cond_destroy(&spy->trigger);
ast_mutex_unlock(&spy->lock);
/* Destroy our mutex since it is no longer in use */
ast_mutex_destroy(&spy->lock);
ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n",
spy->type, chan->name);
if (AST_LIST_EMPTY(&chan->spies->list)) {
if (chan->spies->read_translator.path)
ast_translator_free_path(chan->spies->read_translator.path);
if (chan->spies->write_translator.path)
ast_translator_free_path(chan->spies->write_translator.path);
free(chan->spies);
chan->spies = NULL;
}
return;
}
static void detach_spies(struct ast_channel *chan)
{
struct ast_channel_spy *spy;
struct ast_channel_spy *spy = NULL;
if (!chan->spies)
return;
/* Marking the spies as done is sufficient. Chanspy or spy users will get the picture. */
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
ast_mutex_lock(&spy->lock);
spy->chan = NULL;
if (spy->status == CHANSPY_RUNNING)
spy->status = CHANSPY_DONE;
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
ast_cond_signal(&spy->trigger);
ast_mutex_unlock(&spy->lock);
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
AST_LIST_REMOVE_CURRENT(&chan->spies->list, list);
spy_detach(spy, chan);
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list)
ast_channel_spy_remove(chan, spy);
AST_LIST_TRAVERSE_SAFE_END;
spy_cleanup(chan);
}
/*--- ast_softhangup_nolock: Softly hangup a channel, don't lock */