[asterisk-commits] russell: branch 1.4 r79301 - /branches/1.4/channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 13 15:37:51 CDT 2007


Author: russell
Date: Mon Aug 13 15:37:50 2007
New Revision: 79301

URL: http://svn.digium.com/view/asterisk?view=rev&rev=79301
Log:
Don't call find_peer in registry_authrequest with the pvt lock held to avoid a
deadlock.

Modified:
    branches/1.4/channels/chan_iax2.c

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=79301&r1=79300&r2=79301
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Mon Aug 13 15:37:50 2007
@@ -5794,13 +5794,21 @@
 	return send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGACK, 0, ied.buf, ied.pos, -1);
 }
 
-static int registry_authrequest(const char *name, int callno)
+static int registry_authrequest(int callno)
 {
 	struct iax_ie_data ied;
 	struct iax2_peer *p;
 	char challenge[10];
+	const char *peer_name;
+
+	peer_name = ast_strdupa(iaxs[callno]->peer);
+
 	/* SLD: third call to find_peer in registration */
-	p = find_peer(name, 1);
+	ast_mutex_unlock(&iaxsl[callno]);
+	p = find_peer(peer_name, 1);
+	ast_mutex_lock(&iaxsl[callno]);
+	if (!iaxs[callno])
+		return -1;
 	if (p) {
 		memset(&ied, 0, sizeof(ied));
 		iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods);
@@ -5811,12 +5819,12 @@
 			/* snprintf(iaxs[callno]->challenge, sizeof(iaxs[callno]->challenge), "%d", (int)ast_random()); */
 			iax_ie_append_str(&ied, IAX_IE_CHALLENGE, iaxs[callno]->challenge);
 		}
-		iax_ie_append_str(&ied, IAX_IE_USERNAME, name);
+		iax_ie_append_str(&ied, IAX_IE_USERNAME, peer_name);
 		if (ast_test_flag(p, IAX_TEMPONLY))
 			destroy_peer(p);
 		return send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGAUTH, 0, ied.buf, ied.pos, -1);;
 	} 
-	ast_log(LOG_WARNING, "No such peer '%s'\n", name);
+	ast_log(LOG_WARNING, "No such peer '%s'\n", peer_name);
 	return 0;
 }
 
@@ -7650,7 +7658,11 @@
 					}
 					break;
 				}
-				registry_authrequest(iaxs[fr->callno]->peer, fr->callno);
+				registry_authrequest(fr->callno);
+				if (!iaxs[fr->callno]) {
+					ast_mutex_unlock(&iaxsl[fr->callno]);
+					return 1;
+				}
 				break;
 			case IAX_COMMAND_REGACK:
 				if (iax2_ack_registry(&ies, &sin, fr->callno)) 




More information about the asterisk-commits mailing list