Review Board 1.7.16


Implement ast_channel_search_locked to expensive per-notify channel walk in chan_sip

Review Request #28 - Created Nov. 4, 2008 and submitted

Sean Bright
Reviewers
asterisk-dev
Asterisk
Based on some feedback from my chan_sip commit earlier today from oej, kpfleming, and russellb, implement ast_channel_search_locked which iterates over the channel list, while locked, and calls a filter callback to determine if this is the channel we are looking for.  If so, we lock and return, otherwise we return NULL.

Patch also includes the change required to chan_sip.c to use the new function.

 

Diff revision 2 (Latest)

1 2
1 2

  1. /trunk/channels/chan_sip.c: Loading...
  2. /trunk/include/asterisk/channel.h: Loading...
  3. /trunk/main/channel.c: Loading...
/trunk/channels/chan_sip.c
Revision 154189 New Change
[20] 10034 lines
[+20] [+] static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)
10035

    
   
10035

   
10036
			/* There are some limitations to how this works.  The primary one is that the
10036
			/* There are some limitations to how this works.  The primary one is that the
10037
			   callee must be dialing the same extension that is being monitored.  Simply dialing
10037
			   callee must be dialing the same extension that is being monitored.  Simply dialing
10038
			   the hint'd device is not sufficient. */
10038
			   the hint'd device is not sufficient. */
10039
			if (global_notifycid) {
10039
			if (global_notifycid) {
10040
				struct ast_channel *caller = NULL;
10040
				auto int find_calling_channel(struct ast_channel *c);

    
   
10041
				int find_calling_channel(struct ast_channel *c) {

    
   
10042
					return (c->pbx &&

    
   
10043
							(!strcasecmp(c->macroexten, p->exten) || !strcasecmp(c->exten, p->exten)) &&

    
   
10044
							!strcasecmp(c->context, p->context));

    
   
10045
				}

    
   
10046

   

    
   
10047
				struct ast_channel *caller = ast_channel_search_locked(find_calling_channel);
10041

    
   
10048

   
10042
				while ((caller = ast_channel_walk_locked(caller))) {
10049
				if (caller) {
10043
					if (caller->pbx &&

   
10044
						(!strcasecmp(caller->macroexten, p->exten) || !strcasecmp(caller->exten, p->exten)) &&

   
10045
						!strcasecmp(caller->context, p->context)) {

   
10046
						local_display = ast_strdupa(caller->cid.cid_name);
10050
					local_display = ast_strdupa(caller->cid.cid_name);
10047
						local_target = ast_strdupa(caller->cid.cid_num);
10051
					local_target = ast_strdupa(caller->cid.cid_num);
10048
						ast_channel_unlock(caller);
10052
					ast_channel_unlock(caller);
10049
						break;
10053
					caller = NULL;
10050
					}
10054
				}
10051
					ast_channel_unlock(caller);

   
10052
				}				

   
10053
			}
10055
			}
10054

    
   
10056

   
10055
			/* We create a fake call-id which the phone will send back in an INVITE
10057
			/* We create a fake call-id which the phone will send back in an INVITE
10056
			   Replaces header which we can grab and do some magic with. */
10058
			   Replaces header which we can grab and do some magic with. */
10057
			ast_str_append(&tmp, 0, 
10059
			ast_str_append(&tmp, 0, 
[+20] [20] 13894 lines
/trunk/include/asterisk/channel.h
Revision 154189 New Change
 
/trunk/main/channel.c
Revision 154189 New Change
 
  1. /trunk/channels/chan_sip.c: Loading...
  2. /trunk/include/asterisk/channel.h: Loading...
  3. /trunk/main/channel.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.