[asterisk-commits] seanbright: branch seanbright/resolve-shadow-warnings r114535 - in /team/sean...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 22 12:00:48 CDT 2008


Author: seanbright
Date: Tue Apr 22 12:00:48 2008
New Revision: 114535

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114535
Log:
Merged revisions 114520,114523,114527,114529,114533 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r114520 | murf | 2008-04-22 10:38:46 -0400 (Tue, 22 Apr 2008) | 15 lines


Hopefully, this will resolve the issues that russellb had with this log_show_lock().
I gathered the code that filled the string, and put it in a different func which
I cryptically call "append_lock_information()".
Now, both log_show_lock(), and handle_show_locks() both call this code to do
the work. Tested, seems to work fine. 
Also, log_show_lock was modified to use the ast_str stuff, along with checking
for successful ast_str creation, and freeing the ast_str obj when finished.
A break was inserted to terminate the search for the lock; we should never
see it twice.

An example usage in chan_sip.c was created as a comment, for instructional
purposes.


................
r114523 | russell | 2008-04-22 11:20:53 -0400 (Tue, 22 Apr 2008) | 20 lines

Blocked revisions 114522 via svnmerge

........
r114522 | russell | 2008-04-22 10:20:37 -0500 (Tue, 22 Apr 2008) | 13 lines

Merge changes from team/russell/issue_9520

These changes make sure that the reference count for sip_peer objects properly
reflects the fact that the peer is sitting in the scheduler for a scheduled
callback for qualifying peers or for expiring registrations.  Without this, it
was possible for these callbacks to happen at the same time that the peer was
being destroyed.  This was especially likely to happen with realtime peers, and
for people making use of the realtime prune CLI command.

(closes issue #9520)
Reported by: kryptolus
Committed patch by me

........

................
r114527 | russell | 2008-04-22 11:46:01 -0400 (Tue, 22 Apr 2008) | 8 lines

Correct action_ping() and action_events() with regards to Manager 1.1
documentation.  Also, fix a bug in xml_translate().

(closes issue #11649)
Reported by: ys
Patches:
      trunk_manager.c.diff uploaded by ys (license 281)

................
r114529 | file | 2008-04-22 11:54:06 -0400 (Tue, 22 Apr 2008) | 6 lines

Add support for authenticating on a NOTIFY request. This is useful for phones that require it when sending them a special packet to get them to do something (such as reload their configuration).
(closes issue #9896)
Reported by: IgorG
Patches:
      sipnotify-113980-v14.patch uploaded by IgorG (license 20)

................
r114533 | russell | 2008-04-22 12:47:00 -0400 (Tue, 22 Apr 2008) | 4 lines

Add a c() option for the Jack() application and JACK_HOOK() funciton for supplying
a custom client name.  Using the channel name is still the default.  This was done
at the request of Jared Smith.

................

Modified:
    team/seanbright/resolve-shadow-warnings/   (props changed)
    team/seanbright/resolve-shadow-warnings/CHANGES
    team/seanbright/resolve-shadow-warnings/apps/app_jack.c
    team/seanbright/resolve-shadow-warnings/channels/chan_sip.c
    team/seanbright/resolve-shadow-warnings/configs/sip_notify.conf.sample
    team/seanbright/resolve-shadow-warnings/main/manager.c
    team/seanbright/resolve-shadow-warnings/main/utils.c

Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Apr 22 12:00:48 2008
@@ -1,1 +1,1 @@
-/trunk:1-114518
+/trunk:1-114534

Modified: team/seanbright/resolve-shadow-warnings/CHANGES
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/CHANGES?view=diff&rev=114535&r1=114534&r2=114535
==============================================================================
--- team/seanbright/resolve-shadow-warnings/CHANGES (original)
+++ team/seanbright/resolve-shadow-warnings/CHANGES Tue Apr 22 12:00:48 2008
@@ -6,6 +6,7 @@
 ------------------
  * Added a new dialplan function, AST_CONFIG(), which allows you to access
    variables from an Asterisk configuration file.
+ * The JACK_HOOK function now has a c() option to supply a custom client name.
 
 Zaptel channel driver (chan_zap) Changes
 ----------------------------------------
@@ -31,6 +32,7 @@
    continue in the dialplan, at the specified label, if the caller hangs up.
  * ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the
    technology name (e.g. SIP, IAX, etc) of the channel being spied on.
+ * The Jack application now has a c() option to supply a custom client name.
 
 SIP Changes
 -----------

Modified: team/seanbright/resolve-shadow-warnings/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/apps/app_jack.c?view=diff&rev=114535&r1=114534&r2=114535
==============================================================================
--- team/seanbright/resolve-shadow-warnings/apps/app_jack.c (original)
+++ team/seanbright/resolve-shadow-warnings/apps/app_jack.c Tue Apr 22 12:00:48 2008
@@ -65,7 +65,9 @@
 "    o(<name>) - Connect the input port that gets created to the specified\n" \
 "                jack output port.\n" \
 "    n         - Do not automatically start the JACK server if it is not already\n" \
-"                running.\n"
+"                running.\n" \
+"    c(<name>) - By default, Asterisk will use the channel name for the jack client\n" \
+"                name.  Use this option to specify a custom client name.\n"
 
 static char *jack_app = "JACK";
 static char *jack_synopsis = 
@@ -82,6 +84,7 @@
 struct jack_data {
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(server_name);
+		AST_STRING_FIELD(client_name);
 		AST_STRING_FIELD(connect_input_port);
 		AST_STRING_FIELD(connect_output_port);
 	);
@@ -350,13 +353,17 @@
 
 static int init_jack_data(struct ast_channel *chan, struct jack_data *jack_data)
 {
-	const char *chan_name;
+	const char *client_name;
 	jack_status_t status = 0;
 	jack_options_t jack_options = JackNullOption;
 
-	ast_channel_lock(chan);
-	chan_name = ast_strdupa(chan->name);
-	ast_channel_unlock(chan);
+	if (!ast_strlen_zero(jack_data->client_name)) {
+		client_name = jack_data->client_name;
+	} else {
+		ast_channel_lock(chan);
+		client_name = ast_strdupa(chan->name);
+		ast_channel_unlock(chan);
+	}
 
 	if (!(jack_data->output_rb = jack_ringbuffer_create(RINGBUFFER_SIZE)))
 		return -1;
@@ -369,10 +376,10 @@
 
 	if (!ast_strlen_zero(jack_data->server_name)) {
 		jack_options |= JackServerName;
-		jack_data->client = jack_client_open(chan_name, jack_options, &status,
+		jack_data->client = jack_client_open(client_name, jack_options, &status,
 			jack_data->server_name);
 	} else {
-		jack_data->client = jack_client_open(chan_name, jack_options, &status);
+		jack_data->client = jack_client_open(client_name, jack_options, &status);
 	}
 
 	if (status)
@@ -610,12 +617,15 @@
 	OPT_INPUT_PORT =     (1 << 1),
 	OPT_OUTPUT_PORT =    (1 << 2),
 	OPT_NOSTART_SERVER = (1 << 3),
+	OPT_CLIENT_NAME =    (1 << 4),
 };
 
 enum {
 	OPT_ARG_SERVER_NAME,
 	OPT_ARG_INPUT_PORT,
 	OPT_ARG_OUTPUT_PORT,
+	OPT_ARG_CLIENT_NAME,
+
 	/* Must be the last element */
 	OPT_ARG_ARRAY_SIZE,
 };
@@ -625,6 +635,7 @@
 	AST_APP_OPTION_ARG('i', OPT_INPUT_PORT, OPT_ARG_INPUT_PORT),
 	AST_APP_OPTION_ARG('o', OPT_OUTPUT_PORT, OPT_ARG_OUTPUT_PORT),
 	AST_APP_OPTION('n', OPT_NOSTART_SERVER),
+	AST_APP_OPTION_ARG('c', OPT_CLIENT_NAME, OPT_ARG_CLIENT_NAME),
 END_OPTIONS );
 
 static struct jack_data *jack_data_alloc(void)
@@ -660,6 +671,15 @@
 			ast_string_field_set(jack_data, server_name, option_args[OPT_ARG_SERVER_NAME]);
 		else {
 			ast_log(LOG_ERROR, "A server name must be provided with the s() option\n");
+			return -1;
+		}
+	}
+
+	if (ast_test_flag(&options, OPT_CLIENT_NAME)) {
+		if (!ast_strlen_zero(option_args[OPT_ARG_CLIENT_NAME]))
+			ast_string_field_set(jack_data, client_name, option_args[OPT_ARG_CLIENT_NAME]);
+		else {
+			ast_log(LOG_ERROR, "A client name must be provided with the c() option\n");
 			return -1;
 		}
 	}

Modified: team/seanbright/resolve-shadow-warnings/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/chan_sip.c?view=diff&rev=114535&r1=114534&r2=114535
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/chan_sip.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/chan_sip.c Tue Apr 22 12:00:48 2008
@@ -1278,6 +1278,7 @@
 	struct ast_channel *owner;		/*!< Who owns us (if we have an owner) */
 	struct sip_route *route;		/*!< Head of linked list of routing steps (fm Record-Route) */
 	int route_persistant;			/*!< Is this the "real" route? */
+	struct ast_variable *notify_headers;    /*!< Custom notify type */	
 	struct sip_auth *peerauth;		/*!< Realm authentication */
 	int noncecount;				/*!< Nonce-count */
 	char lastmsg[256];			/*!< Last Message sent/received */
@@ -1832,7 +1833,6 @@
 static int __sip_reliable_xmit(struct sip_pvt *p, int seqno, int resp, struct ast_str *data, int len, int fatal, int sipmethod);
 static int __transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
 static int retrans_pkt(const void *data);
-static int transmit_sip_request(struct sip_pvt *p, struct sip_request *req);
 static int transmit_response_using_temp(ast_string_field callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method, const struct sip_request *req, const char *msg);
 static int transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req);
 static int transmit_response_reliable(struct sip_pvt *p, const char *msg, const struct sip_request *req);
@@ -1852,6 +1852,7 @@
 static int transmit_refer(struct sip_pvt *p, const char *dest);
 static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs, char *vmexten);
 static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq, char *message, int terminate);
+static int transmit_notify_custom(struct sip_pvt *p, struct ast_variable *vars);
 static int transmit_register(struct sip_registry *r, int sipmethod, const char *auth, const char *authheader);
 static int send_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno);
 static int send_request(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno);
@@ -1990,7 +1991,7 @@
 static char *sip_do_debug_ip(int fd, char *arg);
 static char *sip_do_debug_peer(int fd, char *arg);
 static char *sip_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-static char *sip_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static char *sip_do_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static char *sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static int sip_dtmfmode(struct ast_channel *chan, void *data);
@@ -2133,6 +2134,7 @@
 
 /*------Response handling functions */
 static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
+static void handle_response_notify(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
 static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
 static int handle_response_register(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
 static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
@@ -4575,6 +4577,10 @@
 	if (p->options)
 		ast_free(p->options);
 
+	if (p->notify_headers) {
+		ast_variables_destroy(p->notify_headers);
+		p->notify_headers = NULL;
+	}
 	if (p->rtp) {
 		ast_rtp_destroy(p->rtp);
 	}
@@ -9002,6 +9008,7 @@
 static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
 {
 	struct sip_request req;
+	struct ast_variable *var;
 	
 	req.method = sipmethod;
 	if (init) {/* Bump branch even on initial requests */
@@ -9050,6 +9057,14 @@
 
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
+
+	if(p->notify_headers) {
+		char buf[512];
+		for (var = p->notify_headers; var; var = var->next) {
+			ast_copy_string(buf, var->value, sizeof(buf));
+			add_header(&req, var->name, ast_unescape_semicolon(buf));
+		}
+	}
 	if (p->options && p->options->addsipheaders && p->owner) {
 		struct ast_channel *chan = p->owner; /* The owner channel */
 		struct varshead *headp;
@@ -9098,7 +9113,9 @@
 		} else if (p->rtp) 
 			add_sdp(&req, p, FALSE);
 	} else {
-		add_header_contentLength(&req, 0);
+		if (!p->notify_headers) {
+			add_header_contentLength(&req, 0);
+		}
 	}
 
 	if (!p->initreq.headers)
@@ -9107,7 +9124,7 @@
 	return send_request(p, &req, init ? XMIT_CRITICAL : XMIT_RELIABLE, p->ocseq);
 }
 
-/*! \brief Used in the SUBSCRIBE notification subsystem */
+/*! \brief Used in the SUBSCRIBE notification subsystem (RFC3265) */
 static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)
 {
 	struct ast_str *tmp = ast_str_alloca(4000);
@@ -9290,7 +9307,7 @@
 	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
 }
 
-/*! \brief Notify user of messages waiting in voicemail
+/*! \brief Notify user of messages waiting in voicemail (RFC3842)
 \note	- Notification only works for registered peers with mailbox= definitions
 	in sip.conf
 	- We use the SIP Event package message-summary
@@ -9329,15 +9346,7 @@
 	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
 }
 
-/*! \brief Transmit SIP request unreliably (only used in sip_notify subsystem) */
-static int transmit_sip_request(struct sip_pvt *p, struct sip_request *req)
-{
-	if (!p->initreq.headers) 	/* Initialize first request before sending */
-		initialize_initreq(p, req);
-	return send_request(p, req, XMIT_UNRELIABLE, p->ocseq);
-}
-
-/*! \brief Notify a transferring party of the status of transfer */
+/*! \brief Notify a transferring party of the status of transfer (RFC3515) */
 static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq, char *message, int terminate)
 {
 	struct sip_request req;
@@ -9361,6 +9370,32 @@
 	p->lastnoninvite = p->ocseq;
 
 	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
+}
+
+/*! \brief Notify device with custom headers from sip_notify.conf */
+static int transmit_notify_custom(struct sip_pvt *p, struct ast_variable *vars) {
+	struct sip_request req;
+	struct ast_variable *var, *newvar;
+
+	initreqprep(&req, p, SIP_NOTIFY);
+
+	/* Copy notify vars and add headers */
+	p->notify_headers = newvar = ast_variable_new("Subscription-State", "terminated", "");
+	add_header(&req, newvar->name, newvar->value);
+	for (var = vars; var; var = var->next) {
+		char buf[512];
+		ast_debug(2, "  Adding pair %s=%s\n", var->name, var->value);
+		ast_copy_string(buf, var->value, sizeof(buf));
+		add_header(&req, var->name, ast_unescape_semicolon(buf));
+		newvar->next = ast_variable_new(var->name, var->value, "");
+		newvar = newvar->next;
+	}
+
+	if (!p->initreq.headers) { /* Initialize first request before sending */
+		initialize_initreq(p, &req);
+	}
+
+	return send_request(p, &req, XMIT_UNRELIABLE, p->ocseq);
 }
 
 static const struct _map_x_s regstatestrings[] = {
@@ -12927,8 +12962,10 @@
 	struct sip_pvt *dialog = dialogobj;
 	time_t *t = arg;
 	
+	/* log_show_lock(ao2_object_get_lockaddr(dialog)); this is an example of how to use log_show_lock() */
 	if (sip_pvt_trylock(dialog)) {
-		/* this path gets executed fairly frequently (3% or so) even in low load
+		/* In very short-duration calls via sipp,
+		   this path gets executed fairly frequently (3% or so) even in low load
 		   situations; the routines we most commonly fight for a lock with:
 		   sip_answer (7 out of 9)
 		   sip_hangup (2 out of 9)
@@ -14687,7 +14724,7 @@
 }
 
 /*! \brief Cli command to send SIP notify to peer */
-static char *sip_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_variable *varlist;
 	int i;
@@ -14704,7 +14741,6 @@
 		return complete_sipnotify(a->line, a->word, a->pos, a->n);
 	}
 
-
 	if (a->argc < 4)
 		return CLI_SHOWUSAGE;
 
@@ -14722,8 +14758,6 @@
 
 	for (i = 3; i < a->argc; i++) {
 		struct sip_pvt *p;
-		struct sip_request req;
-		struct ast_variable *var;
 
 		if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY))) {
 			ast_log(LOG_WARNING, "Unable to build sip pvt data for notify (memory/socket error)\n");
@@ -14739,13 +14773,8 @@
 			continue;
 		}
 
-		initreqprep(&req, p, SIP_NOTIFY);
-
-		for (var = varlist; var; var = var->next) {
-			char buf[512];
-			ast_copy_string(buf, var->value, sizeof(buf));
-			add_header(&req, var->name, ast_unescape_semicolon(buf));
-		}
+		/* Notify is outgoing call */
+		ast_set_flag(&p->flags[0], SIP_OUTGOING);
 
 		/* Recalculate our side, and recalculate Call ID */
 		ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
@@ -14755,9 +14784,8 @@
 		ao2_t_link(dialogs, p, "Linking in new name");
 		ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n", a->argv[2], a->argv[i]);
 		dialog_ref(p, "bump the count of p, which transmit_sip_request will decrement.");
-		transmit_sip_request(p, &req);
-		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
-		dialog_unref(p, "unref pvt at end of for loop in sip_notify");
+		sip_scheddestroy(p, SIP_TRANS_TIMEOUT);
+		transmit_notify_custom(p, varlist);
 	}
 
 	return CLI_SUCCESS;
@@ -15730,6 +15758,51 @@
 		ast_log(LOG_WARNING, "Could not transmit message in dialog %s\n", p->callid);
 }
 
+/* \brief Handle SIP response in NOTIFY transaction
+       We've sent a NOTIFY, now handle responses to it
+  */
+static void handle_response_notify(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
+{
+	switch (resp) {
+	case 200:   /* Notify accepted */
+		/* They got the notify, this is the end */
+		if (p->owner) {
+			if (!p->refer) {
+				ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name);
+				ast_queue_hangup(p->owner);
+			} else {
+				ast_debug(4, "Got OK on REFER Notify message\n");
+			}
+		} else {
+			if (p->subscribed == NONE) {
+				ast_debug(4, "Got 200 accepted on NOTIFY\n");
+				p->needdestroy = 1;
+			}
+			if (ast_test_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE)) {
+				/* Ready to send the next state we have on queue */
+				ast_clear_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE);
+				cb_extensionstate((char *)p->context, (char *)p->exten, p->laststate, (void *) p);
+			}
+		}
+		break;
+	case 401:   /* Not www-authorized on SIP method */
+	case 407:   /* Proxy auth */
+		if (!p->notify_headers) {
+			break; /* Only device notify can use NOTIFY auth */
+		}
+		ast_string_field_set(p, theirtag, NULL);
+		if (ast_strlen_zero(p->authname)) {
+			ast_log(LOG_WARNING, "Asked to authenticate NOTIFY to %s:%d but we have no matching peer or realm auth!\n", ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
+			p->needdestroy = 1;
+		}
+		if (p->authtries > 1 || do_proxy_auth(p, req, resp, SIP_NOTIFY, 0)) {
+			ast_log(LOG_NOTICE, "Failed to authenticate on NOTYFY to '%s'\n", get_header(&p->initreq, "From"));
+			p->needdestroy = 1;
+		}
+		break;
+	}
+}
+
 /* \brief Handle SIP response in REFER transaction
 	We've sent a REFER, now handle responses to it 
   */
@@ -16079,22 +16152,7 @@
 			} else if (sipmethod == SIP_INVITE) {
 				handle_response_invite(p, resp, rest, req, seqno);
 			} else if (sipmethod == SIP_NOTIFY) {
-				/* They got the notify, this is the end */
-				if (p->owner) {
-					if (!p->refer) {
-						ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name);
-						ast_queue_hangup(p->owner);
-					} else
-						ast_debug(4, "Got OK on REFER Notify message\n");
-				} else {
-					if (p->subscribed == NONE) 
-						p->needdestroy = 1;
-					if (ast_test_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE)) {
-						/* Ready to send the next state we have on queue */
-						ast_clear_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE);
-						cb_extensionstate((char *)p->context, (char *)p->exten, p->laststate, (void *) p);
-					}
-				}
+				handle_response_notify(p, resp, rest, req, seqno);
 			} else if (sipmethod == SIP_REGISTER) 
 				res = handle_response_register(p, resp, rest, req, seqno);
 			else if (sipmethod == SIP_BYE)		/* Ok, we're ready to go */
@@ -16108,6 +16166,8 @@
 		case 407: /* Proxy auth required */
 			if (sipmethod == SIP_INVITE)
 				handle_response_invite(p, resp, rest, req, seqno);
+			else if (sipmethod == SIP_NOTIFY)
+				handle_response_notify(p, resp, rest, req, seqno);
 			else if (sipmethod == SIP_REFER)
 				handle_response_refer(p, resp, rest, req, seqno);
 			else if (p->registry && sipmethod == SIP_REGISTER)
@@ -22404,7 +22464,7 @@
 	AST_CLI_DEFINE(sip_show_registry, "List SIP registration status"),
 	AST_CLI_DEFINE(sip_unregister, "Unregister (force expiration) a SIP peer from the registery\n"),
 	AST_CLI_DEFINE(sip_show_settings, "Show SIP global settings"),
-	AST_CLI_DEFINE(sip_notify, "Send a notify packet to a SIP peer"),
+	AST_CLI_DEFINE(sip_cli_notify, "Send a notify packet to a SIP peer"),
 	AST_CLI_DEFINE(sip_show_channel, "Show detailed SIP channel info"),
 	AST_CLI_DEFINE(sip_show_history, "Show SIP dialog history"),
 	AST_CLI_DEFINE(sip_show_peer, "Show details on specific SIP peer"),

Modified: team/seanbright/resolve-shadow-warnings/configs/sip_notify.conf.sample
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/configs/sip_notify.conf.sample?view=diff&rev=114535&r1=114534&r2=114535
==============================================================================
--- team/seanbright/resolve-shadow-warnings/configs/sip_notify.conf.sample (original)
+++ team/seanbright/resolve-shadow-warnings/configs/sip_notify.conf.sample Tue Apr 22 12:00:48 2008
@@ -2,9 +2,20 @@
 Event=>check-sync
 Content-Length=>0
 
-; Untested
 [sipura-check-cfg]
 Event=>resync
+Content-Length=>0
+
+[linksys-cold-restart]
+Event=>reboot_now
+Content-Length=>0
+
+[linksys-warm-restart]
+Event=>restart_now
+Content-Length=>0
+
+[sipura-get-report]
+Event=>report
 Content-Length=>0
 
 ; Untested
@@ -16,17 +27,14 @@
 Event=>check-sync
 Content-Length=>0
 
-; Tested
 [snom-check-cfg]
 Event=>check-sync\;reboot=false
 Content-Length=>0
 
-; Tested
 [aastra-check-cfg]
 Event=>check-sync
 Content-Length=>0
 
-; Tested
 [aastra-xml]
 Event=>aastra-xml
 Content-Length=>0

Modified: team/seanbright/resolve-shadow-warnings/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/main/manager.c?view=diff&rev=114535&r1=114534&r2=114535
==============================================================================
--- team/seanbright/resolve-shadow-warnings/main/manager.c (original)
+++ team/seanbright/resolve-shadow-warnings/main/manager.c Tue Apr 22 12:00:48 2008
@@ -1064,7 +1064,8 @@
 
 static int action_ping(struct mansession *s, const struct message *m)
 {
-	astman_send_response(s, m, "Success", "Ping: Pong\r\n");
+	astman_append(s, "Response: Success\r\n"
+			 "Ping: Pong\r\n");
 	return 0;
 }
 
@@ -1576,10 +1577,11 @@
 
 	res = set_eventmask(s, mask);
 	if (res > 0)
-		astman_send_response(s, m, "Success", "Events: On\r\n");
+		astman_append(s, "Response: Success\r\n"
+				 "Events: On\r\n");
 	else if (res == 0)
-		astman_send_response(s, m, "Success", "Events: Off\r\n");
-
+		astman_append(s, "Response: Success\r\n"
+				 "Events: Off\r\n");
 	return 0;
 }
 
@@ -3431,11 +3433,13 @@
 				ast_str_append(out, 0, xml ? "'" : "</td></tr>\n");
 				in_data = 0;
 			}
-			ast_str_append(out, 0, xml ? " /></response>\n" :
-				"<tr><td colspan=\"2\"><hr></td></tr>\r\n");
-			inobj = 0;
-			ao2_ref(vco, -1);
-			vco = NULL;
+			if (inobj) {
+				ast_str_append(out, 0, xml ? " /></response>\n" :
+					"<tr><td colspan=\"2\"><hr></td></tr>\r\n");
+				inobj = 0;
+				ao2_ref(vco, -1);
+				vco = NULL;
+			}
 			continue;
 		}
 

Modified: team/seanbright/resolve-shadow-warnings/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/main/utils.c?view=diff&rev=114535&r1=114534&r2=114535
==============================================================================
--- team/seanbright/resolve-shadow-warnings/main/utils.c (original)
+++ team/seanbright/resolve-shadow-warnings/main/utils.c Tue Apr 22 12:00:48 2008
@@ -714,52 +714,86 @@
 	return "UNKNOWN";
 }
 
-/*! \todo this function is very broken and duplicates a lot of code ... */
+static void append_lock_information(struct ast_str **str, struct thr_lock_info *lock_info, int i)
+{
+	int j;
+	ast_mutex_t *lock;
+	
+	ast_str_append(str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", 
+				   lock_info->locks[i].pending > 0 ? "Waiting for " : 
+				   lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i,
+				   lock_info->locks[i].file, 
+				   locktype2str(lock_info->locks[i].type),
+				   lock_info->locks[i].line_num,
+				   lock_info->locks[i].func, lock_info->locks[i].lock_name,
+				   lock_info->locks[i].lock_addr, 
+				   lock_info->locks[i].times_locked);
+	
+	if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
+		return;
+	
+	/* We only have further details for mutexes right now */
+	if (lock_info->locks[i].type != AST_MUTEX)
+		return;
+	
+	lock = lock_info->locks[i].lock_addr;
+	
+	ast_reentrancy_lock(lock);
+	for (j = 0; *str && j < lock->reentrancy; j++) {
+		ast_str_append(str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n",
+					   lock->file[j], lock->lineno[j], lock->func[j]);
+	}
+	ast_reentrancy_unlock(lock);	
+}
+
+
+/*! This function can help you find highly temporal locks; locks that happen for a 
+    short time, but at unexpected times, usually at times that create a deadlock,
+	Why is this thing locked right then? Who is locking it? Who am I fighting
+    with for this lock? 
+
+	To answer such questions, just call this routine before you would normally try
+	to aquire a lock. It doesn't do anything if the lock is not acquired. If the
+	lock is taken, it will publish a line or two to the console via ast_log().
+
+	Sometimes, the lock message is pretty uninformative. For instance, you might
+	find that the lock is being aquired deep within the astobj2 code; this tells
+	you little about higher level routines that call the astobj2 routines.
+	But, using gdb, you can set a break at the ast_log below, and for that
+	breakpoint, you can set the commands:
+	  where
+	  cont
+	which will give a stack trace and continue. -- that aught to do the job!
+
+*/
 void log_show_lock(void *this_lock_addr)
 {
 	struct thr_lock_info *lock_info;
-	struct ast_str *str = NULL;
+	struct ast_str *str;
+
+	if (!(str = ast_str_create(4096))) {
+		ast_log(LOG_NOTICE,"Could not create str\n");
+		return;
+	}
+	
 
 	pthread_mutex_lock(&lock_infos_lock.mutex);
 	AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) {
 		int i;
 		pthread_mutex_lock(&lock_info->lock);
 		for (i = 0; str && i < lock_info->num_locks; i++) {
-			int j;
-			ast_mutex_t *lock;
+			/* ONLY show info about this particular lock, if
+			   it's acquired... */
 			if (lock_info->locks[i].lock_addr == this_lock_addr) {
-				
-				ast_log(LOG_NOTICE, "---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", 
-						lock_info->locks[i].pending > 0 ? "Waiting for " : lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", 
-						i,
-						lock_info->locks[i].file, 
-						locktype2str(lock_info->locks[i].type),
-						lock_info->locks[i].line_num,
-						lock_info->locks[i].func, 
-						lock_info->locks[i].lock_name,
-						lock_info->locks[i].lock_addr, 
-						lock_info->locks[i].times_locked);
-				
-				if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
-					continue;
-				
-				/* We only have further details for mutexes right now */
-				if (lock_info->locks[i].type != AST_MUTEX)
-					continue;
-				
-				lock = lock_info->locks[i].lock_addr;
-				
-				ast_reentrancy_lock(lock);
-				for (j = 0; str && j < lock->reentrancy; j++) {
-					ast_log(LOG_NOTICE, "--- ---> Locked Here: %s line %d (%s)\n",
-								   lock->file[j], lock->lineno[j], lock->func[j]);
-				}
-				ast_reentrancy_unlock(lock);	
+				append_lock_information(&str, lock_info, i);
+				ast_log(LOG_NOTICE, "%s", str->str);
+				break;
 			}
 		}
 		pthread_mutex_unlock(&lock_info->lock);
 	}
 	pthread_mutex_unlock(&lock_infos_lock.mutex);
+	ast_free(str);
 }
 
 
@@ -802,34 +836,7 @@
 			lock_info->thread_name);
 		pthread_mutex_lock(&lock_info->lock);
 		for (i = 0; str && i < lock_info->num_locks; i++) {
-			int j;
-			ast_mutex_t *lock;
-
-			ast_str_append(&str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", 
-				lock_info->locks[i].pending > 0 ? "Waiting for " : 
-					lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i,
-				lock_info->locks[i].file, 
-				locktype2str(lock_info->locks[i].type),
-				lock_info->locks[i].line_num,
-				lock_info->locks[i].func, lock_info->locks[i].lock_name,
-				lock_info->locks[i].lock_addr, 
-				lock_info->locks[i].times_locked);
-
-			if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
-				continue;
-
-			/* We only have further details for mutexes right now */
-			if (lock_info->locks[i].type != AST_MUTEX)
-				continue;
-
-			lock = lock_info->locks[i].lock_addr;
-
-			ast_reentrancy_lock(lock);
-			for (j = 0; str && j < lock->reentrancy; j++) {
-				ast_str_append(&str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n",
-					lock->file[j], lock->lineno[j], lock->func[j]);
-			}
-			ast_reentrancy_unlock(lock);	
+			append_lock_information(&str, lock_info, i);
 		}
 		pthread_mutex_unlock(&lock_info->lock);
 		if (!str)




More information about the asterisk-commits mailing list