aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-09 01:45:08 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-09 01:45:08 +0000
commit7d00f23ad44d18c7041c925f7f556d5d1fe641ac (patch)
treee9c8ee99dcb97720b3dfb49c87b2f2c0b6f6f6b6 /channels
parent523e96fd0323806ed98ca6ce3e58831fc5a392dc (diff)
Merge FreeBSD locking fixes (bug #1411)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3176 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_agent.c4
-rwxr-xr-xchannels/chan_alsa.c2
-rwxr-xr-xchannels/chan_h323.c6
-rwxr-xr-xchannels/chan_iax.c4
-rwxr-xr-xchannels/chan_iax2.c6
-rwxr-xr-xchannels/chan_local.c4
-rwxr-xr-xchannels/chan_mgcp.c10
-rwxr-xr-xchannels/chan_modem.c6
-rwxr-xr-xchannels/chan_modem_aopen.c2
-rwxr-xr-xchannels/chan_modem_bestdata.c2
-rwxr-xr-xchannels/chan_modem_i4l.c2
-rwxr-xr-xchannels/chan_nbs.c2
-rwxr-xr-xchannels/chan_oss.c2
-rwxr-xr-xchannels/chan_phone.c6
-rwxr-xr-xchannels/chan_sip.c26
-rwxr-xr-xchannels/chan_skinny.c10
-rwxr-xr-xchannels/chan_vofr.c6
-rwxr-xr-xchannels/chan_vpb.c8
-rwxr-xr-xchannels/chan_zap.c6
19 files changed, 60 insertions, 54 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index cc35c3ee5..f91c6324b 100755
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -91,10 +91,10 @@ static int wrapuptime;
static int ackcall;
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of sip_pvt's) */
-static ast_mutex_t agentlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(agentlock);
static int recordagentcalls = 0;
static char recordformat[AST_MAX_BUF];
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 8446a7a93..d78ee0f20 100755
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -77,7 +77,7 @@ static int silencethreshold = 1000;
static char digits[80] = "";
static char text2send[80] = "";
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
static char *type = "Console";
static char *desc = "ALSA Console Channel Driver";
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 20f8cd1ea..6c49f227c 100755
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -141,15 +141,15 @@ static struct sched_context *sched;
static struct io_context *io;
/** Protect the interface list (of oh323_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
/** Usage counter and associated lock */
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
diff --git a/channels/chan_iax.c b/channels/chan_iax.c
index d1be19183..b8a48fed2 100755
--- a/channels/chan_iax.c
+++ b/channels/chan_iax.c
@@ -80,7 +80,7 @@
#define GAMMA (0.01)
#ifdef MYSQL_FRIENDS
-static ast_mutex_t mysqllock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(mysqllock);
static MYSQL *mysql;
static char mydbuser[80];
static char mydbpass[80];
@@ -112,7 +112,7 @@ static int tos = 0;
static int expirey = AST_DEFAULT_REG_EXPIRE;
static int usecnt;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
int (*iax_regfunk)(char *username, int onoff) = NULL;
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 25097ac4a..a89a0f557 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -100,7 +100,7 @@
#define GAMMA (0.01)
#ifdef MYSQL_FRIENDS
-static ast_mutex_t mysqllock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(mysqllock);
static MYSQL *mysql;
static char mydbuser[80];
static char mydbpass[80];
@@ -138,7 +138,7 @@ static int expirey = IAX_DEFAULT_REG_EXPIRE;
static int timingfd = -1; /* Timing file descriptor */
static int usecnt;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
int (*iax2_regfunk)(char *username, int onoff) = NULL;
@@ -269,7 +269,7 @@ static struct iax2_trunk_peer {
int calls;
} *tpeers = NULL;
-static ast_mutex_t tpeerlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(tpeerlock);
struct iax_firmware {
struct iax_firmware *next;
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 86ed6d17a..c6cb4c7cf 100755
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -49,12 +49,12 @@ static char *tdesc = "Local Proxy Channel Driver";
static int capability = -1;
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
#define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
/* Protect the interface list (of sip_pvt's) */
-static ast_mutex_t locallock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(locallock);
static struct local_pvt {
ast_mutex_t lock; /* Channel private lock */
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 27adaccfa..740731eab 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -199,7 +199,7 @@ static int adsi = 0;
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* SC: transaction id should always be positive */
static unsigned int oseq;
@@ -214,9 +214,9 @@ static int matchdigittimeout = 3000;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(netlock);
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
@@ -419,10 +419,10 @@ static struct mgcp_gateway {
struct mgcp_gateway *next;
} *gateways;
-static ast_mutex_t mgcp_reload_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(mgcp_reload_lock);
static int mgcp_reloading = 0;
-static ast_mutex_t gatelock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(gatelock);
static int mgcpsock = -1;
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index 728aa361a..905a15d28 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -72,14 +72,14 @@ static int baudrate = 115200;
static int stripmsd = 0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of ast_modem_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
diff --git a/channels/chan_modem_aopen.c b/channels/chan_modem_aopen.c
index 4222e85cd..c123bfddf 100755
--- a/channels/chan_modem_aopen.c
+++ b/channels/chan_modem_aopen.c
@@ -34,7 +34,7 @@ static char *breakcmd = "\0x10\0x03";
static char *desc = "A/Open (Rockwell Chipset) ITU-2 VoiceModem Driver";
static int usecnt;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
static char *aopen_idents[] = {
/* Identify A/Open Modem */
diff --git a/channels/chan_modem_bestdata.c b/channels/chan_modem_bestdata.c
index 10732dca7..7eca76519 100755
--- a/channels/chan_modem_bestdata.c
+++ b/channels/chan_modem_bestdata.c
@@ -39,7 +39,7 @@ static char *breakcmd = "\020!";
static char *desc = "BestData (Conexant V.90 Chipset) VoiceModem Driver";
static int usecnt;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
static char *bestdata_idents[] = {
/* Identify BestData Modem */
diff --git a/channels/chan_modem_i4l.c b/channels/chan_modem_i4l.c
index a8d08a631..a7c28b621 100755
--- a/channels/chan_modem_i4l.c
+++ b/channels/chan_modem_i4l.c
@@ -34,7 +34,7 @@ static char *breakcmd = "\0x10\0x14\0x10\0x3";
static char *desc = "ISDN4Linux Emulated Modem Driver";
static int usecnt;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
static char *i4l_idents[] = {
/* Identify ISDN4Linux Driver */
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index b4e5392c4..700dcc643 100755
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -41,7 +41,7 @@ static int usecnt =0;
/* Only linear is allowed */
static int prefformat = AST_FORMAT_SLINEAR;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
static char context[AST_MAX_EXTENSION] = "default";
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 731ae30ee..7bd7ddb8c 100755
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -70,7 +70,7 @@ static int silencesuppression = 0;
static int silencethreshold = 1000;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
static char *type = "Console";
static char *desc = "OSS Console Channel Driver";
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 3e1a28b4b..8b2261cbb 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -76,14 +76,14 @@ static int silencesupression = 0;
static int prefformat = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of phone_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3c0dc2b56..74d84bd89 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -108,7 +108,7 @@ static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
/* MYSQL_FRIENDS: Check if peer exists in database and read some configuration
from databse (not all options supported though) */
#ifdef MYSQL_FRIENDS
-static ast_mutex_t mysqllock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(mysqllock);
static MYSQL *mysql;
static char mydbuser[80];
static char mydbpass[80];
@@ -155,16 +155,16 @@ static int globalrtptimeout = 0;
static int globalrtpholdtimeout = 0;
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of sip_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(netlock);
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
@@ -430,7 +430,7 @@ struct sip_peer {
struct sip_peer *next;
};
-static ast_mutex_t sip_reload_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(sip_reload_lock);
static int sip_reloading = 0;
#define REG_STATE_UNREGISTERED 0
@@ -467,20 +467,20 @@ struct sip_registry {
static struct ast_user_list {
struct sip_user *users;
ast_mutex_t lock;
-} userl = { NULL, AST_MUTEX_INITIALIZER };
+} userl;
/*--- The peer list: Peers and Friends ---*/
static struct ast_peer_list {
struct sip_peer *peers;
ast_mutex_t lock;
-} peerl = { NULL, AST_MUTEX_INITIALIZER };
+} peerl;
/*--- The register list: Other SIP proxys we register with and call ---*/
static struct ast_register_list {
struct sip_registry *registrations;
ast_mutex_t lock;
int recheck;
-} regl = { NULL, AST_MUTEX_INITIALIZER };
+} regl;
#define REINVITE_INVITE 1
@@ -1368,6 +1368,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
ast_sched_del(sched, cp->retransid);
free(cp);
}
+ ast_mutex_destroy(&p->lock);
free(p);
}
}
@@ -2018,6 +2019,7 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
struct sip_pvt *p;
p = malloc(sizeof(struct sip_pvt));
+ ast_mutex_init(&p->lock);
if (!p)
return NULL;
/* Keep track of stuff */
@@ -2035,6 +2037,7 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
p->ocseq = 101;
if (!p->rtp) {
ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno));
+ ast_mutex_destroy(&p->lock);
free(p);
return NULL;
}
@@ -2049,7 +2052,6 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
if (p->vrtp)
ast_rtp_setnat(p->vrtp, p->nat);
}
- ast_mutex_init(&p->lock);
if (sin) {
memcpy(&p->sa, sin, sizeof(p->sa));
@@ -8039,6 +8041,10 @@ int load_module()
int res;
struct sip_peer *peer;
struct sip_registry *reg;
+
+ ast_mutex_init(&userl.lock);
+ ast_mutex_init(&peerl.lock);
+ ast_mutex_init(&regl.lock);
sched = sched_context_create();
if (!sched) {
ast_log(LOG_WARNING, "Unable to create schedule context\n");
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 22b07c597..bb8a9a9c8 100755
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -585,17 +585,17 @@ static struct io_context *io;
/* usage count and locking */
static int usecnt = 0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* Protect the network socket */
-static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(netlock);
/* Protect the session list */
-static ast_mutex_t sessionlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(sessionlock);
/* Protect the device list */
-static ast_mutex_t devicelock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(devicelock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
diff --git a/channels/chan_vofr.c b/channels/chan_vofr.c
index 444701fd7..7ab952dc2 100755
--- a/channels/chan_vofr.c
+++ b/channels/chan_vofr.c
@@ -53,14 +53,14 @@ static char context[AST_MAX_EXTENSION] = "default";
static char language[MAX_LANGUAGE] = "";
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of vofr_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c
index c578946e0..7528a0f20 100755
--- a/channels/chan_vpb.c
+++ b/channels/chan_vpb.c
@@ -69,14 +69,14 @@ static int gruntdetect_timeout = 3600000; /* Grunt detect timeout is 1hr. */
static const int prefformat = AST_FORMAT_SLINEAR;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of vpb_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
@@ -171,7 +171,7 @@ typedef struct {
static vpb_bridge_t * bridges;
static int max_bridges = MAX_BRIDGES_V4PCI;
-static ast_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(bridge_lock);
typedef enum {
vpb_model_unknown = 0,
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 58a67ddf0..076ad18a1 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -241,16 +241,16 @@ static int gendigittimeout = 8000;
static int matchdigittimeout = 3000;
static int usecnt =0;
-static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of zt_pvt's) */
-static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(iflock);
static int ifcount = 0;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(monlock);
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */