[asterisk-commits] rizzo: trunk r47315 - /trunk/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Nov 8 06:44:28 MST 2006
Author: rizzo
Date: Wed Nov 8 07:44:27 2006
New Revision: 47315
URL: http://svn.digium.com/view/asterisk?rev=47315&view=rev
Log:
merge rev.47224 from team/rizzo/astobj2:
hide dialoglist lock/unlocking in wrapper functions.
Approved By: oej
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=47315&r1=47314&r2=47315&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Nov 8 07:44:27 2006
@@ -558,9 +558,6 @@
static int regobjs = 0; /*!< Registry objects */
static struct ast_flags global_flags[2] = {{0}}; /*!< global SIP_ flags */
-
-/*! \brief Protect the SIP dialog list (of sip_pvt's) */
-AST_MUTEX_DEFINE_STATIC(dialoglock);
AST_MUTEX_DEFINE_STATIC(netlock);
@@ -995,6 +992,20 @@
static struct sip_pvt *dialoglist = NULL;
+/*! \brief Protect the SIP dialog list (of sip_pvt's) */
+AST_MUTEX_DEFINE_STATIC(dialoglock);
+
+/*! \brief hide the way the list is locked/unlocked */
+static void dialoglist_lock(void)
+{
+ ast_mutex_lock(&dialoglock);
+}
+
+static void dialoglist_unlock(void)
+{
+ ast_mutex_unlock(&dialoglock);
+}
+
#define FLAG_RESPONSE (1 << 0)
#define FLAG_FATAL (1 << 1)
@@ -2981,7 +2992,7 @@
/* Lock dialog list before removing ourselves from the list */
if (lockdialoglist)
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
for (prev = NULL, cur = dialoglist; cur; prev = cur, cur = cur->next) {
if (cur == p) {
UNLINK(cur, dialoglist, prev);
@@ -2989,7 +3000,7 @@
}
}
if (lockdialoglist)
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
if (!cur) {
ast_log(LOG_WARNING, "Trying to destroy \"%s\", not found in dialog list?!?! \n", p->callid);
return;
@@ -4297,10 +4308,10 @@
ast_string_field_set(p, context, default_context);
/* Add to active dialog list */
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
p->next = dialoglist;
dialoglist = p;
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
if (option_debug)
ast_log(LOG_DEBUG, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
return p;
@@ -4342,7 +4353,7 @@
ast_log(LOG_DEBUG, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
}
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
for (p = dialoglist; p; p = p->next) {
/* In pedantic, we do not want packets with bad syntax to be connected to a PVT */
int found = FALSE;
@@ -4373,11 +4384,11 @@
if (found) {
/* Found the call */
sip_pvt_lock(p);
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
return p;
}
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
/* See if the method is capable of creating a dialog */
if (sip_methods[intended_method].can_create == CAN_CREATE_DIALOG) {
@@ -8506,7 +8517,7 @@
{
struct sip_pvt *sip_pvt_ptr;
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
if (option_debug > 3 && totag)
ast_log(LOG_DEBUG, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
@@ -8546,7 +8557,7 @@
break;
}
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
if (option_debug > 3 && !sip_pvt_ptr)
ast_log(LOG_DEBUG, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
return sip_pvt_ptr;
@@ -10415,7 +10426,7 @@
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
cur = dialoglist;
if (!subscriptions)
ast_cli(fd, FORMAT2, "Peer", "User/ANR", "Call ID", "Seq (Tx/Rx)", "Format", "Hold", "Last Message");
@@ -10452,7 +10463,7 @@
numchans++;
}
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
if (!subscriptions)
ast_cli(fd, "%d active SIP channel%s\n", numchans, (numchans != 1) ? "s" : "");
else
@@ -10471,14 +10482,14 @@
char *c = NULL;
int wordlen = strlen(word);
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
for (cur = dialoglist; cur; cur = cur->next) {
if (!strncasecmp(word, cur->callid, wordlen) && ++which > state) {
c = ast_strdup(cur->callid);
break;
}
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
return c;
}
@@ -10603,7 +10614,7 @@
if (argc != 4)
return RESULT_SHOWUSAGE;
len = strlen(argv[3]);
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
for (cur = dialoglist; cur; cur = cur->next) {
if (!strncasecmp(cur->callid, argv[3], len)) {
char formatbuf[BUFSIZ/2];
@@ -10657,7 +10668,7 @@
found++;
}
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
if (!found)
ast_cli(fd, "No such SIP Call ID starting with '%s'\n", argv[3]);
return RESULT_SUCCESS;
@@ -10675,7 +10686,7 @@
if (!recordhistory)
ast_cli(fd, "\n***Note: History recording is currently DISABLED. Use 'sip history' to ENABLE.\n");
len = strlen(argv[3]);
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
for (cur = dialoglist; cur; cur = cur->next) {
if (!strncasecmp(cur->callid, argv[3], len)) {
struct sip_history *hist;
@@ -10694,7 +10705,7 @@
found++;
}
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
if (!found)
ast_cli(fd, "No such SIP Call ID starting with '%s'\n", argv[3]);
return RESULT_SUCCESS;
@@ -14319,7 +14330,7 @@
for it to expire and send NOTIFY messages to the peer only to have them
ignored (or generate errors)
*/
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
for (p_old = dialoglist; p_old; p_old = p_old->next) {
if (p_old == p)
continue;
@@ -14338,7 +14349,7 @@
}
sip_pvt_unlock(p_old);
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
}
if (!p->expiry)
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
@@ -14848,7 +14859,7 @@
sipsock_read_id = ast_io_change(io, sipsock_read_id, sipsock, NULL, 0, NULL);
}
/* Check for dialogs needing to be killed */
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
restartsearch:
t = time(NULL);
/* don't scan the dialogs list if it hasn't been a reasonable period
@@ -14868,7 +14879,7 @@
}
sip_pvt_unlock(sip);
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
pthread_testcancel();
/* Wait for sched or io */
@@ -17193,13 +17204,13 @@
ast_manager_unregister("SIPpeers");
ast_manager_unregister("SIPshowpeer");
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
/* Hangup all dialogs if they have an owner */
for (p = dialoglist; p ; p = p->next) {
if (p->owner)
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
}
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
ast_mutex_lock(&monlock);
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
@@ -17210,7 +17221,7 @@
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
- ast_mutex_lock(&dialoglock);
+ dialoglist_lock();
/* Destroy all the dialogs and free their memory */
p = dialoglist;
while (p) {
@@ -17219,7 +17230,7 @@
__sip_destroy(pl, TRUE, TRUE);
}
dialoglist = NULL;
- ast_mutex_unlock(&dialoglock);
+ dialoglist_unlock();
/* Free memory for local network address mask */
ast_free_ha(localaddr);
More information about the asterisk-commits
mailing list