Changeset 5003

Spy list now only needs the head.

We don't have to keep the list ordered so we don't need both a head
and a tail. This allows us to save a few bytes per channel and have
more straightforward code.

This commit changes (yet again) the size and layout of the cw_channel
structure.

Committed by:  karvan
Date:  Jun 27 2008 * 22:27 (5 months ago)

Affected files:

callweaver/trunk/apps/icd/icd_command.c (unified diff)

r4992r5003
14481448 cw_cli_command(fd, buf);
14491449 return 0;
14501450 }
1451 if(chan->spies.head != NULL){
1451 if(chan->spies != NULL){
14521452 cw_log(CW_LOG_NOTICE, "Start of recording for customer [%s] failed - already recording \n", customer_source);
14531453 manager_event(EVENT_FLAG_USER, "icd_command",
14541454 "Command: Record\r\nSubCommand: Start\r\nResult: Fail\r\nCause: Already recording\r\nCallerID: %s\r\n",

callweaver/trunk/apps/icd/icd_conference.c (unified diff)

r4999r5003
521521
522522 /* This part of code (if) is for ZAP channels to make possible for muxmon to record 2 channels */
523523 if(!strcmp(chan->type, "DAHDI")){
524 if (chan->spies.head && (read_frame->frametype == CW_FRAME_VOICE)
524 if (chan->spies && (read_frame->frametype == CW_FRAME_VOICE)
525525 && (read_frame->subclass == icd_conf_format)) {
526526 struct cw_channel_spy *spying;
527 for (spying = chan->spies.head; spying; spying=spying->next) {
527 for (spying = chan->spies; spying; spying=spying->next) {
528528 cw_spy_queue_frame(spying, read_frame, 1);
529529 }
530530 }

callweaver/trunk/corelib/channel.c (unified diff)

r4999r5003
10621062 {
10631063 struct cw_channel_spy *chanspy;
10641064
1065 for (chanspy = chan->spies.head; chanspy; chanspy = chanspy->next)
1065 for (chanspy = chan->spies; chanspy; chanspy = chanspy->next)
10661066 {
10671067 if (chanspy->status == CHANSPY_RUNNING)
10681068 chanspy->status = CHANSPY_DONE;
10691069 }
1070 chan->spies.head = chan->spies.tail = NULL;
1070 chan->spies = NULL;
10711071 }
10721072
10731073 /*--- cw_spy_attach: Attach another spy in the given channel. */
------
10821082 struct cw_channel *peer;
10831083
10841084 cw_mutex_lock(&chan->lock);
1085 if (chan->spies.head) {
1086 chan->spies.tail->next = newspy;
1087 chan->spies.tail = newspy;
1088 } else {
1089 chan->spies.head = chan->spies.tail = newspy;
1090 }
1085 newspy->next = chan->spies;
1086 chan->spies = newspy;
10911087 cw_mutex_unlock(&chan->lock);
10921088 if (cw_test_flag(chan, CW_FLAG_NBRIDGE)
10931089 && (peer = cw_bridged_channel(chan)))
------
11051101 void cw_spy_detach(struct cw_channel *chan, struct cw_channel_spy *oldspy)
11061102 {
11071103 struct cw_channel_spy *cur, *prev = NULL;
1108 for (cur = chan->spies.head ; cur && cur != oldspy; cur = cur->next) {
1104 for (cur = chan->spies ; cur && cur != oldspy; cur = cur->next) {
11091105 prev = cur;
11101106 }
11111107 if (cur) { /* We found the spy in our list. */
1112 if (chan->spies.head == cur)
1113 chan->spies.head = cur->next;
1108 if (chan->spies == cur)
1109 chan->spies = cur->next;
11141110 else
11151111 prev->next = cur->next;
1116 if (chan->spies.tail == cur)
1117 chan->spies.tail = prev;
11181112 } else { /* Is this ever possible? */
11191113 cw_log(CW_LOG_WARNING, "Unknown spy in cw_spy_detach().\n");
11201114 }
------
18261820 }
18271821 else
18281822 {
1829 if (chan->spies.head)
1823 if (chan->spies)
18301824 {
18311825 struct cw_channel_spy *spying;
18321826
1833 for (spying = chan->spies.head; spying; spying = spying->next)
1827 for (spying = chan->spies; spying; spying = spying->next)
18341828 cw_spy_queue_frame(spying, f, 0);
18351829 }
18361830 if (chan->monitor && chan->monitor->read_stream)
------
22542248 * let the channel driver use a writer thread
22552249 * to actually write the stuff, for example. */
22562250
2257 if (f->frametype == CW_FRAME_VOICE && chan->spies.head)
2251 if (f->frametype == CW_FRAME_VOICE && chan->spies)
22582252 {
22592253 struct cw_channel_spy *spying;
22602254
2261 for (spying = chan->spies.head; spying; spying = spying->next)
2255 for (spying = chan->spies; spying; spying = spying->next)
22622256 cw_spy_queue_frame(spying, f, 1);
22632257 }
22642258
------
36523646 if (c0->tech->bridge &&
36533647 (config->timelimit == 0) &&
36543648 (c0->tech->bridge == c1->tech->bridge) &&
3655 !nativefailed && !c0->monitor && !c1->monitor && !c0->spies.head && !c1->spies.head)
3649 !nativefailed && !c0->monitor && !c1->monitor && !c0->spies && !c1->spies)
36563650 {
36573651 /* Looks like they share a bridge method */
36583652 if (option_verbose > 2)

callweaver/trunk/include/callweaver/channel.h (unified diff)

r4999r5003
338338 int rawwriteformat;
339339
340340 /*! Chan Spy stuff */
341 struct {
342 struct cw_channel_spy *head;
343 struct cw_channel_spy *tail;
344 } spies;
341 struct cw_channel_spy *spies;
345342
346343 /*! For easy linking */
347344 struct cw_channel *next;