Totally revamp thread debugging to support locating and removing deadlocks
authorMark Spencer <markster@digium.com>
Wed, 13 Aug 2003 15:25:16 +0000 (15:25 +0000)
committerMark Spencer <markster@digium.com>
Wed, 13 Aug 2003 15:25:16 +0000 (15:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1310 65c4cc65-6c06-0410-ace0-fbb531ad65f3

76 files changed:
Makefile
apps/app_intercom.c
apps/app_macro.c
apps/app_meetme.c
apps/app_queue.c
apps/app_voicemail2.c
asterisk.c
astmm.c
autoservice.c
cdr.c
cdr/cdr_mysql.c
channel.c
channels/chan_agent.c
channels/chan_alsa.c
channels/chan_iax.c
channels/chan_iax2.c
channels/chan_local.c
channels/chan_mgcp.c
channels/chan_modem.c
channels/chan_modem_aopen.c
channels/chan_modem_bestdata.c
channels/chan_modem_i4l.c
channels/chan_nbs.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_vofr.c
channels/chan_vpb.c
channels/chan_zap.c
channels/chan_zap_old.c
cli.c
codecs/codec_a_mu.c
codecs/codec_adpcm.c
codecs/codec_alaw.c
codecs/codec_g723_1.c
codecs/codec_gsm.c
codecs/codec_ilbc.c
codecs/codec_lpc10.c
codecs/codec_mp3_d.c
codecs/codec_speex.c
codecs/codec_ulaw.c
db.c
enum.c
file.c
formats/format_g723.c
formats/format_g729.c
formats/format_gsm.c
formats/format_h263.c
formats/format_mp3.c
formats/format_pcm.c
formats/format_pcm_alaw.c
formats/format_vox.c
formats/format_wav.c
formats/format_wav_gsm.c
frame.c
image.c
include/asterisk/channel.h
include/asterisk/indications.h
include/asterisk/linkedlists.h
include/asterisk/lock.h
include/asterisk/manager.h
include/asterisk/module.h
indications.c
loader.c
logger.c
manager.c
pbx.c
pbx/pbx_config.c
pbx/pbx_gtkconsole.c
res/res_crypto.c
res/res_indications.c
res/res_monitor.c
res/res_musiconhold.c
res/res_parking.c
rtp.c
translate.c

index 0c53598..960df72 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ DEBUG=-g #-pg
 OPTIONS += -DNEW_PRI_HANGUP
 
 # Optional debugging parameters
-DEBUG_THREADS = #-DDO_CRASH -DDEBUG_THREADS
+DEBUG_THREADS = #-DDEBUG_THREADS #-DDO_CRASH 
 
 # Uncomment next one to enable ast_frame tracing (for debugging)
 TRACE_FRAMES = #-DTRACE_FRAMES
index bf139e0..c4be328 100755 (executable)
@@ -52,26 +52,26 @@ STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
 
-static pthread_mutex_t sound_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t sound_lock = AST_MUTEX_INITIALIZER;
 static int sound = -1;
 
 static int write_audio(short *data, int len)
 {
        int res;
        struct audio_buf_info info;
-       ast_pthread_mutex_lock(&sound_lock);
+       ast_mutex_lock(&sound_lock);
        if (sound < 0) {
                ast_log(LOG_WARNING, "Sound device closed?\n");
-               ast_pthread_mutex_unlock(&sound_lock);
+               ast_mutex_unlock(&sound_lock);
                return -1;
        }
     if (ioctl(sound, SNDCTL_DSP_GETOSPACE, &info)) {
                ast_log(LOG_WARNING, "Unable to read output space\n");
-               ast_pthread_mutex_unlock(&sound_lock);
+               ast_mutex_unlock(&sound_lock);
         return -1;
     }
        res = write(sound, data, len);
-       ast_pthread_mutex_unlock(&sound_lock);
+       ast_mutex_unlock(&sound_lock);
        return res;
 }
 
index 331e550..4ea0947 100755 (executable)
@@ -59,7 +59,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
   char varname[80];
   char *oldargs[MAX_ARGS + 1] = { NULL, };
   int argc, x;
-  int res;
+  int res=0;
   char oldexten[256]="";
   int oldpriority;
   char pc[80];
index 12b0ce5..a26392d 100755 (executable)
@@ -72,7 +72,7 @@ static struct conf {
        struct conf *next;
 } *confs;
 
-static pthread_mutex_t conflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t conflock = AST_MUTEX_INITIALIZER;
 
 #include "enter.h"
 #include "leave.h"
@@ -112,7 +112,7 @@ static void conf_play(struct conf *conf, int sound)
 {
        unsigned char *data;
        int len;
-       ast_pthread_mutex_lock(&conflock);
+       ast_mutex_lock(&conflock);
        switch(sound) {
        case ENTER:
                data = enter;
@@ -128,14 +128,14 @@ static void conf_play(struct conf *conf, int sound)
        }
        if (data) 
                careful_write(conf->fd, data, len);
-       pthread_mutex_unlock(&conflock);
+       ast_mutex_unlock(&conflock);
 }
 
 static struct conf *build_conf(char *confno, int make)
 {
        struct conf *cnf;
        struct zt_confinfo ztc;
-       ast_pthread_mutex_lock(&conflock);
+       ast_mutex_lock(&conflock);
        cnf = confs;
        while(cnf) {
                if (!strcmp(confno, cnf->confno)) 
@@ -179,7 +179,7 @@ static struct conf *build_conf(char *confno, int make)
 cnfout:
        if (cnf && make) 
                cnf->users++;
-       ast_pthread_mutex_unlock(&conflock);
+       ast_mutex_unlock(&conflock);
        return cnf;
 }
 
@@ -431,7 +431,7 @@ zapretry:
 
 outrun:
 
-       ast_pthread_mutex_lock(&conflock);
+       ast_mutex_lock(&conflock);
        /* Clean up */
        conf->users--;
        if (!conf->users) {
@@ -453,7 +453,7 @@ outrun:
                close(conf->fd);
                free(conf);
        }
-       pthread_mutex_unlock(&conflock);
+       ast_mutex_unlock(&conflock);
        return ret;
 }
 
index 8417833..43440e4 100755 (executable)
@@ -145,7 +145,7 @@ struct member {
 };
 
 struct ast_call_queue {
-       pthread_mutex_t lock;   
+       ast_mutex_t     lock;   
        char name[80];                  /* Name of the queue */
        char moh[80];                   /* Name of musiconhold to be used */
        char announce[80];              /* Announcement to play */
@@ -170,7 +170,7 @@ struct ast_call_queue {
 };
 
 static struct ast_call_queue *queues = NULL;
-static pthread_mutex_t qlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t qlock = AST_MUTEX_INITIALIZER;
 
 static char *int2strat(int strategy)
 {
@@ -198,12 +198,12 @@ static int join_queue(char *queuename, struct queue_ent *qe)
        struct queue_ent *cur, *prev = NULL;
        int res = -1;
        int pos = 0;
-       ast_pthread_mutex_lock(&qlock);
+       ast_mutex_lock(&qlock);
        q = queues;
        while(q) {
                if (!strcasecmp(q->name, queuename)) {
                        /* This is our one */
-                       ast_pthread_mutex_lock(&q->lock);
+                       ast_mutex_lock(&q->lock);
                        if (q->members && (!q->maxlen || (q->count < q->maxlen))) {
                                /* There's space for us, put us at the end */
                                prev = NULL;
@@ -234,12 +234,12 @@ static int join_queue(char *queuename, struct queue_ent *qe)
 ast_log(LOG_NOTICE, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
 #endif
                        }
-                       ast_pthread_mutex_unlock(&q->lock);
+                       ast_mutex_unlock(&q->lock);
                        break;
                }
                q = q->next;
        }
-       ast_pthread_mutex_unlock(&qlock);
+       ast_mutex_unlock(&qlock);
        return res;
 }
 
@@ -258,7 +258,7 @@ static void free_members(struct ast_call_queue *q)
 static void destroy_queue(struct ast_call_queue *q)
 {
        struct ast_call_queue *cur, *prev = NULL;
-       ast_pthread_mutex_lock(&qlock);
+       ast_mutex_lock(&qlock);
        cur = queues;
        while(cur) {
                if (cur == q) {
@@ -271,7 +271,7 @@ static void destroy_queue(struct ast_call_queue *q)
                }
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&qlock);
+       ast_mutex_unlock(&qlock);
        free_members(q);
        free(q);
 }
@@ -284,7 +284,7 @@ static void leave_queue(struct queue_ent *qe)
        q = qe->parent;
        if (!q)
                return;
-       ast_pthread_mutex_lock(&q->lock);
+       ast_mutex_lock(&q->lock);
 
        prev = NULL;
        cur = q->head;
@@ -310,7 +310,7 @@ ast_log(LOG_NOTICE, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name
                }
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&q->lock);
+       ast_mutex_unlock(&q->lock);
        if (q->dead && !q->count) {     
                /* It's dead and nobody is in it, so kill it */
                destroy_queue(q);
@@ -591,9 +591,9 @@ static int wait_our_turn(struct queue_ent *qe)
        int res = 0;
        for (;;) {
                /* Atomically read the parent head */
-               pthread_mutex_lock(&qe->parent->lock);
+               ast_mutex_lock(&qe->parent->lock);
                ch = qe->parent->head;
-               pthread_mutex_unlock(&qe->parent->lock);
+               ast_mutex_unlock(&qe->parent->lock);
                /* If we are now at the top of the head, break out */
                if (qe->parent->head == qe)
                        break;
@@ -610,7 +610,7 @@ static int update_queue(struct ast_call_queue *q, struct localuser *user)
        struct member *cur;
        /* Since a reload could have taken place, we have to traverse the list to
                be sure it's still valid */
-       ast_pthread_mutex_lock(&q->lock);
+       ast_mutex_lock(&q->lock);
        cur = q->members;
        while(cur) {
                if (user->member == cur) {
@@ -620,7 +620,7 @@ static int update_queue(struct ast_call_queue *q, struct localuser *user)
                }
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&q->lock);
+       ast_mutex_unlock(&q->lock);
        return 0;
 }
 
@@ -692,7 +692,7 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
        char *announce = NULL;
        char digit = 0;
        /* Hold the lock while we setup the outgoing calls */
-       ast_pthread_mutex_lock(&qe->parent->lock);
+       ast_mutex_lock(&qe->parent->lock);
        cur = qe->parent->members;
        if (strlen(qe->announce))
                announce = qe->announce;
@@ -759,7 +759,7 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
                to = -1;
        if (qe->parent->strategy)
                ring_one(qe, outgoing);
-       ast_pthread_mutex_unlock(&qe->parent->lock);
+       ast_mutex_unlock(&qe->parent->lock);
        lpeer = wait_for_answer(qe, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, &digit);
        if (lpeer)
                peer = lpeer->chan;
@@ -846,9 +846,9 @@ static int wait_a_bit(struct queue_ent *qe)
 {
        int retrywait;
        /* Hold the lock while we setup the outgoing calls */
-       ast_pthread_mutex_lock(&qe->parent->lock);
+       ast_mutex_lock(&qe->parent->lock);
        retrywait = qe->parent->retry * 1000;
-       ast_pthread_mutex_unlock(&qe->parent->lock);
+       ast_mutex_unlock(&qe->parent->lock);
        return ast_waitfordigit(qe->chan, retrywait);
 }
 
@@ -941,7 +941,7 @@ static int rqm_exec(struct ast_channel *chan, void *data)
        {
                while( q && ( res != 0 ) && (!found) ) 
                {
-                       ast_pthread_mutex_lock(&q->lock);
+                       ast_mutex_lock(&q->lock);
                        if( strcmp( q->name, queuename) == 0 )
                        {
                                // found queue, try to remove  interface
@@ -977,7 +977,7 @@ static int rqm_exec(struct ast_channel *chan, void *data)
                                                "Not there\n", interface, queuename);
                        }
 
-                       ast_pthread_mutex_unlock(&q->lock);
+                       ast_mutex_unlock(&q->lock);
                        q = q->next;
                }
        }
@@ -1026,7 +1026,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
        {
                while( q && ( res != 0 ) && (!found) ) 
                {
-                       ast_pthread_mutex_lock(&q->lock);
+                       ast_mutex_lock(&q->lock);
                        if( strcmp( q->name, queuename) == 0 )
                        {
                                // found queue, try to enable interface
@@ -1050,7 +1050,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
                                                "Already there\n", interface, queuename);
                        }
 
-                       ast_pthread_mutex_unlock(&q->lock);
+                       ast_mutex_unlock(&q->lock);
                        q = q->next;
                }
        }
@@ -1171,7 +1171,7 @@ static void reload_queues(void)
                ast_log(LOG_NOTICE, "No call queueing config file, so no call queues\n");
                return;
        }
-       ast_pthread_mutex_lock(&qlock);
+       ast_mutex_lock(&qlock);
        /* Mark all queues as dead for the moment */
        q = queues;
        while(q) {
@@ -1195,7 +1195,7 @@ static void reload_queues(void)
                                if (q) {
                                        /* Initialize it */
                                        memset(q, 0, sizeof(struct ast_call_queue));
-                                       ast_pthread_mutex_init(&q->lock);
+                                       ast_mutex_init(&q->lock);
                                        strncpy(q->name, cat, sizeof(q->name));
                                        new = 1;
                                } else new = 0;
@@ -1203,7 +1203,7 @@ static void reload_queues(void)
                                        new = 0;
                        if (q) {
                                if (!new) 
-                                       ast_pthread_mutex_lock(&q->lock);
+                                       ast_mutex_lock(&q->lock);
                                /* Re-initialize the queue */
                                q->dead = 0;
                                q->retry = 0;
@@ -1274,7 +1274,7 @@ static void reload_queues(void)
                                if (q->maxlen < 0)
                                        q->maxlen = 0;
                                if (!new) 
-                                       ast_pthread_mutex_unlock(&q->lock);
+                                       ast_mutex_unlock(&q->lock);
                                if (new) {
                                        q->next = queues;
                                        queues = q;
@@ -1301,7 +1301,7 @@ static void reload_queues(void)
                        ql = q;
                q = qn;
        }
-       ast_pthread_mutex_unlock(&qlock);
+       ast_mutex_unlock(&qlock);
 }
 
 static int queues_show(int fd, int argc, char **argv)
@@ -1323,7 +1323,7 @@ static int queues_show(int fd, int argc, char **argv)
                return RESULT_SUCCESS;
        }
        while(q) {
-               ast_pthread_mutex_lock(&q->lock);
+               ast_mutex_lock(&q->lock);
                if (q->maxlen)
                        snprintf(max, sizeof(max), "%d", q->maxlen);
                else
@@ -1354,7 +1354,7 @@ static int queues_show(int fd, int argc, char **argv)
                } else
                        ast_cli(fd, "   No Callers\n");
                ast_cli(fd, "\n");
-               ast_pthread_mutex_unlock(&q->lock);
+               ast_mutex_unlock(&q->lock);
                q = q->next;
        }
        return RESULT_SUCCESS;
@@ -1379,7 +1379,7 @@ static int manager_queues_status( struct mansession *s, struct message *m )
        time(&now);
        q = queues;
        while(q) {
-               ast_pthread_mutex_lock(&q->lock);
+               ast_mutex_lock(&q->lock);
                ast_cli(s->fd, "Event: QueueParams\r\n"
                                        "Queue: %s\r\n"
                                        "Max: %d\r\n"
@@ -1401,7 +1401,7 @@ static int manager_queues_status( struct mansession *s, struct message *m )
                                "Wait: %ld\r\n"
                                "\r\n", 
                                        q->name, pos++, qe->chan->name, (qe->chan->callerid ? qe->chan->callerid : ""), now - qe->start);
-               ast_pthread_mutex_unlock(&q->lock);
+               ast_mutex_unlock(&q->lock);
                q = q->next;
        }
        return RESULT_SUCCESS;
index a955fe3..2dd8d07 100755 (executable)
@@ -133,7 +133,7 @@ static char *app = "VoiceMail2";
 /* Check mail, control, etc */
 static char *app2 = "VoiceMailMain2";
 
-static pthread_mutex_t vmlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t vmlock = AST_MUTEX_INITIALIZER;
 struct ast_vm_user *users;
 struct ast_vm_user *usersl;
 struct vm_zone *zones = NULL;
@@ -183,7 +183,7 @@ static void apply_options(struct ast_vm_user *vmu, char *options)
 
 #ifdef USEMYSQLVM
 MYSQL *dbhandler=NULL;
-pthread_mutex_t mysqllock;
+ast_mutex_t mysqllock;
 char dbuser[80];
 char dbpass[80];
 char dbname[80];
@@ -241,7 +241,7 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, cha
                } else {
                        sprintf(query, "SELECT password,fullname,email,pager,options FROM users WHERE mailbox='%s'", mailbox);
                }
-               pthread_mutex_lock(&mysqllock);
+               ast_mutex_lock(&mysqllock);
                mysql_query(dbhandler, query);
                if ((result=mysql_store_result(dbhandler))!=NULL) {
                        if ((rowval=mysql_fetch_row(result))!=NULL) {
@@ -264,16 +264,16 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, cha
                                        }
                                }
                                mysql_free_result(result);
-                               pthread_mutex_unlock(&mysqllock);
+                               ast_mutex_unlock(&mysqllock);
                                return(retval);
                        } else {
                                mysql_free_result(result);
-                               pthread_mutex_unlock(&mysqllock);
+                               ast_mutex_unlock(&mysqllock);
                                free(retval);
                                return(NULL);
                        }
                }
-               pthread_mutex_unlock(&mysqllock);
+               ast_mutex_unlock(&mysqllock);
                free(retval);
        }
        return(NULL);
@@ -288,10 +288,10 @@ static void vm_change_password(struct ast_vm_user *vmu, char *password)
        } else {
                sprintf(query, "UPDATE users SET password='%s' WHERE mailbox='%s' AND password='%s'", password, vmu->mailbox, vmu->password);
        }
-       pthread_mutex_lock(&mysqllock);
+       ast_mutex_lock(&mysqllock);
        mysql_query(dbhandler, query);
        strcpy(vmu->password, password);
-       pthread_mutex_unlock(&mysqllock);
+       ast_mutex_unlock(&mysqllock);
 }
 
 static void reset_user_pw(char *context, char *mailbox, char *password)
@@ -303,9 +303,9 @@ static void reset_user_pw(char *context, char *mailbox, char *password)
        } else {
                sprintf(query, "UPDATE users SET password='%s' WHERE mailbox='%s'", password, mailbox);
        }
-       pthread_mutex_lock(&mysqllock);
+       ast_mutex_lock(&mysqllock);
        mysql_query(dbhandler, query);
-       pthread_mutex_unlock(&mysqllock);
+       ast_mutex_unlock(&mysqllock);
 }
 #else
 
@@ -313,7 +313,7 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, cha
 {
        /* This function could be made to generate one from a database, too */
        struct ast_vm_user *vmu=NULL, *cur;
-       ast_pthread_mutex_lock(&vmlock);
+       ast_mutex_lock(&vmlock);
        cur = users;
        while(cur) {
                if ((!context || !strcasecmp(context, cur->context)) &&
@@ -336,7 +336,7 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, cha
                        vmu->next = NULL;
                }
        }
-       ast_pthread_mutex_unlock(&vmlock);
+       ast_mutex_unlock(&vmlock);
        return vmu;
 }
 
@@ -345,7 +345,7 @@ static int reset_user_pw(char *context, char *mailbox, char *newpass)
        /* This function could be made to generate one from a database, too */
        struct ast_vm_user *cur;
        int res = -1;
-       ast_pthread_mutex_lock(&vmlock);
+       ast_mutex_lock(&vmlock);
        cur = users;
        while(cur) {
                if ((!context || !strcasecmp(context, cur->context)) &&
@@ -357,7 +357,7 @@ static int reset_user_pw(char *context, char *mailbox, char *newpass)
                strncpy(cur->password, newpass, sizeof(cur->password) - 1);
                res = 0;
        }
-       ast_pthread_mutex_unlock(&vmlock);
+       ast_mutex_unlock(&vmlock);
        return res;
 }
 
@@ -2876,7 +2876,7 @@ static int load_config(void)
        int x;
 
        cfg = ast_load(VOICEMAIL_CONFIG);
-       ast_pthread_mutex_lock(&vmlock);
+       ast_mutex_lock(&vmlock);
        cur = users;
        while(cur) {
                l = cur;
@@ -3054,10 +3054,10 @@ static int load_config(void)
                        }
                }
                ast_destroy(cfg);
-               ast_pthread_mutex_unlock(&vmlock);
+               ast_mutex_unlock(&vmlock);
                return 0;
        } else {
-               ast_pthread_mutex_unlock(&vmlock);
+               ast_mutex_unlock(&vmlock);
                ast_log(LOG_WARNING, "Error reading voicemail config\n");
                return -1;
        }
index ccc3845..8813c07 100755 (executable)
@@ -75,7 +75,7 @@ static struct ast_atexit {
        void (*func)(void);
        struct ast_atexit *next;
 } *atexits = NULL;
-static pthread_mutex_t atexitslock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t atexitslock = AST_MUTEX_INITIALIZER;
 
 time_t ast_startuptime;
 time_t ast_lastreloadtime;
@@ -111,7 +111,7 @@ int ast_register_atexit(void (*func)(void))
        struct ast_atexit *ae;
        ast_unregister_atexit(func);
        ae = malloc(sizeof(struct ast_atexit));
-       ast_pthread_mutex_lock(&atexitslock);
+       ast_mutex_lock(&atexitslock);
        if (ae) {
                memset(ae, 0, sizeof(struct ast_atexit));
                ae->next = atexits;
@@ -119,14 +119,14 @@ int ast_register_atexit(void (*func)(void))
                atexits = ae;
                res = 0;
        }
-       ast_pthread_mutex_unlock(&atexitslock);
+       ast_mutex_unlock(&atexitslock);
        return res;
 }
 
 void ast_unregister_atexit(void (*func)(void))
 {
        struct ast_atexit *ae, *prev = NULL;
-       ast_pthread_mutex_lock(&atexitslock);
+       ast_mutex_lock(&atexitslock);
        ae = atexits;
        while(ae) {
                if (ae->func == func) {
@@ -139,7 +139,7 @@ void ast_unregister_atexit(void (*func)(void))
                prev = ae;
                ae = ae->next;
        }
-       ast_pthread_mutex_unlock(&atexitslock);
+       ast_mutex_unlock(&atexitslock);
 }
 
 static int fdprint(int fd, const char *s)
@@ -402,14 +402,14 @@ static int shuttingdown = 0;
 static void ast_run_atexits(void)
 {
        struct ast_atexit *ae;
-       ast_pthread_mutex_lock(&atexitslock);
+       ast_mutex_lock(&atexitslock);
        ae = atexits;
        while(ae) {
                if (ae->func) 
                        ae->func();
                ae = ae->next;
        }
-       ast_pthread_mutex_unlock(&atexitslock);
+       ast_mutex_unlock(&atexitslock);
 }
 
 static void quit_handler(int num, int nice, int safeshutdown, int restart)
diff --git a/astmm.c b/astmm.c
index 94e4555..ebc6fc1 100755 (executable)
--- a/astmm.c
+++ b/astmm.c
@@ -55,7 +55,7 @@ static struct ast_region {
 #define HASH(a) \
        (((unsigned long)(a)) % SOME_PRIME)
        
-static pthread_mutex_t reglock = PTHREAD_MUTEX_INITIALIZER;
+static ast_mutex_t reglock = PTHREAD_MUTEX_INITIALIZER;
 
 static inline void *__ast_alloc_region(size_t size, int which, const char *file, int lineno, const char *func)
 {
@@ -63,7 +63,7 @@ static inline void *__ast_alloc_region(size_t size, int which, const char *file,
        void *ptr=NULL;
        int hash;
        reg = malloc(size + sizeof(struct ast_region));
-       pthread_mutex_lock(&reglock);
+       ast_mutex_lock(&reglock);
        if (reg) {
                strncpy(reg->file, file, sizeof(reg->file) - 1);
                reg->file[sizeof(reg->file) - 1] = '\0';
@@ -77,7 +77,7 @@ static inline void *__ast_alloc_region(size_t size, int which, const char *file,
                reg->next = regions[hash];
                regions[hash] = reg;
        }
-       pthread_mutex_unlock(&reglock);
+       ast_mutex_unlock(&reglock);
        if (!reg) {
                fprintf(stderr, "Out of memory :(\n");
                if (mmlog) {
@@ -94,7 +94,7 @@ static inline size_t __ast_sizeof_region(void *ptr)
        struct ast_region *reg;
        size_t len = 0;
        
-       pthread_mutex_lock(&reglock);
+       ast_mutex_lock(&reglock);
        reg = regions[hash];
        while(reg) {
                if (reg->data == ptr) {
@@ -103,7 +103,7 @@ static inline size_t __ast_sizeof_region(void *ptr)
                }
                reg = reg->next;
        }
-       pthread_mutex_unlock(&reglock);
+       ast_mutex_unlock(&reglock);
        return len;
 }
 
@@ -111,7 +111,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha
 {
        int hash = HASH(ptr);
        struct ast_region *reg, *prev = NULL;
-       pthread_mutex_lock(&reglock);
+       ast_mutex_lock(&reglock);
        reg = regions[hash];
        while(reg) {
                if (reg->data == ptr) {
@@ -125,7 +125,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha
                prev = reg;
                reg = reg->next;
        }
-       pthread_mutex_unlock(&reglock);
+       ast_mutex_unlock(&reglock);
        if (reg) {
                free(reg);
        } else {
@@ -226,7 +226,7 @@ static int handle_show_memory(int fd, int argc, char *argv[])
                fn = argv[3];
 
        /* try to lock applications list ... */
-       pthread_mutex_lock(&reglock);
+       ast_mutex_lock(&reglock);
 
        for (x=0;x<SOME_PRIME;x++) {
                reg = regions[x];
@@ -240,7 +240,7 @@ static int handle_show_memory(int fd, int argc, char *argv[])
                }
        }
        ast_cli(fd, "%d bytes allocated %d units total\n", len, count);
-       pthread_mutex_unlock(&reglock);
+       ast_mutex_unlock(&reglock);
        return RESULT_SUCCESS;
 }
 
@@ -264,7 +264,7 @@ static int handle_show_memory_summary(int fd, int argc, char *argv[])
                fn = argv[3];
 
        /* try to lock applications list ... */
-       pthread_mutex_lock(&reglock);
+       ast_mutex_lock(&reglock);
 
        for (x=0;x<SOME_PRIME;x++) {
                reg = regions[x];
@@ -289,7 +289,7 @@ static int handle_show_memory_summary(int fd, int argc, char *argv[])
                        reg = reg->next;
                }
        }
-       pthread_mutex_unlock(&reglock);
+       ast_mutex_unlock(&reglock);
        
        /* Dump the whole list */
        while(list) {
index 5f15c24..fc81c48 100755 (executable)
@@ -36,7 +36,7 @@
 
 #define MAX_AUTOMONS 256
 
-static pthread_mutex_t autolock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t autolock = AST_MUTEX_INITIALIZER;
 
 struct asent {
        struct ast_channel *chan;
@@ -56,7 +56,7 @@ static void *autoservice_run(void *ign)
        struct ast_frame *f;
        for(;;) {
                x = 0;
-               ast_pthread_mutex_lock(&autolock);
+               ast_mutex_lock(&autolock);
                as = aslist;
                while(as) {
                        if (!as->chan->_softhangup) {
@@ -67,7 +67,7 @@ static void *autoservice_run(void *ign)
                        }
                        as = as->next;
                }
-               ast_pthread_mutex_unlock(&autolock);
+               ast_mutex_unlock(&autolock);
 
 /*             if (!aslist)
                        break; */
@@ -89,7 +89,7 @@ int ast_autoservice_start(struct ast_channel *chan)
        int res = -1;
        struct asent *as;
        int needstart;
-       ast_pthread_mutex_lock(&autolock);
+       ast_mutex_lock(&autolock);
        needstart = (asthread == -1) ? 1 : 0 /* aslist ? 0 : 1 */;
        as = aslist;
        while(as) {
@@ -116,7 +116,7 @@ int ast_autoservice_start(struct ast_channel *chan)
                        }
                }
        }
-       ast_pthread_mutex_unlock(&autolock);
+       ast_mutex_unlock(&autolock);
        return res;
 }
 
@@ -124,7 +124,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
 {
        int res = -1;
        struct asent *as, *prev;
-       ast_pthread_mutex_lock(&autolock);
+       ast_mutex_lock(&autolock);
        as = aslist;
        prev = NULL;
        while(as) {
@@ -144,7 +144,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
        }
        if (asthread != -1) 
                pthread_kill(asthread, SIGURG);
-       ast_pthread_mutex_unlock(&autolock);
+       ast_mutex_unlock(&autolock);
        /* Wait for it to un-block */
        while(chan->blocking)
                usleep(1000);
diff --git a/cdr.c b/cdr.c
index 6be19f2..20b3e2c 100755 (executable)
--- a/cdr.c
+++ b/cdr.c
@@ -27,7 +27,7 @@
 int ast_default_amaflags = AST_CDR_DOCUMENTATION;
 char ast_default_accountcode[20] = "";
 
-static pthread_mutex_t cdrlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t cdrlock = AST_MUTEX_INITIALIZER;
 
 static struct ast_cdr_beitem {
        char name[20];
@@ -52,14 +52,14 @@ int ast_cdr_register(char *name, char *desc, ast_cdrbe be)
                ast_log(LOG_WARNING, "CDR engine '%s' lacks backend\n", name);
                return -1;
        }
-       ast_pthread_mutex_lock(&cdrlock);
+       ast_mutex_lock(&cdrlock);
        i = bes;
        while(i) {
                if (!strcasecmp(name, i->name))
                        break;
                i = i->next;
        }
-       ast_pthread_mutex_unlock(&cdrlock);
+       ast_mutex_unlock(&cdrlock);
        if (i) {
                ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);
                return -1;
@@ -71,17 +71,17 @@ int ast_cdr_register(char *name, char *desc, ast_cdrbe be)
        strncpy(i->name, name, sizeof(i->name) - 1);
        strncpy(i->desc, desc, sizeof(i->desc) - 1);
        i->be = be;
-       ast_pthread_mutex_lock(&cdrlock);
+       ast_mutex_lock(&cdrlock);
        i->next = bes;
        bes = i;
-       ast_pthread_mutex_unlock(&cdrlock);
+       ast_mutex_unlock(&cdrlock);
        return 0;
 }
 
 void ast_cdr_unregister(char *name)
 {
        struct ast_cdr_beitem *i, *prev = NULL;
-       ast_pthread_mutex_lock(&cdrlock);
+       ast_mutex_lock(&cdrlock);
        i = bes;
        while(i) {
                if (!strcasecmp(name, i->name)) {
@@ -93,7 +93,7 @@ void ast_cdr_unregister(char *name)
                }
                i = i->next;
        }
-       ast_pthread_mutex_unlock(&cdrlock);
+       ast_mutex_unlock(&cdrlock);
        if (i) 
                free(i);
 }
@@ -367,13 +367,13 @@ void ast_cdr_post(struct ast_cdr *cdr)
                } else
                        cdr->billsec = 0;
                cdr->posted = 1;
-               ast_pthread_mutex_lock(&cdrlock);
+               ast_mutex_lock(&cdrlock);
                i = bes;
                while(i) {
                        i->be(cdr);
                        i = i->next;
                }
-               ast_pthread_mutex_unlock(&cdrlock);
+               ast_mutex_unlock(&cdrlock);
        }
 }
 
index b8127cf..a2632ea 100755 (executable)
@@ -37,7 +37,7 @@ static char *config = "cdr_mysql.conf";
 static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL;
 static int connected = 0;
 
-static pthread_mutex_t mysql_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t mysql_lock = AST_MUTEX_INITIALIZER;
 
 static MYSQL mysql;
 
@@ -48,7 +48,7 @@ static int mysql_log(struct ast_cdr *cdr)
        char sqlcmd[2048], timestr[128];
        time_t t;
 
-       ast_pthread_mutex_lock(&mysql_lock);
+       ast_mutex_lock(&mysql_lock);
 
        memset(sqlcmd,0,2048);
 
@@ -91,11 +91,11 @@ static int mysql_log(struct ast_cdr *cdr)
        
                if (mysql_real_query(&mysql,sqlcmd,strlen(sqlcmd))) {
                        ast_log(LOG_ERROR,"Failed to insert into database.");
-                       ast_pthread_mutex_unlock(&mysql_lock);
+                       ast_mutex_unlock(&mysql_lock);
                        return -1;
                }
        }
-       ast_pthread_mutex_unlock(&mysql_lock);
+       ast_mutex_unlock(&mysql_lock);
        return 0;
 }
 
index 89a6db7..c393631 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -45,25 +45,6 @@ static int uniqueint = 0;
 
 /* XXX Lock appropriately in more functions XXX */
 
-#ifdef DEBUG_MUTEX
-/* Convenient mutex debugging functions */
-#define PTHREAD_MUTEX_LOCK(a) __PTHREAD_MUTEX_LOCK(__FUNCTION__, a)
-#define PTHREAD_MUTEX_UNLOCK(a) __PTHREAD_MUTEX_UNLOCK(__FUNCTION__, a)
-
-static int __PTHREAD_MUTEX_LOCK(char *f, pthread_mutex_t *a) {
-       ast_log(LOG_DEBUG, "Locking %p (%s)\n", a, f); 
-       return ast_pthread_mutex_lock(a);
-}
-
-static int __PTHREAD_MUTEX_UNLOCK(char *f, pthread_mutex_t *a) {
-       ast_log(LOG_DEBUG, "Unlocking %p (%s)\n", a, f); 
-       return ast_pthread_mutex_unlock(a);
-}
-#else
-#define PTHREAD_MUTEX_LOCK(a) ast_pthread_mutex_lock(a)
-#define PTHREAD_MUTEX_UNLOCK(a) ast_pthread_mutex_unlock(a)
-#endif
-
 struct chanlist {
        char type[80];
        char description[80];
@@ -77,7 +58,7 @@ struct ast_channel *channels = NULL;
 /* Protect the channel list (highly unlikely that two things would change
    it at the same time, but still! */
    
-static pthread_mutex_t chlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t chlock = AST_MUTEX_INITIALIZER;
 
 int ast_check_hangup(struct ast_channel *chan)
 {
@@ -99,9 +80,9 @@ time_t        myt;
 static int ast_check_hangup_locked(struct ast_channel *chan)
 {
        int res;
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        res = ast_check_hangup(chan);
-       ast_pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
        return res;
 }
 
@@ -110,13 +91,13 @@ void ast_begin_shutdown(int hangup)
        struct ast_channel *c;
        shutting_down = 1;
        if (hangup) {
-               PTHREAD_MUTEX_LOCK(&chlock);
+               ast_mutex_lock(&chlock);
                c = channels;
                while(c) {
                        ast_softhangup(c, AST_SOFTHANGUP_SHUTDOWN);
                        c = c->next;
                }
-               PTHREAD_MUTEX_UNLOCK(&chlock);
+               ast_mutex_unlock(&chlock);
        }
 }
 
@@ -124,13 +105,13 @@ int ast_active_channels(void)
 {
        struct ast_channel *c;
        int cnt = 0;
-       PTHREAD_MUTEX_LOCK(&chlock);
+       ast_mutex_lock(&chlock);
        c = channels;
        while(c) {
                cnt++;
                c = c->next;
        }
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
        return cnt;
 }
 
@@ -167,7 +148,7 @@ int ast_channel_register_ex(char *type, char *description, int capabilities,
                int (*devicestate)(void *data))
 {
        struct chanlist *chan, *last=NULL;
-       if (PTHREAD_MUTEX_LOCK(&chlock)) {
+       if (ast_mutex_lock(&chlock)) {
                ast_log(LOG_WARNING, "Unable to lock channel list\n");
                return -1;
        }
@@ -175,7 +156,7 @@ int ast_channel_register_ex(char *type, char *description, int capabilities,
        while(chan) {
                if (!strcasecmp(type, chan->type)) {
                        ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", type);
-                       PTHREAD_MUTEX_UNLOCK(&chlock);
+                       ast_mutex_unlock(&chlock);
                        return -1;
                }
                last = chan;
@@ -184,7 +165,7 @@ int ast_channel_register_ex(char *type, char *description, int capabilities,
        chan = malloc(sizeof(struct chanlist));
        if (!chan) {
                ast_log(LOG_WARNING, "Out of memory\n");
-               PTHREAD_MUTEX_UNLOCK(&chlock);
+               ast_mutex_unlock(&chlock);
                return -1;
        }
        strncpy(chan->type, type, sizeof(chan->type)-1);
@@ -201,7 +182,7 @@ int ast_channel_register_ex(char *type, char *description, int capabilities,
                ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->type, chan->description);
        else if (option_verbose > 1)
                ast_verbose( VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->type, chan->description);
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
        return 0;
 }
 
@@ -286,7 +267,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
        /* If shutting down, don't allocate any new channels */
        if (shutting_down)
                return NULL;
-       PTHREAD_MUTEX_LOCK(&chlock);
+       ast_mutex_lock(&chlock);
        tmp = malloc(sizeof(struct ast_channel));
        if (tmp) {
                memset(tmp, 0, sizeof(struct ast_channel));
@@ -334,7 +315,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
                                        tmp->fout = 0;
                                        snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", time(NULL), uniqueint++);
                                        headp=&tmp->varshead;
-                                       ast_pthread_mutex_init(&tmp->lock);
+                                       ast_mutex_init(&tmp->lock);
                                        AST_LIST_HEAD_INIT(headp);
                                        tmp->vars=ast_var_assign("tempvar","tempval");
                                        AST_LIST_INSERT_HEAD(headp,tmp->vars,entries);
@@ -359,7 +340,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
                }
        } else 
                ast_log(LOG_WARNING, "Out of memory\n");
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
        return tmp;
 }
 
@@ -376,7 +357,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int lock)
                return -1;
        }
        if (lock)
-               ast_pthread_mutex_lock(&chan->lock);
+               ast_mutex_lock(&chan->lock);
        prev = NULL;
        cur = chan->pvt->readq;
        while(cur) {
@@ -393,7 +374,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int lock)
                        ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
                        ast_frfree(f);
                        if (lock)
-                               ast_pthread_mutex_unlock(&chan->lock);
+                               ast_mutex_unlock(&chan->lock);
                        return 0;
                }
        }
@@ -409,7 +390,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int lock)
                pthread_kill(chan->blocker, SIGURG);
        }
        if (lock)
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
        return 0;
 }
 
@@ -446,10 +427,10 @@ void ast_channel_undefer_dtmf(struct ast_channel *chan)
 struct ast_channel *ast_channel_walk(struct ast_channel *prev)
 {
        struct ast_channel *l, *ret=NULL;
-       PTHREAD_MUTEX_LOCK(&chlock);
+       ast_mutex_lock(&chlock);
        l = channels;
        if (!prev) {
-               PTHREAD_MUTEX_UNLOCK(&chlock);
+               ast_mutex_unlock(&chlock);
                return l;
        }
        while(l) {
@@ -457,7 +438,7 @@ struct ast_channel *ast_channel_walk(struct ast_channel *prev)
                        ret = l->next;
                l = l->next;
        }
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
        return ret;
        
 }
@@ -511,7 +492,7 @@ void ast_channel_free(struct ast_channel *chan)
        
        headp=&chan->varshead;
        
-       PTHREAD_MUTEX_LOCK(&chlock);
+       ast_mutex_lock(&chlock);
        cur = channels;
        while(cur) {
                if (cur == chan) {
@@ -551,7 +532,7 @@ void ast_channel_free(struct ast_channel *chan)
                free(chan->ani);
        if (chan->rdnis)
                free(chan->rdnis);
-       pthread_mutex_destroy(&chan->lock);
+       ast_mutex_destroy(&chan->lock);
        /* Close pipes if appropriate */
        if ((fd = chan->pvt->alertpipe[0]) > -1)
                close(fd);
@@ -581,7 +562,7 @@ void ast_channel_free(struct ast_channel *chan)
        free(chan->pvt);
        chan->pvt = NULL;
        free(chan);
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
 
        ast_device_state_changed(name);
 }
@@ -604,9 +585,9 @@ int ast_softhangup_nolock(struct ast_channel *chan, int cause)
 int ast_softhangup(struct ast_channel *chan, int cause)
 {
        int res;
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        res = ast_softhangup_nolock(chan, cause);
-       ast_pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
        return res;
 }
 
@@ -629,7 +610,7 @@ int ast_hangup(struct ast_channel *chan)
        int res = 0;
        /* Don't actually hang up a channel that will masquerade as someone else, or
           if someone is going to masquerade as us */
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        if (chan->masq) {
                if (ast_do_masquerade(chan)) 
                        ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -637,13 +618,13 @@ int ast_hangup(struct ast_channel *chan)
 
        if (chan->masq) {
                ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name);
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                return 0;
        }
        /* If this channel is one which will be masqueraded into something, 
           mark it as a zombie already, so we know to free it later */
        if (chan->masqr) {
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                chan->zombie=1;
                return 0;
        }
@@ -679,7 +660,7 @@ int ast_hangup(struct ast_channel *chan)
                if (option_debug)
                        ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name);
                        
-       ast_pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
        manager_event(EVENT_FLAG_CALL, "Hangup", 
                        "Channel: %s\r\n"
                        "Uniqueid: %s\r\n",
@@ -693,7 +674,7 @@ void ast_channel_unregister(char *type)
        struct chanlist *chan, *last=NULL;
        if (option_debug)
                ast_log(LOG_DEBUG, "Unregistering channel type '%s'\n", type);
-       if (PTHREAD_MUTEX_LOCK(&chlock)) {
+       if (ast_mutex_lock(&chlock)) {
                ast_log(LOG_WARNING, "Unable to lock channel list\n");
                return;
        }
@@ -705,13 +686,13 @@ void ast_channel_unregister(char *type)
                        else
                                backends = backends->next;
                        free(chan);
-                       PTHREAD_MUTEX_UNLOCK(&chlock);
+                       ast_mutex_unlock(&chlock);
                        return;
                }
                last = chan;
                chan = chan->next;
        }
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
 }
 
 int ast_answer(struct ast_channel *chan)
@@ -825,16 +806,16 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
        
        /* Perform any pending masquerades */
        for (x=0;x<n;x++) {
-               ast_pthread_mutex_lock(&c[x]->lock);
+               ast_mutex_lock(&c[x]->lock);
                if (c[x]->masq) {
                        if (ast_do_masquerade(c[x])) {
                                ast_log(LOG_WARNING, "Masquerade failed\n");
                                *ms = -1;
-                               ast_pthread_mutex_unlock(&c[x]->lock);
+                               ast_mutex_unlock(&c[x]->lock);
                                return NULL;
                        }
                }
-               ast_pthread_mutex_unlock(&c[x]->lock);
+               ast_mutex_unlock(&c[x]->lock);
        }
        
        tv.tv_sec = *ms / 1000;
@@ -1012,14 +993,14 @@ struct ast_frame *ast_read(struct ast_channel *chan)
                AST_FRAME_NULL,
        };
        
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        if (chan->masq) {
                if (ast_do_masquerade(chan)) {
                        ast_log(LOG_WARNING, "Failed to perform masquerade\n");
                        f = NULL;
                } else
                        f =  &null_frame;
-               pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                return f;
        }
 
@@ -1027,7 +1008,7 @@ struct ast_frame *ast_read(struct ast_channel *chan)
        if (chan->zombie || ast_check_hangup(chan)) {
                if (chan->generator)
                        ast_deactivate_generator(chan);
-               pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                return NULL;
        }
 
@@ -1037,7 +1018,7 @@ struct ast_frame *ast_read(struct ast_channel *chan)
                chan->dtmff.subclass = chan->dtmfq[0];
                /* Drop first digit */
                memmove(chan->dtmfq, chan->dtmfq + 1, sizeof(chan->dtmfq) - 1);
-               pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                return &chan->dtmff;
        }
        
@@ -1053,7 +1034,7 @@ struct ast_frame *ast_read(struct ast_channel *chan)
                ioctl(chan->timingfd, ZT_TIMERACK, &blah);
                func = chan->timingfunc;
                data = chan->timingdata;
-               pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                if (func) {
 #if 0
                        ast_log(LOG_DEBUG, "Calling private function\n");
@@ -1061,10 +1042,10 @@ struct ast_frame *ast_read(struct ast_channel *chan)
                        func(data);
                } else {
                        blah = 0;
-                       pthread_mutex_lock(&chan->lock);
+                       ast_mutex_lock(&chan->lock);
                        ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah);
                        chan->timingdata = NULL;
-                       pthread_mutex_unlock(&chan->lock);
+                       ast_mutex_unlock(&chan->lock);
                }
                f =  &null_frame;
                return f;
@@ -1136,7 +1117,7 @@ struct ast_frame *ast_read(struct ast_channel *chan)
                ast_setstate(chan, AST_STATE_UP);
                ast_cdr_answer(chan->cdr);
        } 
-       pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
 
        /* Run any generator sitting on the line */
        if (f && (f->frametype == AST_FRAME_VOICE) && chan->generatordata) {
@@ -1321,28 +1302,28 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
        int res = -1;
        struct ast_frame *f = NULL;
        /* Stop if we're a zombie or need a soft hangup */
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        if (chan->zombie || ast_check_hangup(chan))  {
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                return -1;
        }
        /* Handle any pending masquerades */
        if (chan->masq) {
                if (ast_do_masquerade(chan)) {
                        ast_log(LOG_WARNING, "Failed to perform masquerade\n");
-                       ast_pthread_mutex_unlock(&chan->lock);
+                       ast_mutex_unlock(&chan->lock);
                        return -1;
                }
        }
        if (chan->masqr) {
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
                return 0;
        }
        if (chan->generatordata) {
                if (chan->writeinterrupt)
                        ast_deactivate_generator(chan);
                else {
-                       ast_pthread_mutex_unlock(&chan->lock);
+                       ast_mutex_unlock(&chan->lock);
                        return 0;
                }
        }
@@ -1402,7 +1383,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                        chan->fout++;
                chan->fout++;
        }
-       ast_pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
        return res;
 }
 
@@ -1534,7 +1515,7 @@ struct ast_channel *ast_request(char *type, int format, void *data)
        int capabilities;
        int fmt;
        int res;
-       if (PTHREAD_MUTEX_LOCK(&chlock)) {
+       if (ast_mutex_lock(&chlock)) {
                ast_log(LOG_WARNING, "Unable to lock channel list\n");
                return NULL;
        }
@@ -1546,10 +1527,10 @@ struct ast_channel *ast_request(char *type, int format, void *data)
                        res = ast_translator_best_choice(&fmt, &capabilities);
                        if (res < 0) {
                                ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->capabilities, format);
-                               PTHREAD_MUTEX_UNLOCK(&chlock);
+                               ast_mutex_unlock(&chlock);
                                return NULL;
                        }
-                       PTHREAD_MUTEX_UNLOCK(&chlock);
+                       ast_mutex_unlock(&chlock);
                        if (chan->requester)
                                c = chan->requester(type, capabilities, data);
                        if (c) {
@@ -1567,7 +1548,7 @@ struct ast_channel *ast_request(char *type, int format, void *data)
        }
        if (!chan)
                ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
        return c;
 }
 
@@ -1605,14 +1586,14 @@ int ast_device_state(char *device)
        *number = 0;
        number++;
                
-       if (PTHREAD_MUTEX_LOCK(&chlock)) {
+       if (ast_mutex_lock(&chlock)) {
                ast_log(LOG_WARNING, "Unable to lock channel list\n");
                return -1;
        }
        chanls = backends;
        while(chanls) {
                if (!strcasecmp(tech, chanls->type)) {
-                       PTHREAD_MUTEX_UNLOCK(&chlock);
+                       ast_mutex_unlock(&chlock);
                        if (!chanls->devicestate) 
                                return ast_parse_device_state(device);
                        else {
@@ -1625,7 +1606,7 @@ int ast_device_state(char *device)
                }
                chanls = chanls->next;
        }
-       PTHREAD_MUTEX_UNLOCK(&chlock);
+       ast_mutex_unlock(&chlock);
        return AST_DEVICE_INVALID;
 }
 
@@ -1636,11 +1617,11 @@ int ast_call(struct ast_channel *chan, char *addr, int timeout)
           return anyway.  */
        int res = -1;
        /* Stop if we're a zombie or need a soft hangup */
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        if (!chan->zombie && !ast_check_hangup(chan)) 
                if (chan->pvt->call)
                        res = chan->pvt->call(chan, addr, timeout);
-       pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
        return res;
 }
 
@@ -1651,7 +1632,7 @@ int ast_transfer(struct ast_channel *chan, char *dest)
           return anyway.  */
        int res = -1;
        /* Stop if we're a zombie or need a soft hangup */
-       ast_pthread_mutex_lock(&chan->lock);
+       ast_mutex_lock(&chan->lock);
        if (!chan->zombie && !ast_check_hangup(chan)) {
                if (chan->pvt->transfer) {
                        res = chan->pvt->transfer(chan, dest);
@@ -1660,7 +1641,7 @@ int ast_transfer(struct ast_channel *chan, char *dest)
                } else
                        res = 0;
        }
-       pthread_mutex_unlock(&chan->lock);
+       ast_mutex_unlock(&chan->lock);
        return res;
 }
 
@@ -1871,7 +1852,7 @@ static int ast_do_masquerade(struct ast_channel *original)
           while the features are nice, the cost is very high in terms of pure nastiness. XXX */
 
        /* We need the clone's lock, too */
-       ast_pthread_mutex_lock(&clone->lock);
+       ast_mutex_lock(&clone->lock);
 
        ast_log(LOG_DEBUG, "Got clone lock on '%s' at %p\n", clone->name, &clone->lock);
 
@@ -1921,7 +1902,7 @@ static int ast_do_masquerade(struct ast_channel *original)
                res = clone->pvt->hangup(clone);
        if (res) {
                ast_log(LOG_WARNING, "Hangup failed!  Strange things may happen!\n");
-               pthread_mutex_unlock(&clone->lock);
+               ast_mutex_unlock(&clone->lock);
                return -1;
        }
        
@@ -1984,13 +1965,13 @@ static int ast_do_masquerade(struct ast_channel *original)
           zombie, then free it now (since it already is considered invalid). */
        if (clone->zombie) {
                ast_log(LOG_DEBUG, "Destroying clone '%s'\n", clone->name);
-               pthread_mutex_unlock(&clone->lock);
+               ast_mutex_unlock(&clone->lock);
                ast_channel_free(clone);
                manager_event(EVENT_FLAG_CALL, "Hangup", "Channel: %s\r\n", zombn);
        } else {
                ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
                clone->zombie=1;
-               pthread_mutex_unlock(&clone->lock);
+               ast_mutex_unlock(&clone->lock);
        }
        /* Set the write format */
        ast_set_write_format(original, wformat);
index 53dd4e7..74155d0 100755 (executable)
@@ -81,13 +81,13 @@ static int wrapuptime;
 static int ackcall;
 
 static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 /* Protect the interface list (of sip_pvt's) */
-static pthread_mutex_t agentlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t agentlock = AST_MUTEX_INITIALIZER;
 
 static struct agent_pvt {
-       pthread_mutex_t lock;                           /* Channel private lock */
+       ast_mutex_t lock;                               /* Channel private lock */
        int dead;                                                       /* Poised for destruction? */
        int pending;                                            /* Not a real agent -- just pending a match */
        int abouttograb;                                        /* About to grab */
@@ -102,7 +102,7 @@ static struct agent_pvt {
        char agent[AST_MAX_AGENT];                      /* Agent ID */
        char password[AST_MAX_AGENT];           /* Password for Agent login */
        char name[AST_MAX_AGENT];
-       pthread_mutex_t app_lock;                       /* Synchronization between owning applications */
+       ast_mutex_t app_lock;                   /* Synchronization between owning applications */
        volatile pthread_t owning_app;          /* Owning application thread id */
        volatile int app_sleep_cond;            /* Sleep condition for the login app */
        struct ast_channel *owner;                      /* Agent */
@@ -168,8 +168,8 @@ static struct agent_pvt *add_agent(char *agent, int pending)
                if (p) {
                        memset(p, 0, sizeof(struct agent_pvt));
                        strncpy(p->agent, tmp, sizeof(p->agent) -1);
-                       ast_pthread_mutex_init( &p->lock );
-                       ast_pthread_mutex_init( &p->app_lock );
+                       ast_mutex_init( &p->lock );
+                       ast_mutex_init( &p->app_lock );
                        p->owning_app = -1;
                        p->app_sleep_cond = 1;
                        p->group = group;
@@ -204,7 +204,7 @@ static int agent_cleanup(struct agent_pvt *p)
        chan->pvt->pvt = NULL;
        p->app_sleep_cond = 1;
        /* Release ownership of the agent to other threads (presumably running the login app). */
-       ast_pthread_mutex_unlock(&p->app_lock);
+       ast_mutex_unlock(&p->app_lock);
        if (chan)
                ast_channel_free(chan);
        if (p->dead)
@@ -226,7 +226,7 @@ static struct ast_frame  *agent_read(struct ast_channel *ast)
        struct ast_frame *f = NULL;
        static struct ast_frame null_frame = { AST_FRAME_NULL, };
        static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
-       ast_pthread_mutex_lock(&p->lock); 
+       ast_mutex_lock(&p->lock); 
        if (p->chan) {
                p->chan->pvt->rawreadformat = ast->pvt->rawreadformat;
                f = ast_read(p->chan);
@@ -270,7 +270,7 @@ static struct ast_frame  *agent_read(struct ast_channel *ast)
                f = NULL;
        }
        CLEANUP(ast,p);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return f;
 }
 
@@ -278,28 +278,28 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
 {
        struct agent_pvt *p = ast->pvt->pvt;
        int res = -1;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (p->chan) {
                p->chan->pvt->rawwriteformat = ast->pvt->rawwriteformat;
                res = ast_write(p->chan, f);
        } else
                res = 0;
        CLEANUP(ast, p);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
 static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
        struct agent_pvt *p = newchan->pvt->pvt;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (p->owner != oldchan) {
                ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return -1;
        }
        p->owner = newchan;
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return 0;
 }
 
@@ -307,12 +307,12 @@ static int agent_indicate(struct ast_channel *ast, int condition)
 {
        struct agent_pvt *p = ast->pvt->pvt;
        int res = -1;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (p->chan)
                res = ast_indicate(p->chan, condition);
        else
                res = 0;
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -320,12 +320,12 @@ static int agent_digit(struct ast_channel *ast, char digit)
 {
        struct agent_pvt *p = ast->pvt->pvt;
        int res = -1;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (p->chan)
                res = p->chan->pvt->send_digit(p->chan, digit);
        else
                res = 0;
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -333,7 +333,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
 {
        struct agent_pvt *p = ast->pvt->pvt;
        int res = -1;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (!p->chan) {
                if (p->pending) {
                        ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
@@ -343,7 +343,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
                        ast_log(LOG_NOTICE, "Whoa, they hung up between alloc and call...  what are the odds of that?\n");
                        res = -1;
                }
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return res;
        } else if (strlen(p->loginchan)) {
                time(&p->start);
@@ -352,7 +352,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
                        ast_verbose(VERBOSE_PREFIX_3 "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
                res = ast_call(p->chan, p->loginchan, 0);
                CLEANUP(ast,p);
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return res;
        }
        ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
@@ -385,7 +385,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
                ast_setstate(ast, AST_STATE_UP);
        }
        CLEANUP(ast,p);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -393,7 +393,7 @@ static int agent_hangup(struct ast_channel *ast)
 {
        struct agent_pvt *p = ast->pvt->pvt;
        int howlong = 0;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        p->owner = NULL;
        ast->pvt->pvt = NULL;
        p->app_sleep_cond = 1;
@@ -415,38 +415,38 @@ static int agent_hangup(struct ast_channel *ast)
                                strcpy(p->loginchan, "");
                        }
                } else if (p->dead) {
-                       ast_pthread_mutex_lock(&p->chan->lock);
+                       ast_mutex_lock(&p->chan->lock);
                        ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
-                       ast_pthread_mutex_unlock(&p->chan->lock);
+                       ast_mutex_unlock(&p->chan->lock);
                } else {
-                       ast_pthread_mutex_lock(&p->chan->lock);
+                       ast_mutex_lock(&p->chan->lock);
                        ast_moh_start(p->chan, p->moh);
-                       ast_pthread_mutex_unlock(&p->chan->lock);
+                       ast_mutex_unlock(&p->chan->lock);
                }
        }
 #if 0
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                /* Release ownership of the agent to other threads (presumably running the login app). */
-               ast_pthread_mutex_unlock(&p->app_lock);
+               ast_mutex_unlock(&p->app_lock);
        } else if (p->dead) {
                /* Go ahead and lose it */
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                /* Release ownership of the agent to other threads (presumably running the login app). */
-               ast_pthread_mutex_unlock(&p->app_lock);
+               ast_mutex_unlock(&p->app_lock);
        } else {
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                /* Release ownership of the agent to other threads (presumably running the login app). */
-               ast_pthread_mutex_unlock(&p->app_lock);
+               ast_mutex_unlock(&p->app_lock);
        }
 #endif 
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        /* Release ownership of the agent to other threads (presumably running the login app). */
-       ast_pthread_mutex_unlock(&p->app_lock);
+       ast_mutex_unlock(&p->app_lock);
 
        if (p->pending) {
-               ast_pthread_mutex_lock(&agentlock);
+               ast_mutex_lock(&agentlock);
                agent_unlink(p);
-               ast_pthread_mutex_unlock(&agentlock);
+               ast_mutex_unlock(&agentlock);
        }
        if (p->abouttograb) {
                /* Let the "about to grab" thread know this isn't valid anymore, and let it
@@ -456,11 +456,11 @@ static int agent_hangup(struct ast_channel *ast)
                free(p);
        } else if (p->chan) {
                /* Not dead -- check availability now */
-               ast_pthread_mutex_lock(&p->lock);
+               ast_mutex_lock(&p->lock);
                /* check_availability(p, 1); */
                /* Store last disconnect time */
                gettimeofday(&p->lastdisc, NULL);
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
        }
        return 0;
 }
@@ -473,7 +473,7 @@ static int agent_cont_sleep( void *data )
 
        p = (struct agent_pvt *)data;
 
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        res = p->app_sleep_cond;
        if (p->lastdisc.tv_sec) {
                gettimeofday(&tv, NULL);
@@ -481,7 +481,7 @@ static int agent_cont_sleep( void *data )
                        (tv.tv_usec - p->lastdisc.tv_usec) / 1000 > p->wrapuptime) 
                        res = 1;
        }
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
 #if 0
        if( !res )
                ast_log( LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
@@ -534,9 +534,9 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
                tmp->pvt->indicate = agent_indicate;
                tmp->pvt->fixup = agent_fixup;
                p->owner = tmp;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                tmp->priority = 1;
                /* Wake up and wait for other applications (by definition the login app)
@@ -547,13 +547,13 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
                 * implemented in the kernel for this.
                 */
                p->app_sleep_cond = 0;
-               if( pthread_mutex_trylock(&p->app_lock) )
+               if( ast_mutex_trylock(&p->app_lock) )
                {
                        if (p->chan) {
                                ast_queue_frame(p->chan, &null_frame, 1);
-                               ast_pthread_mutex_unlock(&p->lock);     /* For other thread to read the condition. */
-                               ast_pthread_mutex_lock(&p->app_lock);
-                               ast_pthread_mutex_lock(&p->lock);
+                               ast_mutex_unlock(&p->lock);     /* For other thread to read the condition. */
+                               ast_mutex_lock(&p->app_lock);
+                               ast_mutex_lock(&p->lock);
                        }
                        if( !p->chan )
                        {
@@ -562,8 +562,8 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
                                tmp->pvt->pvt = NULL;
                                p->app_sleep_cond = 1;
                                ast_channel_free( tmp );
-                               ast_pthread_mutex_unlock(&p->lock);     /* For other thread to read the condition. */
-                               ast_pthread_mutex_unlock(&p->app_lock);
+                               ast_mutex_unlock(&p->lock);     /* For other thread to read the condition. */
+                               ast_mutex_unlock(&p->app_lock);
                                return NULL;
                        }
                }
@@ -596,7 +596,7 @@ static int read_agent_config(void)
                ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n");
                return 0;
        }
-       ast_pthread_mutex_lock(&agentlock);
+       ast_mutex_lock(&agentlock);
        p = agents;
        while(p) {
                p->dead = 1;
@@ -648,7 +648,7 @@ static int read_agent_config(void)
                        pl = p;
                p = pn;
        }
-       ast_pthread_mutex_unlock(&agentlock);
+       ast_mutex_unlock(&agentlock);
        ast_destroy(cfg);
        return 0;
 }
@@ -660,28 +660,28 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
        int res;
        ast_log(LOG_DEBUG, "Checking availability of '%s'\n", newlyavailable->agent);
        if (needlock)
-               ast_pthread_mutex_lock(&agentlock);
+               ast_mutex_lock(&agentlock);
        p = agents;
        while(p) {
                if (p == newlyavailable) {
                        p = p->next;
                        continue;
                }
-               ast_pthread_mutex_lock(&p->lock);
+               ast_mutex_lock(&p->lock);
                if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
                        ast_log(LOG_DEBUG, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
                        /* We found a pending call, time to merge */
                        chan = agent_new(newlyavailable, AST_STATE_DOWN);
                        parent = p->owner;
                        p->abouttograb = 1;
-                       ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        break;
                }
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                p = p->next;
        }
        if (needlock)
-               ast_pthread_mutex_unlock(&agentlock);
+               ast_mutex_unlock(&agentlock);
        if (parent && chan)  {
                ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
                res = ast_streamfile(newlyavailable->chan, "beep", newlyavailable->chan->language);
@@ -697,10 +697,10 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
                                ast_setstate(chan, AST_STATE_UP);
                                /* Go ahead and mark the channel as a zombie so that masquerade will
                                   destroy it for us, and we need not call ast_hangup */
-                               ast_pthread_mutex_lock(&parent->lock);
+                               ast_mutex_lock(&parent->lock);
                                chan->zombie = 1;
                                ast_channel_masquerade(parent, chan);
-                               ast_pthread_mutex_unlock(&parent->lock);
+                               ast_mutex_unlock(&parent->lock);
                                p->abouttograb = 0;
                        } else {
                                ast_log(LOG_DEBUG, "Sneaky, parent disappeared in the mean time...\n");
@@ -732,10 +732,10 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
        }
 
        /* Check actual logged in agents first */
-       ast_pthread_mutex_lock(&agentlock);
+       ast_mutex_lock(&agentlock);
        p = agents;
        while(p) {
-               ast_pthread_mutex_lock(&p->lock);
+               ast_mutex_lock(&p->lock);
                if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
                                !p->lastdisc.tv_sec && !strlen(p->loginchan)) {
                        /* Agent must be registered, but not have any active call, and not be in a waiting state */
@@ -749,17 +749,17 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
                                        chan = agent_new(p, AST_STATE_DOWN);
                        }
                        if (chan) {
-                               ast_pthread_mutex_unlock(&p->lock);
+                               ast_mutex_unlock(&p->lock);
                                break;
                        }
                }
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                p = p->next;
        }
        if (!p) {
                p = agents;
                while(p) {
-                       ast_pthread_mutex_lock(&p->lock);
+                       ast_mutex_lock(&p->lock);
                        if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
                                        !p->lastdisc.tv_sec) {
                                /* Agent must be registered, but not have any active call, and not be in a waiting state */
@@ -773,11 +773,11 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
                                                chan = agent_new(p, AST_STATE_DOWN);
                                }
                                if (chan) {
-                                       ast_pthread_mutex_unlock(&p->lock);
+                                       ast_mutex_unlock(&p->lock);
                                        break;
                                }
                        }
-                       ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        p = p->next;
                }
        }
@@ -793,7 +793,7 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
                        ast_log(LOG_WARNING, "Weird...  Fix this to drop the unused pending agent\n");
                }
        }
-       ast_pthread_mutex_unlock(&agentlock);
+       ast_mutex_unlock(&agentlock);
        return chan;
 }
 
@@ -816,10 +816,10 @@ static int agents_show(int fd, int argc, char **argv)
 
        if (argc != 2)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&agentlock);
+       ast_mutex_lock(&agentlock);
        p = agents;
        while(p) {
-               ast_pthread_mutex_lock(&p->lock);
+               ast_mutex_lock(&p->lock);
                if (p->pending) {
                        if (p->group)
                                ast_cli(fd, "-- Pending call to group %d\n", powerof(p->group));
@@ -851,10 +851,10 @@ static int agents_show(int fd, int argc, char **argv)
                        ast_cli(fd, "%-12.12s %s%s%s%s\n", p->agent, 
                                        username, location, talkingto, moh);
                }
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&agentlock);
+       ast_mutex_unlock(&agentlock);
        return RESULT_SUCCESS;
 }
 
@@ -917,14 +917,14 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
        }
        while (!res && (tries < 3)) {
                /* Check for password */
-               ast_pthread_mutex_lock(&agentlock);
+               ast_mutex_lock(&agentlock);
                p = agents;
                while(p) {
                        if (!strcmp(p->agent, user) && !p->pending)
                                strncpy(xpass, p->password, sizeof(xpass) - 1);
                        p = p->next;
                }
-               ast_pthread_mutex_unlock(&agentlock);
+               ast_mutex_unlock(&agentlock);
                if (!res) {
                        if (strlen(xpass))
                                res = ast_app_getdata(chan, "agent-pass", pass, sizeof(pass) - 1, 0);
@@ -938,10 +938,10 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
 #endif         
 
                /* Check again for accuracy */
-               ast_pthread_mutex_lock(&agentlock);
+               ast_mutex_lock(&agentlock);
                p = agents;
                while(p) {
-                       ast_pthread_mutex_lock(&p->lock);
+                       ast_mutex_lock(&p->lock);
                        if (!strcmp(p->agent, user) &&
                                !strcmp(p->password, pass) && !p->pending) {
                                        if (!p->chan) {
@@ -992,8 +992,8 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                res = ast_waitstream(chan, "");
                                                        if (!res)
                                                                res = ast_safe_sleep(chan, 1000);
-                                                       ast_pthread_mutex_unlock(&p->lock);
-                                                       ast_pthread_mutex_unlock(&agentlock);
+                                                       ast_mutex_unlock(&p->lock);
+                                                       ast_mutex_unlock(&agentlock);
                                                } else if (!res) {
                                                        /* check if the moh class was changed with setmusiconhold */
                                                        if (*(chan->musicclass))
@@ -1011,19 +1011,19 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                        p->chan = chan;
                                                        p->acknowledged = 1;
                                                        check_availability(p, 0);
-                                                       ast_pthread_mutex_unlock(&p->lock);
-                                                       ast_pthread_mutex_unlock(&agentlock);
+                                                       ast_mutex_unlock(&p->lock);
+                                                       ast_mutex_unlock(&agentlock);
                                                        while (res >= 0) {
-                                                               ast_pthread_mutex_lock(&p->lock);
+                                                               ast_mutex_lock(&p->lock);
                                                                if (p->chan != chan)
                                                                        res = -1;
-                                                               ast_pthread_mutex_unlock(&p->lock);
+                                                               ast_mutex_unlock(&p->lock);
                                                                /* Yield here so other interested threads can kick in. */
                                                                sched_yield();
                                                                if (res)
                                                                        break;
 
-                                                               ast_pthread_mutex_lock(&p->lock);
+                                                               ast_mutex_lock(&p->lock);
                                                                if (p->lastdisc.tv_sec) {
                                                                        gettimeofday(&tv, NULL);
                                                                        if ((tv.tv_sec - p->lastdisc.tv_sec) * 1000 + 
@@ -1033,25 +1033,25 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                                check_availability(p, 1);
                                                                        }
                                                                }
-                                                               ast_pthread_mutex_unlock(&p->lock);
+                                                               ast_mutex_unlock(&p->lock);
                                                                /*      Synchronize channel ownership between call to agent and itself. */
-                                                               pthread_mutex_lock( &p->app_lock );
-                                                               ast_pthread_mutex_lock(&p->lock);
+                                                               ast_mutex_lock( &p->app_lock );
+                                                               ast_mutex_lock(&p->lock);
                                                                p->owning_app = pthread_self();
-                                                               ast_pthread_mutex_unlock(&p->lock);
+                                                               ast_mutex_unlock(&p->lock);
                                                                res = ast_safe_sleep_conditional( chan, 1000,
                                                                                                                agent_cont_sleep, p );
-                                                               pthread_mutex_unlock( &p->app_lock );
+                                                               ast_mutex_unlock( &p->app_lock );
                                                                sched_yield();
                                                        }
-                                                       ast_pthread_mutex_lock(&p->lock);
+                                                       ast_mutex_lock(&p->lock);
                                                        if (res && p->owner) 
                                                                ast_log(LOG_WARNING, "Huh?  We broke out when there was still an owner?\n");
                                                        /* Log us off if appropriate */
                                                        if (p->chan == chan)
                                                                p->chan = NULL;
                                                        p->acknowledged = 0;
-                                                       ast_pthread_mutex_unlock(&p->lock);
+                                                       ast_mutex_unlock(&p->lock);
                                                        if (option_verbose > 2)
                                                                ast_verbose(VERBOSE_PREFIX_3 "Agent '%s' logged out\n", p->agent);
                                                        manager_event(EVENT_FLAG_AGENT, "Agentlogoff",
@@ -1062,22 +1062,22 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                free(p);
                                                }
                                                else {
-                                                       ast_pthread_mutex_unlock(&p->lock);
+                                                       ast_mutex_unlock(&p->lock);
                                                        p = NULL;
                                                }
                                                res = -1;
                                        } else {
-                                               ast_pthread_mutex_unlock(&p->lock);
+                                               ast_mutex_unlock(&p->lock);
                                                errmsg = "agent-alreadyon";
                                                p = NULL;
                                        }
                                        break;
                        }
-                       ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        p = p->next;
                }
                if (!p)
-                       ast_pthread_mutex_unlock(&agentlock);
+                       ast_mutex_unlock(&agentlock);
 
                if (!res)
                        res = ast_app_getdata(chan, errmsg, user, sizeof(user) - 1, 0);
@@ -1127,7 +1127,7 @@ int unload_module()
        ast_unregister_application(app);
        ast_unregister_application(app2);
        ast_channel_unregister(type);
-       if (!ast_pthread_mutex_lock(&agentlock)) {
+       if (!ast_mutex_lock(&agentlock)) {
                /* Hangup all interfaces if they have an owner */
                p = agents;
                while(p) {
@@ -1136,7 +1136,7 @@ int unload_module()
                        p = p->next;
                }
                agents = NULL;
-               ast_pthread_mutex_unlock(&agentlock);
+               ast_mutex_unlock(&agentlock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
@@ -1147,9 +1147,9 @@ int unload_module()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index dfbce57..e7ec368 100755 (executable)
@@ -71,7 +71,7 @@ static int silencethreshold = 1000;
 static char digits[80] = "";
 static char text2send[80] = "";
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char *type = "Console";
 static char *desc = "ALSA Console Channel Driver";
@@ -518,9 +518,9 @@ static int alsa_hangup(struct ast_channel *c)
        c->pvt->pvt = NULL;
        alsa.owner = NULL;
        ast_verbose( " << Hangup on console >> \n");
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt--;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        needhangup = 0;
        needanswer = 0;
        if (hookstate) {
@@ -807,9 +807,9 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
                        strncpy(tmp->language, language, sizeof(tmp->language)-1);
                p->owner = tmp;
                ast_setstate(tmp, state);
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -1103,9 +1103,9 @@ char *description()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index b986991..1d1c354 100755 (executable)
@@ -91,7 +91,7 @@ static int tos = 0;
 static int expirey = AST_DEFAULT_REG_EXPIRE;
 
 static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 int (*iax_regfunk)(char *username, int onoff) = NULL;
 
@@ -384,17 +384,17 @@ static struct ast_iax_queue {
        struct ast_iax_frame *head;
        struct ast_iax_frame *tail;
        int count;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } iaxq;
 
 static struct ast_user_list {
        struct iax_user *users;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } userl;
 
 static struct ast_peer_list {
        struct iax_peer *peers;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } peerl;
 
 /* Extension exists */
@@ -426,7 +426,7 @@ static struct iax_dpcache {
        struct iax_dpcache *peer;       /* For linking in peers */
 } *dpcache;
 
-static pthread_mutex_t dpcache_lock;
+static ast_mutex_t dpcache_lock;
 
 #ifdef DEBUG_SUPPORT
 static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int rx, struct sockaddr_in *sin)
@@ -541,7 +541,7 @@ static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int
 
 /* XXX We probably should use a mutex when working with this XXX */
 static struct chan_iax_pvt *iaxs[AST_IAX_MAX_CALLS];
-static pthread_mutex_t iaxsl[AST_IAX_MAX_CALLS];
+static ast_mutex_t iaxsl[AST_IAX_MAX_CALLS];
 
 static int send_command(struct chan_iax_pvt *, char, int, unsigned int, char *, int, int);
 static int send_command_immediate(struct chan_iax_pvt *, char, int, unsigned int, char *, int, int);
@@ -767,14 +767,14 @@ static int find_callno(short callno, short dcallno ,struct sockaddr_in *sin, int
        if (new <= NEW_ALLOW) {
                /* Look for an existing connection first */
                for (x=0;(res < 0) && (x<AST_IAX_MAX_CALLS);x++) {
-                       ast_pthread_mutex_lock(&iaxsl[x]);
+                       ast_mutex_lock(&iaxsl[x]);
                        if (iaxs[x]) {
                                /* Look for an exact match */
                                if (match(sin, callno, dcallno, iaxs[x])) {
                                        res = x;
                                }
                        }
-                       ast_pthread_mutex_unlock(&iaxsl[x]);
+                       ast_mutex_unlock(&iaxsl[x]);
                }
        }
        if ((res < 0) && (new >= NEW_ALLOW)) {
@@ -785,9 +785,9 @@ static int find_callno(short callno, short dcallno ,struct sockaddr_in *sin, int
                        ast_log(LOG_WARNING, "Unable to accept more calls\n");
                        return -1;
                }
-               ast_pthread_mutex_lock(&iaxsl[x]);
+               ast_mutex_lock(&iaxsl[x]);
                iaxs[x] = new_iax();
-               ast_pthread_mutex_unlock(&iaxsl[x]);
+               ast_mutex_unlock(&iaxsl[x]);
                if (iaxs[x]) {
                        if (option_debug)
                                ast_log(LOG_DEBUG, "Creating new call structure %d\n", x);
@@ -818,19 +818,19 @@ static int iax_queue_frame(int callno, struct ast_frame *f)
        /* Assumes lock for callno is already held... */
        for (;;) {
                pass++;
-               if (!pthread_mutex_trylock(&iaxsl[callno])) {
+               if (!ast_mutex_trylock(&iaxsl[callno])) {
                        ast_log(LOG_WARNING, "Lock is not held on pass %d of iax_queue_frame\n", pass);
                        CRASH;
                }
                if (iaxs[callno] && iaxs[callno]->owner) {
-                       if (pthread_mutex_trylock(&iaxs[callno]->owner->lock)) {
+                       if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
                                /* Avoid deadlock by pausing and trying again */
-                               ast_pthread_mutex_unlock(&iaxsl[callno]);
+                               ast_mutex_unlock(&iaxsl[callno]);
                                usleep(1);
-                               ast_pthread_mutex_lock(&iaxsl[callno]);
+                               ast_mutex_lock(&iaxsl[callno]);
                        } else {
                                ast_queue_frame(iaxs[callno]->owner, f, 0);
-                               ast_pthread_mutex_unlock(&iaxs[callno]->owner->lock);
+                               ast_mutex_unlock(&iaxs[callno]->owner->lock);
                                break;
                        }
                } else
@@ -879,9 +879,9 @@ static int do_deliver(void *data)
        struct ast_iax_frame *fr = data;
        int callno = fr->callno;
        int res;
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        res = __do_deliver(data);
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return res;
 }
 
@@ -963,10 +963,10 @@ static int iax_predestroy(int callno)
 {
        struct ast_channel *c;
        struct chan_iax_pvt *pvt;
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        pvt = iaxs[callno];
        if (!pvt) {
-               ast_pthread_mutex_unlock(&iaxsl[callno]);
+               ast_mutex_unlock(&iaxsl[callno]);
                return -1;
        }
        if (!pvt->alreadygone) {
@@ -990,23 +990,23 @@ static int iax_predestroy(int callno)
                c->_softhangup |= AST_SOFTHANGUP_DEV;
                c->pvt->pvt = NULL;
                pvt->owner = NULL;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt--;
                if (usecnt < 0) 
                        ast_log(LOG_WARNING, "Usecnt < 0???\n");
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return 0;
 }
 
 static int iax_predestroy_nolock(int callno)
 {
        int res;
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        res = iax_predestroy(callno);
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        return res;
 }
 
@@ -1017,7 +1017,7 @@ static void iax_destroy(int callno)
        struct ast_channel *owner;
 
 retry:
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        pvt = iaxs[callno];
        iaxs[callno] = NULL;
 
@@ -1026,9 +1026,9 @@ retry:
        else
                owner = NULL;
        if (owner) {
-               if (pthread_mutex_trylock(&owner->lock)) {
+               if (ast_mutex_trylock(&owner->lock)) {
                        ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
-                       ast_pthread_mutex_unlock(&iaxsl[callno]);
+                       ast_mutex_unlock(&iaxsl[callno]);
                        usleep(1);
                        goto retry;
                }
@@ -1070,16 +1070,16 @@ retry:
                free(pvt);
        }
        if (owner) {
-               ast_pthread_mutex_unlock(&owner->lock);
+               ast_mutex_unlock(&owner->lock);
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
 }
 static void iax_destroy_nolock(int callno)
 {      
        /* Actually it's easier to unlock, kill it, and relock */
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        iax_destroy(callno);
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
 }
 
 
@@ -1093,7 +1093,7 @@ static int attempt_transmit(void *data)
        int callno = f->callno;
        /* Make sure this call is still active */
        if (callno > -1) 
-               ast_pthread_mutex_lock(&iaxsl[callno]);
+               ast_mutex_lock(&iaxsl[callno]);
        if ((f->callno > -1) && iaxs[f->callno]) {
                if ((f->retries < 0) /* Already ACK'd */ ||
                    (f->retries >= max_retries) /* Too many attempts */) {
@@ -1146,11 +1146,11 @@ static int attempt_transmit(void *data)
                freeme++;
        }
        if (callno > -1)
-               ast_pthread_mutex_unlock(&iaxsl[callno]);
+               ast_mutex_unlock(&iaxsl[callno]);
        /* Do not try again */
        if (freeme) {
                /* Don't attempt delivery, just remove it from the queue */
-               ast_pthread_mutex_lock(&iaxq.lock);
+               ast_mutex_lock(&iaxq.lock);
                if (f->prev) 
                        f->prev->next = f->next;
                else
@@ -1160,7 +1160,7 @@ static int attempt_transmit(void *data)
                else
                        iaxq.tail = f->prev;
                iaxq.count--;
-               ast_pthread_mutex_unlock(&iaxq.lock);
+               ast_mutex_unlock(&iaxq.lock);
                /* Free the frame */
                ast_frfree(f->f);
                f->retrans = -1;
@@ -1228,7 +1228,7 @@ static int iax_show_cache(int fd, int argc, char *argv[])
        int x,y;
        struct timeval tv;
        gettimeofday(&tv, NULL);
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = dpcache;
        ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
        while(dp) {
@@ -1270,7 +1270,7 @@ static int iax_show_cache(int fd, int argc, char *argv[])
                        ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->exten, "(expired)", y, tmp);
                dp = dp->next;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        return RESULT_SUCCESS;
 }
 
@@ -1453,7 +1453,7 @@ static int iax_transmit(struct ast_iax_frame *fr)
        /* By setting this to 0, the network thread will send it for us, and
           queue retransmission if necessary */
        fr->sentyet = 0;
-       ast_pthread_mutex_lock(&iaxq.lock);
+       ast_mutex_lock(&iaxq.lock);
        if (!iaxq.head) {
                /* Empty queue */
                iaxq.head = fr;
@@ -1465,7 +1465,7 @@ static int iax_transmit(struct ast_iax_frame *fr)
                iaxq.tail = fr;
        }
        iaxq.count++;
-       ast_pthread_mutex_unlock(&iaxq.lock);
+       ast_mutex_unlock(&iaxq.lock);
        /* Wake up the network thread */
        pthread_kill(netthreadid, SIGURG);
        return 0;
@@ -1512,7 +1512,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
        if (maxtime)
                *maxtime = 0;
        sin->sin_family = AF_INET;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        p = peerl.peers;
        while(p) {
                if (!strcasecmp(p->name, peer)) {
@@ -1539,7 +1539,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (!p && !found) {
                hp = gethostbyname(peer);
                if (hp) {
@@ -1560,13 +1560,13 @@ static int auto_congest(void *nothing)
 {
        int callno = (int)(long)(nothing);
        struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_CONGESTION };
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno]) {
                iaxs[callno]->initid = -1;
                iax_queue_frame(callno, &f);
                ast_log(LOG_NOTICE, "Auto-congesting call due to slow response\n");
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return 0;
 }
 
@@ -1683,7 +1683,7 @@ static int iax_hangup(struct ast_channel *c)
        int callno;
        if (pvt) {
                callno = pvt->callno;
-               ast_pthread_mutex_lock(&iaxsl[callno]);
+               ast_mutex_lock(&iaxsl[callno]);
                ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
                alreadygone = pvt->alreadygone;
                /* Send the hangup unless we have had a transmission error or are already gone */
@@ -1696,7 +1696,7 @@ static int iax_hangup(struct ast_channel *c)
                        ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
                        iax_destroy_nolock(callno);
                }
-               ast_pthread_mutex_unlock(&iaxsl[callno]);
+               ast_mutex_unlock(&iaxsl[callno]);
        }
        if (option_verbose > 2) 
                ast_verbose(VERBOSE_PREFIX_3 "Hungup '%s'\n", c->name);
@@ -1886,7 +1886,7 @@ static int iax_getpeername(struct sockaddr_in sin, char *host, int len)
 {
        struct iax_peer *peer;
        int res = 0;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
@@ -1897,7 +1897,7 @@ static int iax_getpeername(struct sockaddr_in sin, char *host, int len)
                }
                peer = peer->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return res;
 }
 
@@ -1950,9 +1950,9 @@ static struct ast_channel *ast_iax_new(struct chan_iax_pvt *i, int state, int ca
                i->owner = tmp;
                i->capability = capability;
                ast_setstate(tmp, state);
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -2142,14 +2142,14 @@ static int iax_show_users(int fd, int argc, char *argv[])
        struct iax_user *user;
        if (argc != 3) 
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        ast_cli(fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C");
        for(user=userl.users;user;user=user->next) {
                ast_cli(fd, FORMAT, user->name, user->secret, user->methods, 
                                user->contexts ? user->contexts->context : context,
                                user->ha ? "Yes" : "No");
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 }
@@ -2162,7 +2162,7 @@ static int iax_show_peers(int fd, int argc, char *argv[])
        char name[256] = "";
        if (argc != 3)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "Status");
        for (peer = peerl.peers;peer;peer = peer->next) {
                char nm[20];
@@ -2189,7 +2189,7 @@ static int iax_show_peers(int fd, int argc, char *argv[])
                                        nm,
                                        ntohs(peer->addr.sin_port), status);
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -2236,7 +2236,7 @@ static int iax_show_registry(int fd, int argc, char *argv[])
        char perceived[80];
        if (argc != 3)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        ast_cli(fd, FORMAT2, "Host", "Username", "Perceived", "Refresh", "State");
        for (reg = registrations;reg;reg = reg->next) {
                snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
@@ -2247,7 +2247,7 @@ static int iax_show_registry(int fd, int argc, char *argv[])
                ast_cli(fd, FORMAT, host, 
                                        reg->username, perceived, reg->refresh, regstate2str(reg->regstate));
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -2263,7 +2263,7 @@ static int iax_show_channels(int fd, int argc, char *argv[])
                return RESULT_SHOWUSAGE;
        ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
        for (x=0;x<AST_IAX_MAX_CALLS;x++) {
-               ast_pthread_mutex_lock(&iaxsl[x]);
+               ast_mutex_lock(&iaxsl[x]);
                if (iaxs[x]) {
                        ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr), 
                                                strlen(iaxs[x]->username) ? iaxs[x]->username : "(None)", 
@@ -2274,7 +2274,7 @@ static int iax_show_channels(int fd, int argc, char *argv[])
                                                iaxs[x]->voiceformat);
                        numchans++;
                }
-               ast_pthread_mutex_unlock(&iaxsl[x]);
+               ast_mutex_unlock(&iaxsl[x]);
        }
        ast_cli(fd, "%d active IAX channel(s)\n", numchans);
        return RESULT_SUCCESS;
@@ -2499,7 +2499,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
                        inet_ntoa(sin->sin_addr), version);
                return res;
        }
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        /* Search the userlist for a compatible entry, and fill in the rest */
        user = userl.users;
        while(user) {
@@ -2541,7 +2541,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
                }
                user = user->next;      
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        return res;
 }
 
@@ -2860,7 +2860,7 @@ static int authenticate_reply(struct chan_iax_pvt *p, struct sockaddr_in *sin, c
                /* Normal password authentication */
                res = authenticate(p->challenge, override, okey, methods, requeststr, sizeof(requeststr), sin);
        } else {
-               ast_pthread_mutex_lock(&peerl.lock);
+               ast_mutex_lock(&peerl.lock);
                peer = peerl.peers;
                while(peer) {
                        if ((!strlen(p->peer) || !strcmp(p->peer, peer->name)) 
@@ -2876,7 +2876,7 @@ static int authenticate_reply(struct chan_iax_pvt *p, struct sockaddr_in *sin, c
                        }
                        peer = peer->next;
                }
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
        }
        if (strlen(requeststr))
                requeststr[strlen(requeststr)-1] = '\0';
@@ -2983,7 +2983,7 @@ static int complete_dpreply(struct chan_iax_pvt *pvt, char *orequest)
                }
                var = strsep(&stringp, ";");
        }
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        prev = NULL;
        dp = pvt->dpentries;
        while(dp) {
@@ -3009,7 +3009,7 @@ static int complete_dpreply(struct chan_iax_pvt *pvt, char *orequest)
                prev = dp;
                dp = dp->peer;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        return 0;
 }
 
@@ -3063,7 +3063,7 @@ static int complete_transfer(int callno, char *orequest)
        pvt->last = 0;
        pvt->lastsent = 0;
        pvt->pingtime = DEFAULT_RETRY_TIME;
-       ast_pthread_mutex_lock(&iaxq.lock);
+       ast_mutex_lock(&iaxq.lock);
        for (cur = iaxq.head; cur ; cur = cur->next) {
                /* We must cancel any packets that would have been transmitted
                   because now we're talking to someone new.  It's okay, they
@@ -3071,7 +3071,7 @@ static int complete_transfer(int callno, char *orequest)
                if (callno == cur->callno) 
                        cur->retries = -1;
        }
-       ast_pthread_mutex_unlock(&iaxq.lock);
+       ast_mutex_unlock(&iaxq.lock);
        return 0; 
 }
 
@@ -3353,12 +3353,12 @@ static int auto_hangup(void *nothing)
 {
        /* Called from IAX thread only, without iaxs lock */
        int callno = (int)(long)(nothing);
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno]) {
                iaxs[callno]->autoid = -1;
                send_command_final(iaxs[callno], AST_FRAME_IAX, AST_IAX_COMMAND_HANGUP, 0, "Timeout", strlen("Timeout") + 1, -1);
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return 0;
 }
 
@@ -3380,7 +3380,7 @@ static int iax_vnak(int callno)
 static void vnak_retransmit(int callno, int last)
 {
        struct ast_iax_frame *f;
-       ast_pthread_mutex_lock(&iaxq.lock);
+       ast_mutex_lock(&iaxq.lock);
        f = iaxq.head;
        while(f) {
                /* Send a copy immediately */
@@ -3390,7 +3390,7 @@ static void vnak_retransmit(int callno, int last)
                }
                f = f->next;
        }
-       ast_pthread_mutex_unlock(&iaxq.lock);
+       ast_mutex_unlock(&iaxq.lock);
 }
 
 static int iax_poke_peer_s(void *data)
@@ -3460,7 +3460,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
        fr.callno = find_callno(ntohs(mh->callno) & ~AST_FLAG_FULL, dcallno, &sin, new);
 
        if (fr.callno > 0) 
-               ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+               ast_mutex_lock(&iaxsl[fr.callno]);
 
        if ((fr.callno < 0) || !iaxs[fr.callno]) {
                /* A call arrived for a non-existant destination.  Unless it's an "inval"
@@ -3475,7 +3475,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                );
                }
                if (fr.callno > 0) 
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                return 1;
        }
        if (((f.subclass != AST_IAX_COMMAND_TXCNT) &&
@@ -3515,7 +3515,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        /* Send a VNAK requesting retransmission */
                                        iax_vnak(fr.callno);
                                }
-                               ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                               ast_mutex_unlock(&iaxsl[fr.callno]);
                                return 1;
                        }
                } else {
@@ -3531,7 +3531,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                /* A full frame */
                if (res < sizeof(struct ast_iax_full_hdr)) {
                        ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, sizeof(struct ast_iax_full_hdr));
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                f.datalen = res - sizeof(struct ast_iax_full_hdr);
@@ -3553,13 +3553,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
                                        if (iaxs[fr.callno]->owner) {
                                                int orignative;
-                                               ast_pthread_mutex_lock(&iaxs[fr.callno]->owner->lock);
+                                               ast_mutex_lock(&iaxs[fr.callno]->owner->lock);
                                                orignative = iaxs[fr.callno]->owner->nativeformats;
                                                iaxs[fr.callno]->owner->nativeformats = f.subclass;
                                                if (iaxs[fr.callno]->owner->readformat)
                                                        ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
                                                iaxs[fr.callno]->owner->nativeformats = orignative;
-                                               ast_pthread_mutex_unlock(&iaxs[fr.callno]->owner->lock);
+                                               ast_mutex_unlock(&iaxs[fr.callno]->owner->lock);
                                        }
                        }
                }
@@ -3579,7 +3579,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                        switch(f.subclass) {
                        case AST_IAX_COMMAND_ACK:
                                /* Ack the packet with the given timestamp */
-                               ast_pthread_mutex_lock(&iaxq.lock);
+                               ast_mutex_lock(&iaxq.lock);
                                for (cur = iaxq.head; cur ; cur = cur->next) {
                                        /* If it's our call, and our timestamp, mark -1 retries */
                                        if ((fr.callno == cur->callno) && (fr.seqno == cur->seqno)) {
@@ -3592,7 +3592,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                                }
                                        }
                                }
-                               ast_pthread_mutex_unlock(&iaxq.lock);
+                               ast_mutex_unlock(&iaxq.lock);
                                break;
                        case AST_IAX_COMMAND_QUELCH:
                                if (iaxs[fr.callno]->state & IAX_STATE_STARTED)
@@ -3605,13 +3605,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                        case AST_IAX_COMMAND_TXACC:
                                if (iaxs[fr.callno]->transferring == TRANSFER_BEGIN) {
                                        /* Ack the packet with the given timestamp */
-                                       ast_pthread_mutex_lock(&iaxq.lock);
+                                       ast_mutex_lock(&iaxq.lock);
                                        for (cur = iaxq.head; cur ; cur = cur->next) {
                                                /* Cancel any outstanding txcnt's */
                                                if ((fr.callno == cur->callno) && (cur->transfer))
                                                        cur->retries = -1;
                                        }
-                                       ast_pthread_mutex_unlock(&iaxq.lock);
+                                       ast_mutex_unlock(&iaxq.lock);
                                        snprintf(rel1, sizeof(rel1), "callno=%d;", iaxs[fr.callno]->callno);
                                        send_command(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_TXREADY, 0, rel1, strlen(rel1) + 1, -1);
                                        iaxs[fr.callno]->transferring = TRANSFER_READY;
@@ -3745,7 +3745,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                                        ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);        
                                        }
                                }
-                               ast_pthread_mutex_lock(&dpcache_lock);
+                               ast_mutex_lock(&dpcache_lock);
                                dp = iaxs[fr.callno]->dpentries;
                                while(dp) {
                                        if (!(dp->flags & CACHE_FLAG_TRANSMITTED)) {
@@ -3753,7 +3753,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        }
                                        dp = dp->peer;
                                }
-                               ast_pthread_mutex_unlock(&dpcache_lock);
+                               ast_mutex_unlock(&dpcache_lock);
                                break;
                        case AST_IAX_COMMAND_POKE:
                                /* Send back a pong packet with the original timestamp */
@@ -4030,7 +4030,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr.callno, iaxs[fr.callno]->peercallno);
                        }
                        /* Don't actually pass these frames along */
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
        } else {
@@ -4041,13 +4041,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                else {
                        ast_log(LOG_WARNING, "Received mini frame before first full voice frame\n ");
                        iax_vnak(fr.callno);
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                f.datalen = res - sizeof(struct ast_iax_mini_hdr);
                if (f.datalen < 0) {
                        ast_log(LOG_WARNING, "Datalen < 0?\n");
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                if (f.datalen)
@@ -4058,7 +4058,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
        }
        /* Don't pass any packets until we're started */
        if (!(iaxs[fr.callno]->state & IAX_STATE_STARTED)) {
-               ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+               ast_mutex_unlock(&iaxsl[fr.callno]);
                return 1;
        }
        /* Common things */
@@ -4090,7 +4090,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
        schedule_delivery(iaxfrdup2(&fr, 0), 1);
 #endif
        /* Always run again */
-       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+       ast_mutex_unlock(&iaxsl[fr.callno]);
        return 1;
 }
 
@@ -4209,12 +4209,12 @@ static struct ast_channel *iax_request(char *type, int format, void *data)
                ast_log(LOG_WARNING, "Unable to create call\n");
                return NULL;
        }
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        /* Keep track of sendani flag */
        iaxs[callno]->sendani = sendani;
        iaxs[callno]->maxtime = maxtime;
        c = ast_iax_new(iaxs[callno], AST_STATE_DOWN, capability);
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        if (c) {
                /* Choose a format we can live with */
                if (c->nativeformats & format)
@@ -4245,7 +4245,7 @@ static void *network_thread(void *ignore)
        for(;;) {
                /* Go through the queue, sending messages which have not yet been
                   sent, and scheduling retransmissions if appropriate */
-               ast_pthread_mutex_lock(&iaxq.lock);
+               ast_mutex_lock(&iaxq.lock);
                f = iaxq.head;
                while(f) {
                        freeme = NULL;
@@ -4281,7 +4281,7 @@ static void *network_thread(void *ignore)
                        if (freeme)
                                ast_iax_frame_free(freeme);
                }
-               ast_pthread_mutex_unlock(&iaxq.lock);
+               ast_mutex_unlock(&iaxq.lock);
                res = ast_sched_wait(sched);
                if ((res > 1000) || (res < 0))
                        res = 1000;
@@ -4316,7 +4316,7 @@ static struct iax_peer *build_peer(char *name, struct ast_variable *v)
        int format;
        int found=0;
        prev = NULL;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if (!strcasecmp(peer->name, name)) {    
@@ -4333,9 +4333,9 @@ static struct iax_peer *build_peer(char *name, struct ast_variable *v)
                } else {
                        peerl.peers = peer->next;
                }
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
        } else {
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
                peer = malloc(sizeof(struct iax_peer));
                memset(peer, 0, sizeof(struct iax_peer));
                peer->expire = -1;
@@ -4507,7 +4507,7 @@ static void delete_users(void){
        struct iax_registry *reg, *regl;
 
        /* Delete all users */
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        for (user=userl.users;user;) {
                ast_free_ha(user->ha);
                free_context(user->contexts);
@@ -4516,7 +4516,7 @@ static void delete_users(void){
                free(userlast);
        }
        userl.users=NULL;
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
 
        for (reg = registrations;reg;) {
                regl = reg;
@@ -4526,30 +4526,30 @@ static void delete_users(void){
                free(regl);
        }
        registrations = NULL;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        for (peer=peerl.peers;peer;) {
                /* Assume all will be deleted, and we'll find out for sure later */
                peer->delme = 1;
                peer = peer->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
 }
 
 static void prune_peers(void){
        /* Prune peers who still are supposed to be deleted */
        struct iax_peer *peer, *peerlast, *peernext;
        int x;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peerlast = NULL;
        for (peer=peerl.peers;peer;) {
                peernext = peer->next;
                if (peer->delme) {
                        for (x=0;x<AST_IAX_MAX_CALLS;x++) {
-                               ast_pthread_mutex_lock(&iaxsl[x]);
+                               ast_mutex_lock(&iaxsl[x]);
                                if (iaxs[x] && (iaxs[x]->peerpoke == peer)) {
                                        iax_destroy(x);
                                }
-                               ast_pthread_mutex_unlock(&iaxsl[x]);
+                               ast_mutex_unlock(&iaxsl[x]);
                        }
                        /* Delete it, it needs to disappear */
                        if (peer->expire > -1)
@@ -4567,7 +4567,7 @@ static void prune_peers(void){
                        peerlast = peer;
                peer=peernext;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
 }
 
 
@@ -4675,19 +4675,19 @@ static int set_config(char *config_file, struct sockaddr_in* sin){
                                if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
                                        user = build_user(cat, ast_variable_browse(cfg, cat));
                                        if (user) {
-                                               ast_pthread_mutex_lock(&userl.lock);
+                                               ast_mutex_lock(&userl.lock);
                                                user->next = userl.users;
                                                userl.users = user;
-                                               ast_pthread_mutex_unlock(&userl.lock);
+                                               ast_mutex_unlock(&userl.lock);
                                        }
                                }
                                if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
                                        peer = build_peer(cat, ast_variable_browse(cfg, cat));
                                        if (peer) {
-                                               ast_pthread_mutex_lock(&peerl.lock);
+                                               ast_mutex_lock(&peerl.lock);
                                                peer->next = peerl.peers;
                                                peerl.peers = peer;
-                                               ast_pthread_mutex_unlock(&peerl.lock);
+                                               ast_mutex_unlock(&peerl.lock);
                                        }
                                } else if (strcasecmp(utype, "user")) {
                                        ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
@@ -4736,12 +4736,12 @@ static int cache_get_callno(char *data)
        for (x=0;x<AST_IAX_MAX_CALLS; x++) {
                /* Look for an *exact match* call.  Once a call is negotiated, it can only
                   look up entries for a single context */
-               if (!pthread_mutex_trylock(&iaxsl[x])) {
+               if (!ast_mutex_trylock(&iaxsl[x])) {
                        if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) {
-                               ast_pthread_mutex_unlock(&iaxsl[x]);
+                               ast_mutex_unlock(&iaxsl[x]);
                                return x;
                        }
-                       ast_pthread_mutex_unlock(&iaxsl[x]);
+                       ast_mutex_unlock(&iaxsl[x]);
                }
        }
        /* No match found, we need to create a new one */
@@ -4779,7 +4779,7 @@ static int cache_get_callno(char *data)
                ast_log(LOG_WARNING, "Unable to create call\n");
                return -1;
        }
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        strncpy(iaxs[callno]->dproot, data, sizeof(iaxs[callno]->dproot)-1);
        iaxs[callno]->capability = IAX_CAPABILITY_FULLBANDWIDTH;
        MYSNPRINTF "exten=TBD;");
@@ -4800,7 +4800,7 @@ static int cache_get_callno(char *data)
                ast_verbose(VERBOSE_PREFIX_3 "Calling TBD using options '%s'\n", requeststr);
        /* Start the call going */
        send_command(iaxs[callno], AST_FRAME_IAX, AST_IAX_COMMAND_NEW, 0, requeststr, strlen(requeststr) + 1, -1);
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return callno;
 }
 
@@ -4895,7 +4895,7 @@ static struct iax_dpcache *find_cache(struct ast_channel *chan, char *data, char
                /* Okay, now we wait */
                timeout = iaxdefaulttimeout * 1000;
                /* Temporarily unlock */
-               ast_pthread_mutex_unlock(&dpcache_lock);
+               ast_mutex_unlock(&dpcache_lock);
                /* Defer any dtmf */
                if (chan)
                        old = ast_channel_defer_dtmf(chan);
@@ -4919,7 +4919,7 @@ static struct iax_dpcache *find_cache(struct ast_channel *chan, char *data, char
                if (!timeout) {
                        ast_log(LOG_WARNING, "Timeout waiting for %s exten %s\n", data, exten);
                }
-               ast_pthread_mutex_lock(&dpcache_lock);
+               ast_mutex_lock(&dpcache_lock);
                dp->waiters[x] = -1;
                close(com[1]);
                close(com[0]);
@@ -4961,13 +4961,13 @@ static int iax_exists(struct ast_channel *chan, char *context, char *exten, int
 #endif
        if (priority != 1)
                return 0;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_EXISTS)
                        res= 1;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        if (!dp) {
                ast_log(LOG_WARNING, "Unable to make DP cache\n");
        }
@@ -4983,13 +4983,13 @@ static int iax_canmatch(struct ast_channel *chan, char *context, char *exten, in
 #endif
        if (priority != 1)
                return 0;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_CANEXIST)
                        res= 1;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        if (!dp) {
                ast_log(LOG_WARNING, "Unable to make DP cache\n");
        }
@@ -5005,13 +5005,13 @@ static int iax_matchmore(struct ast_channel *chan, char *context, char *exten, i
 #endif
        if (priority != 1)
                return 0;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_MATCHMORE)
                        res= 1;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        if (!dp) {
                ast_log(LOG_WARNING, "Unable to make DP cache\n");
        }
@@ -5030,7 +5030,7 @@ static int iax_exec(struct ast_channel *chan, char *context, char *exten, int pr
 #endif
        if (priority != 1)
                return -1;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_EXISTS) {
@@ -5046,12 +5046,12 @@ static int iax_exec(struct ast_channel *chan, char *context, char *exten, int pr
                        if (option_verbose > 2)
                                ast_verbose(VERBOSE_PREFIX_3 "Executing Dial('%s')\n", req);
                } else {
-                       ast_pthread_mutex_unlock(&dpcache_lock);
+                       ast_mutex_unlock(&dpcache_lock);
                        ast_log(LOG_WARNING, "Can't execute non-existant extension '%s[@%s]' in data '%s'\n", exten, context, data);
                        return -1;
                }
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        dial = pbx_findapp("Dial");
        if (dial) {
                pbx_exec(chan, dial, req, newstack);
@@ -5089,7 +5089,7 @@ int load_module(void)
        sin.sin_addr.s_addr = INADDR_ANY;
 
        for (x=0;x<AST_IAX_MAX_CALLS;x++)
-               ast_pthread_mutex_init(&iaxsl[x]);
+               ast_mutex_init(&iaxsl[x]);
        
        io = io_context_create();
        sched = sched_context_create();
@@ -5099,10 +5099,10 @@ int load_module(void)
                return -1;
        }
 
-       ast_pthread_mutex_init(&iaxq.lock);
-       ast_pthread_mutex_init(&userl.lock);
-       ast_pthread_mutex_init(&peerl.lock);
-       ast_pthread_mutex_init(&dpcache_lock);
+       ast_mutex_init(&iaxq.lock);
+       ast_mutex_init(&userl.lock);
+       ast_mutex_init(&peerl.lock);
+       ast_mutex_init(&dpcache_lock);
 
        ast_cli_register(&cli_show_users);
        ast_cli_register(&cli_show_channels);
@@ -5155,10 +5155,10 @@ int load_module(void)
        }
        for (reg = registrations; reg; reg = reg->next)
                iax_do_register(reg);
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        for (peer = peerl.peers; peer; peer = peer->next)
                iax_poke_peer(peer);
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return res;
 }
 
@@ -5192,9 +5192,9 @@ int unload_module()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 83f4723..b6feec0 100755 (executable)
@@ -107,7 +107,7 @@ static int expirey = IAX_DEFAULT_REG_EXPIRE;
 static int timingfd = -1;                              /* Timing file descriptor */
 
 static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 int (*iax2_regfunk)(char *username, int onoff) = NULL;
 
@@ -397,17 +397,17 @@ static struct ast_iax2_queue {
        struct iax_frame *head;
        struct iax_frame *tail;
        int count;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } iaxq;
 
 static struct ast_user_list {
        struct iax2_user *users;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } userl;
 
 static struct ast_peer_list {
        struct iax2_peer *peers;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } peerl;
 
 /* Extension exists */
@@ -439,7 +439,7 @@ static struct iax2_dpcache {
        struct iax2_dpcache *peer;      /* For linking in peers */
 } *dpcache;
 
-static pthread_mutex_t dpcache_lock;
+static ast_mutex_t dpcache_lock;
 
 static void iax_debug_output(const char *data)
 {
@@ -453,7 +453,7 @@ static void iax_error_output(const char *data)
 
 /* XXX We probably should use a mutex when working with this XXX */
 static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS];
-static pthread_mutex_t iaxsl[IAX_MAX_CALLS];
+static ast_mutex_t iaxsl[IAX_MAX_CALLS];
 static struct timeval lastused[IAX_MAX_CALLS];
 
 
@@ -531,7 +531,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len, int loc
        struct iax2_peer *peer;
        int res = 0;
        if (lockpeer)
-               ast_pthread_mutex_lock(&peerl.lock);
+               ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
@@ -543,7 +543,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len, int loc
                peer = peer->next;
        }
        if (lockpeer)
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
        return res;
 }
 
@@ -692,7 +692,7 @@ static int make_trunk(unsigned short callno, int locked)
        }
        gettimeofday(&now, NULL);
        for (x=TRUNK_CALL_START;x<IAX_MAX_CALLS - 1; x++) {
-               ast_pthread_mutex_lock(&iaxsl[x]);
+               ast_mutex_lock(&iaxsl[x]);
                if (!iaxs[x] && ((now.tv_sec - lastused[x].tv_sec) > MIN_REUSE_TIME)) {
                        iaxs[x] = iaxs[callno];
                        iaxs[x]->callno = x;
@@ -705,13 +705,13 @@ static int make_trunk(unsigned short callno, int locked)
                        iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)x);
                        iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)x);
                        if (locked)
-                               ast_pthread_mutex_unlock(&iaxsl[callno]);
+                               ast_mutex_unlock(&iaxsl[callno]);
                        res = x;
                        if (!locked)
-                               ast_pthread_mutex_unlock(&iaxsl[x]);
+                               ast_mutex_unlock(&iaxsl[x]);
                        break;
                }
-               ast_pthread_mutex_unlock(&iaxsl[x]);
+               ast_mutex_unlock(&iaxsl[x]);
        }
        if (x >= IAX_MAX_CALLS - 1) {
                ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
@@ -732,33 +732,33 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
        if (new <= NEW_ALLOW) {
                /* Look for an existing connection first */
                for (x=1;(res < 1) && (x<maxnontrunkcall);x++) {
-                       ast_pthread_mutex_lock(&iaxsl[x]);
+                       ast_mutex_lock(&iaxsl[x]);
                        if (iaxs[x]) {
                                /* Look for an exact match */
                                if (match(sin, callno, dcallno, iaxs[x])) {
                                        res = x;
                                }
                        }
-                       ast_pthread_mutex_unlock(&iaxsl[x]);
+                       ast_mutex_unlock(&iaxsl[x]);
                }
                for (x=TRUNK_CALL_START;(res < 1) && (x<maxtrunkcall);x++) {
-                       ast_pthread_mutex_lock(&iaxsl[x]);
+                       ast_mutex_lock(&iaxsl[x]);
                        if (iaxs[x]) {
                                /* Look for an exact match */
                                if (match(sin, callno, dcallno, iaxs[x])) {
                                        res = x;
                                }
                        }
-                       ast_pthread_mutex_unlock(&iaxsl[x]);
+                       ast_mutex_unlock(&iaxsl[x]);
                }
        }
        if ((res < 1) && (new >= NEW_ALLOW)) {
                gettimeofday(&now, NULL);
                for (x=1;x<TRUNK_CALL_START;x++) {
                        /* Find first unused call number that hasn't been used in a while */
-                       ast_pthread_mutex_lock(&iaxsl[x]);
+                       ast_mutex_lock(&iaxsl[x]);
                        if (!iaxs[x] && ((now.tv_sec - lastused[x].tv_sec) > MIN_REUSE_TIME)) break;
-                       ast_pthread_mutex_unlock(&iaxsl[x]);
+                       ast_mutex_unlock(&iaxsl[x]);
                }
                /* We've still got lock held if we found a spot */
                if (x >= TRUNK_CALL_START) {
@@ -766,7 +766,7 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
                        return -1;
                }
                iaxs[x] = new_iax(sin, lockpeer);
-               ast_pthread_mutex_unlock(&iaxsl[x]);
+               ast_mutex_unlock(&iaxsl[x]);
                update_max_nontrunk();
                if (iaxs[x]) {
                        if (option_debug)
@@ -805,19 +805,19 @@ static int iax2_queue_frame(int callno, struct ast_frame *f)
        /* Assumes lock for callno is already held... */
        for (;;) {
                pass++;
-               if (!pthread_mutex_trylock(&iaxsl[callno])) {
+               if (!ast_mutex_trylock(&iaxsl[callno])) {
                        ast_log(LOG_WARNING, "Lock is not held on pass %d of iax2_queue_frame\n", pass);
                        CRASH;
                }
                if (iaxs[callno] && iaxs[callno]->owner) {
-                       if (pthread_mutex_trylock(&iaxs[callno]->owner->lock)) {
+                       if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
                                /* Avoid deadlock by pausing and trying again */
-                               ast_pthread_mutex_unlock(&iaxsl[callno]);
+                               ast_mutex_unlock(&iaxsl[callno]);
                                usleep(1);
-                               ast_pthread_mutex_lock(&iaxsl[callno]);
+                               ast_mutex_lock(&iaxsl[callno]);
                        } else {
                                ast_queue_frame(iaxs[callno]->owner, f, 0);
-                               ast_pthread_mutex_unlock(&iaxs[callno]->owner->lock);
+                               ast_mutex_unlock(&iaxs[callno]->owner->lock);
                                break;
                        }
                } else
@@ -864,9 +864,9 @@ static int do_deliver(void *data)
        struct iax_frame *fr = data;
        int callno = fr->callno;
        int res;
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        res = __do_deliver(data);
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return res;
 }
 
@@ -944,10 +944,10 @@ static int iax2_predestroy(int callno)
 {
        struct ast_channel *c;
        struct chan_iax2_pvt *pvt;
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        pvt = iaxs[callno];
        if (!pvt) {
-               ast_pthread_mutex_unlock(&iaxsl[callno]);
+               ast_mutex_unlock(&iaxsl[callno]);
                return -1;
        }
        if (!pvt->alreadygone) {
@@ -972,23 +972,23 @@ static int iax2_predestroy(int callno)
                c->pvt->pvt = NULL;
                ast_queue_hangup(c, 0);
                pvt->owner = NULL;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt--;
                if (usecnt < 0) 
                        ast_log(LOG_WARNING, "Usecnt < 0???\n");
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return 0;
 }
 
 static int iax2_predestroy_nolock(int callno)
 {
        int res;
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        res = iax2_predestroy(callno);
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        return res;
 }
 
@@ -999,7 +999,7 @@ static void iax2_destroy(int callno)
        struct ast_channel *owner;
 
 retry:
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        pvt = iaxs[callno];
        gettimeofday(&lastused[callno], NULL);
 
@@ -1008,9 +1008,9 @@ retry:
        else
                owner = NULL;
        if (owner) {
-               if (pthread_mutex_trylock(&owner->lock)) {
+               if (ast_mutex_trylock(&owner->lock)) {
                        ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
-                       ast_pthread_mutex_unlock(&iaxsl[callno]);
+                       ast_mutex_unlock(&iaxsl[callno]);
                        usleep(1);
                        goto retry;
                }
@@ -1053,18 +1053,18 @@ retry:
                free(pvt);
        }
        if (owner) {
-               ast_pthread_mutex_unlock(&owner->lock);
+               ast_mutex_unlock(&owner->lock);
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        if (callno & 0x4000)
                update_max_trunk();
 }
 static void iax2_destroy_nolock(int callno)
 {      
        /* Actually it's easier to unlock, kill it, and relock */
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        iax2_destroy(callno);
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
 }
 
 static int update_packet(struct iax_frame *f)
@@ -1088,7 +1088,7 @@ static int attempt_transmit(void *data)
        int callno = f->callno;
        /* Make sure this call is still active */
        if (callno) 
-               ast_pthread_mutex_lock(&iaxsl[callno]);
+               ast_mutex_lock(&iaxsl[callno]);
        if ((f->callno) && iaxs[f->callno]) {
                if ((f->retries < 0) /* Already ACK'd */ ||
                    (f->retries >= max_retries) /* Too many attempts */) {
@@ -1143,11 +1143,11 @@ static int attempt_transmit(void *data)
                freeme++;
        }
        if (callno)
-               ast_pthread_mutex_unlock(&iaxsl[callno]);
+               ast_mutex_unlock(&iaxsl[callno]);
        /* Do not try again */
        if (freeme) {
                /* Don't attempt delivery, just remove it from the queue */
-               ast_pthread_mutex_lock(&iaxq.lock);
+               ast_mutex_lock(&iaxq.lock);
                if (f->prev) 
                        f->prev->next = f->next;
                else
@@ -1157,7 +1157,7 @@ static int attempt_transmit(void *data)
                else
                        iaxq.tail = f->prev;
                iaxq.count--;
-               ast_pthread_mutex_unlock(&iaxq.lock);
+               ast_mutex_unlock(&iaxq.lock);
                f->retrans = -1;
                /* Free the IAX frame */
                iax2_frame_free(f);
@@ -1224,7 +1224,7 @@ static int iax2_show_cache(int fd, int argc, char *argv[])
        int x,y;
        struct timeval tv;
        gettimeofday(&tv, NULL);
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = dpcache;
        ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
        while(dp) {
@@ -1266,7 +1266,7 @@ static int iax2_show_cache(int fd, int argc, char *argv[])
                        ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->exten, "(expired)", y, tmp);
                dp = dp->next;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        return RESULT_SUCCESS;
 }
 
@@ -1449,7 +1449,7 @@ static int iax2_transmit(struct iax_frame *fr)
        /* By setting this to 0, the network thread will send it for us, and
           queue retransmission if necessary */
        fr->sentyet = 0;
-       ast_pthread_mutex_lock(&iaxq.lock);
+       ast_mutex_lock(&iaxq.lock);
        if (!iaxq.head) {
                /* Empty queue */
                iaxq.head = fr;
@@ -1461,7 +1461,7 @@ static int iax2_transmit(struct iax_frame *fr)
                iaxq.tail = fr;
        }
        iaxq.count++;
-       ast_pthread_mutex_unlock(&iaxq.lock);
+       ast_mutex_unlock(&iaxq.lock);
        /* Wake up the network thread */
        pthread_kill(netthreadid, SIGURG);
        return 0;
@@ -1510,7 +1510,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
        if (trunk)
                *trunk = 0;
        sin->sin_family = AF_INET;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        p = peerl.peers;
        while(p) {
                if (!strcasecmp(p->name, peer)) {
@@ -1543,7 +1543,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (!p && !found) {
                hp = gethostbyname(peer);
                if (hp) {
@@ -1564,13 +1564,13 @@ static int auto_congest(void *nothing)
 {
        int callno = (int)(long)(nothing);
        struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_CONGESTION };
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno]) {
                iaxs[callno]->initid = -1;
                iax2_queue_frame(callno, &f);
                ast_log(LOG_NOTICE, "Auto-congesting call due to slow response\n");
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return 0;
 }
 
@@ -1718,7 +1718,7 @@ static int iax2_hangup(struct ast_channel *c)
        int callno;
        if (pvt) {
                callno = pvt->callno;
-               ast_pthread_mutex_lock(&iaxsl[callno]);
+               ast_mutex_lock(&iaxsl[callno]);
                ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
                alreadygone = pvt->alreadygone;
                /* Send the hangup unless we have had a transmission error or are already gone */
@@ -1731,7 +1731,7 @@ static int iax2_hangup(struct ast_channel *c)
                        ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
                        iax2_destroy_nolock(callno);
                }
-               ast_pthread_mutex_unlock(&iaxsl[callno]);
+               ast_mutex_unlock(&iaxsl[callno]);
        }
        if (option_verbose > 2) 
                ast_verbose(VERBOSE_PREFIX_3 "Hungup '%s'\n", c->name);
@@ -1965,7 +1965,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
 {
        struct iax2_peer *peer;
        int res = 0;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
@@ -1975,7 +1975,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
                }
                peer = peer->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return res;
 }
 
@@ -2027,9 +2027,9 @@ static struct ast_channel *ast_iax2_new(struct chan_iax2_pvt *i, int state, int
                i->owner = tmp;
                i->capability = capability;
                ast_setstate(tmp, state);
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -2309,14 +2309,14 @@ static int iax2_show_users(int fd, int argc, char *argv[])
        struct iax2_user *user;
        if (argc != 3) 
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        ast_cli(fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C");
        for(user=userl.users;user;user=user->next) {
                ast_cli(fd, FORMAT2, user->name, user->secret, user->authmethods, 
                                user->contexts ? user->contexts->context : context,
                                user->ha ? "Yes" : "No");
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -2337,7 +2337,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
                } else
                        return RESULT_SHOWUSAGE;
        }
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "Status");
        for (peer = peerl.peers;peer;peer = peer->next) {
                char nm[20];
@@ -2366,7 +2366,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
                                        nm,
                                        ntohs(peer->addr.sin_port), peer->trunk ? "(T)" : "   ", status);
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -2413,7 +2413,7 @@ static int iax2_show_registry(int fd, int argc, char *argv[])
        char perceived[80];
        if (argc != 3)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        ast_cli(fd, FORMAT2, "Host", "Username", "Perceived", "Refresh", "State");
        for (reg = registrations;reg;reg = reg->next) {
                snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
@@ -2424,7 +2424,7 @@ static int iax2_show_registry(int fd, int argc, char *argv[])
                ast_cli(fd, FORMAT, host, 
                                        reg->username, perceived, reg->refresh, regstate2str(reg->regstate));
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -2440,7 +2440,7 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
                return RESULT_SHOWUSAGE;
        ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
        for (x=0;x<IAX_MAX_CALLS;x++) {
-               ast_pthread_mutex_lock(&iaxsl[x]);
+               ast_mutex_lock(&iaxsl[x]);
                if (iaxs[x]) {
                        ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr), 
                                                strlen(iaxs[x]->username) ? iaxs[x]->username : "(None)", 
@@ -2451,7 +2451,7 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
                                                iaxs[x]->voiceformat);
                        numchans++;
                }
-               ast_pthread_mutex_unlock(&iaxsl[x]);
+               ast_mutex_unlock(&iaxsl[x]);
        }
        ast_cli(fd, "%d active IAX channel(s)\n", numchans);
        return RESULT_SUCCESS;
@@ -2654,7 +2654,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
                        inet_ntoa(sin->sin_addr), version);
                return res;
        }
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        /* Search the userlist for a compatible entry, and fill in the rest */
        user = userl.users;
        while(user) {
@@ -2699,7 +2699,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
                }
                user = user->next;      
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        iaxs[callno]->trunk = iax2_getpeertrunk(*sin);
        return res;
 }
@@ -2970,7 +2970,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin,
                /* Normal password authentication */
                res = authenticate(p->challenge, override, okey, authmethods, &ied, sin);
        } else {
-               ast_pthread_mutex_lock(&peerl.lock);
+               ast_mutex_lock(&peerl.lock);
                peer = peerl.peers;
                while(peer) {
                        if ((!strlen(p->peer) || !strcmp(p->peer, peer->name)) 
@@ -2986,7 +2986,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin,
                        }
                        peer = peer->next;
                }
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
        }
        if (!res)
                res = send_command(p, AST_FRAME_IAX, IAX_COMMAND_AUTHREP, 0, ied.buf, ied.pos, -1);
@@ -3058,7 +3058,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
                expirey = ies->refresh;
        if (ies->dpstatus & IAX_DPSTATUS_MATCHMORE)
                matchmore = CACHE_FLAG_MATCHMORE;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        prev = NULL;
        dp = pvt->dpentries;
        while(dp) {
@@ -3084,7 +3084,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
                prev = dp;
                dp = dp->peer;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        return 0;
 }
 
@@ -3123,7 +3123,7 @@ static int complete_transfer(int callno, struct iax_ies *ies)
        pvt->last = 0;
        pvt->lastsent = 0;
        pvt->pingtime = DEFAULT_RETRY_TIME;
-       ast_pthread_mutex_lock(&iaxq.lock);
+       ast_mutex_lock(&iaxq.lock);
        for (cur = iaxq.head; cur ; cur = cur->next) {
                /* We must cancel any packets that would have been transmitted
                   because now we're talking to someone new.  It's okay, they
@@ -3131,7 +3131,7 @@ static int complete_transfer(int callno, struct iax_ies *ies)
                if (callno == cur->callno) 
                        cur->retries = -1;
        }
-       ast_pthread_mutex_unlock(&iaxq.lock);
+       ast_mutex_unlock(&iaxq.lock);
        return 0; 
 }
 
@@ -3395,14 +3395,14 @@ static int auto_hangup(void *nothing)
        /* Called from IAX thread only, without iaxs lock */
        int callno = (int)(long)(nothing);
        struct iax_ie_data ied;
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno]) {
                iaxs[callno]->autoid = -1;
                memset(&ied, 0, sizeof(ied));
                iax_ie_append_str(&ied, IAX_IE_CAUSE, "Timeout");
                send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
        }
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return 0;
 }
 
@@ -3427,7 +3427,7 @@ static int iax2_vnak(int callno)
 static void vnak_retransmit(int callno, int last)
 {
        struct iax_frame *f;
-       ast_pthread_mutex_lock(&iaxq.lock);
+       ast_mutex_lock(&iaxq.lock);
        f = iaxq.head;
        while(f) {
                /* Send a copy immediately */
@@ -3437,7 +3437,7 @@ static void vnak_retransmit(int callno, int last)
                }
                f = f->next;
        }
-       ast_pthread_mutex_unlock(&iaxq.lock);
+       ast_mutex_unlock(&iaxq.lock);
 }
 
 static int iax2_poke_peer_s(void *data)
@@ -3472,7 +3472,7 @@ static int send_trunk(struct iax2_peer *peer)
        
        /* Search through trunked calls for a match with this peer */
        for (x=TRUNK_CALL_START;x<maxtrunkcall; x++) {
-               ast_pthread_mutex_lock(&iaxsl[x]);
+               ast_mutex_lock(&iaxsl[x]);
 #if 0
                if (iaxtrunkdebug)
                        ast_verbose("Call %d is at %s:%d (%d)\n", x, inet_ntoa(iaxs[x]->addr.sin_addr), ntohs(iaxs[x]->addr.sin_port), iaxs[x]->addr.sin_family);
@@ -3500,7 +3500,7 @@ static int send_trunk(struct iax2_peer *peer)
                        if (!firstcall)
                                firstcall = x;
                }
-               ast_pthread_mutex_unlock(&iaxsl[x]);
+               ast_mutex_unlock(&iaxsl[x]);
        }
        if (calls) {
                /* We're actually sending a frame, so fill the meta trunk header and meta header */
@@ -3548,12 +3548,12 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
                res = read(fd, buf, sizeof(buf));
                if (res < 1) {
                        ast_log(LOG_WARNING, "Unable to read from timing fd\n");
-                       ast_pthread_mutex_unlock(&peerl.lock);
+                       ast_mutex_unlock(&peerl.lock);
                        return 1;
                }
        }
        /* For each peer that supports trunking... */
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if (peer->trunk) {
@@ -3566,7 +3566,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
                }
                peer = peer->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (iaxtrunkdebug)
                ast_verbose("Ending trunk processing with %d peers and %d calls processed\n", processed, totalcalls);
        iaxtrunkdebug =0;
@@ -3634,14 +3634,14 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                        ts = ntohl(mth->ts);
                        res -= (sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr));
                        ptr = mth->data;
-                       ast_pthread_mutex_lock(&peerl.lock);
+                       ast_mutex_lock(&peerl.lock);
                        peer = peerl.peers;
                        while(peer) {
                                if (!inaddrcmp(&peer->addr, &sin))
                                        break;
                                peer = peer->next;
                        }
-                       ast_pthread_mutex_unlock(&peerl.lock);
+                       ast_mutex_unlock(&peerl.lock);
                        if (!peer) {
                                ast_log(LOG_WARNING, "Unable to accept trunked packet from '%s:%d': No matching peer\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
                                return 1;
@@ -3660,7 +3660,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        break;
                                fr.callno = find_callno(ntohs(mte->callno) & ~IAX_FLAG_FULL, 0, &sin, NEW_PREVENT, 1);
                                if (fr.callno) {
-                                       ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+                                       ast_mutex_lock(&iaxsl[fr.callno]);
                                        /* If it's a valid call, deliver the contents.  If not, we
                                           drop it, since we don't have a scallno to use for an INVAL */
                                        /* Process as a mini frame */
@@ -3703,7 +3703,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                                ast_log(LOG_WARNING, "Received trunked frame before first full voice frame\n ");
                                                iax2_vnak(fr.callno);
                                        }
-                                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                                       ast_mutex_unlock(&iaxsl[fr.callno]);
                                }
                                ptr += len;
                                res -= len;
@@ -3739,7 +3739,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                fr.callno = find_callno(ntohs(mh->callno) & ~IAX_FLAG_FULL, dcallno, &sin, new, 1);
 
        if (fr.callno > 0) 
-               ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+               ast_mutex_lock(&iaxsl[fr.callno]);
 
        if (!fr.callno || !iaxs[fr.callno]) {
                /* A call arrived for a non-existant destination.  Unless it's an "inval"
@@ -3754,7 +3754,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                );
                }
                if (fr.callno > 0) 
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                return 1;
        }
        if (!inaddrcmp(&sin, &iaxs[fr.callno]->addr) && !minivid)
@@ -3798,7 +3798,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        /* Send a VNAK requesting retransmission */
                                        iax2_vnak(fr.callno);
                                }
-                               ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                               ast_mutex_unlock(&iaxsl[fr.callno]);
                                return 1;
                        }
                } else {
@@ -3814,7 +3814,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                /* A full frame */
                if (res < sizeof(struct ast_iax2_full_hdr)) {
                        ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, sizeof(struct ast_iax2_full_hdr));
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                f.datalen = res - sizeof(struct ast_iax2_full_hdr);
@@ -3838,7 +3838,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        /* Ack the packet with the given timestamp */
                                        if (option_debug)
                                                ast_log(LOG_DEBUG, "Cancelling transmission of packet %d\n", x);
-                                       ast_pthread_mutex_lock(&iaxq.lock);
+                                       ast_mutex_lock(&iaxq.lock);
                                        for (cur = iaxq.head; cur ; cur = cur->next) {
                                                /* If it's our call, and our timestamp, mark -1 retries */
                                                if ((fr.callno == cur->callno) && (x == cur->oseqno)) {
@@ -3851,14 +3851,14 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                                        }
                                                }
                                        }
-                                       ast_pthread_mutex_unlock(&iaxq.lock);
+                                       ast_mutex_unlock(&iaxq.lock);
                                }
                                /* Note how much we've received acknowledgement for */
                                if (iaxs[fr.callno])
                                        iaxs[fr.callno]->rseqno = fr.iseqno;
                                else {
                                        /* Stop processing now */
-                                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                                       ast_mutex_unlock(&iaxsl[fr.callno]);
                                        return 1;
                                }
                        } else
@@ -3869,7 +3869,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                         ((f.subclass != IAX_COMMAND_TXACC) &&
                          (f.subclass != IAX_COMMAND_TXCNT)))) {
                        /* Only messages we accept from a transfer host are TXACC and TXCNT */
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
 
@@ -3877,7 +3877,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                        if (f.frametype == AST_FRAME_IAX) {
                                if (iax_parse_ies(&ies, buf + sizeof(struct ast_iax2_full_hdr), f.datalen)) {
                                        ast_log(LOG_WARNING, "undecodable frame received\n");
-                                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                                       ast_mutex_unlock(&iaxsl[fr.callno]);
                                        return 1;
                                }
                                f.data = NULL;
@@ -3897,10 +3897,10 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        if (iaxs[fr.callno]->owner) {
                                                int orignative;
 retryowner:
-                                               if (pthread_mutex_trylock(&iaxs[fr.callno]->owner->lock)) {
-                                                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                                               if (ast_mutex_trylock(&iaxs[fr.callno]->owner->lock)) {
+                                                       ast_mutex_unlock(&iaxsl[fr.callno]);
                                                        usleep(1);
-                                                       ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+                                                       ast_mutex_lock(&iaxsl[fr.callno]);
                                                        if (iaxs[fr.callno] && iaxs[fr.callno]->owner) goto retryowner;
                                                }
                                                if (iaxs[fr.callno]) {
@@ -3910,11 +3910,11 @@ retryowner:
                                                                if (iaxs[fr.callno]->owner->readformat)
                                                                        ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
                                                                iaxs[fr.callno]->owner->nativeformats = orignative;
-                                                               ast_pthread_mutex_unlock(&iaxs[fr.callno]->owner->lock);
+                                                               ast_mutex_unlock(&iaxs[fr.callno]->owner->lock);
                                                        }
                                                } else {
                                                        ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
-                                                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                                                       ast_mutex_unlock(&iaxsl[fr.callno]);
                                                        return 1;
                                                }
                                        }
@@ -3954,13 +3954,13 @@ retryowner:
                        case IAX_COMMAND_TXACC:
                                if (iaxs[fr.callno]->transferring == TRANSFER_BEGIN) {
                                        /* Ack the packet with the given timestamp */
-                                       ast_pthread_mutex_lock(&iaxq.lock);
+                                       ast_mutex_lock(&iaxq.lock);
                                        for (cur = iaxq.head; cur ; cur = cur->next) {
                                                /* Cancel any outstanding txcnt's */
                                                if ((fr.callno == cur->callno) && (cur->transfer))
                                                        cur->retries = -1;
                                        }
-                                       ast_pthread_mutex_unlock(&iaxq.lock);
+                                       ast_mutex_unlock(&iaxq.lock);
                                        memset(&ied1, 0, sizeof(ied1));
                                        iax_ie_append_short(&ied1, IAX_IE_CALLNO, iaxs[fr.callno]->callno);
                                        send_command(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_TXREADY, 0, ied1.buf, ied1.pos, -1);
@@ -4125,7 +4125,7 @@ retryowner:
                                                        ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);        
                                        }
                                }
-                               ast_pthread_mutex_lock(&dpcache_lock);
+                               ast_mutex_lock(&dpcache_lock);
                                dp = iaxs[fr.callno]->dpentries;
                                while(dp) {
                                        if (!(dp->flags & CACHE_FLAG_TRANSMITTED)) {
@@ -4133,7 +4133,7 @@ retryowner:
                                        }
                                        dp = dp->peer;
                                }
-                               ast_pthread_mutex_unlock(&dpcache_lock);
+                               ast_mutex_unlock(&dpcache_lock);
                                break;
                        case IAX_COMMAND_POKE:
                                /* Send back a pong packet with the original timestamp */
@@ -4430,7 +4430,7 @@ retryowner:
                                if (iaxs[fr.callno] && iaxs[fr.callno]->aseqno != iaxs[fr.callno]->iseqno)
                                        send_command_immediate(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr.ts, NULL, 0,fr.iseqno);
                        }
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                /* Unless this is an ACK or INVAL frame, ack it */
@@ -4443,7 +4443,7 @@ retryowner:
                else {
                        ast_log(LOG_WARNING, "Received mini frame before first full voice frame\n ");
                        iax2_vnak(fr.callno);
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                f.datalen = res - sizeof(struct ast_iax2_video_hdr);
@@ -4460,13 +4460,13 @@ retryowner:
                else {
                        ast_log(LOG_WARNING, "Received mini frame before first full voice frame\n ");
                        iax2_vnak(fr.callno);
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                f.datalen = res - sizeof(struct ast_iax2_mini_hdr);
                if (f.datalen < 0) {
                        ast_log(LOG_WARNING, "Datalen < 0?\n");
-                       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+                       ast_mutex_unlock(&iaxsl[fr.callno]);
                        return 1;
                }
                if (f.datalen)
@@ -4477,7 +4477,7 @@ retryowner:
        }
        /* Don't pass any packets until we're started */
        if (!(iaxs[fr.callno]->state & IAX_STATE_STARTED)) {
-               ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+               ast_mutex_unlock(&iaxsl[fr.callno]);
                return 1;
        }
        /* Common things */
@@ -4509,7 +4509,7 @@ retryowner:
        schedule_delivery(iaxfrdup2(&fr), 1, updatehistory);
 #endif
        /* Always run again */
-       ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+       ast_mutex_unlock(&iaxsl[fr.callno]);
        return 1;
 }
 
@@ -4632,7 +4632,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data)
                ast_log(LOG_WARNING, "Unable to create call\n");
                return NULL;
        }
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        /* If this is a trunk, update it now */
        iaxs[callno]->trunk = trunk;
        if (trunk) 
@@ -4642,7 +4642,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data)
        iaxs[callno]->maxtime = maxtime;
        iaxs[callno]->notransfer = notransfer;
        c = ast_iax2_new(iaxs[callno], AST_STATE_DOWN, capability);
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        if (c) {
                /* Choose a format we can live with */
                if (c->nativeformats & format)
@@ -4675,7 +4675,7 @@ static void *network_thread(void *ignore)
        for(;;) {
                /* Go through the queue, sending messages which have not yet been
                   sent, and scheduling retransmissions if appropriate */
-               ast_pthread_mutex_lock(&iaxq.lock);
+               ast_mutex_lock(&iaxq.lock);
                f = iaxq.head;
                while(f) {
                        freeme = NULL;
@@ -4708,7 +4708,7 @@ static void *network_thread(void *ignore)
                        if (freeme)
                                iax_frame_free(freeme);
                }
-               ast_pthread_mutex_unlock(&iaxq.lock);
+               ast_mutex_unlock(&iaxq.lock);
                res = ast_sched_wait(sched);
                if ((res > 1000) || (res < 0))
                        res = 1000;
@@ -4755,7 +4755,7 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
        int format;
        int found=0;
        prev = NULL;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if (!strcasecmp(peer->name, name)) {    
@@ -4772,9 +4772,9 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
                } else {
                        peerl.peers = peer->next;
                }
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
        } else {
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
                peer = malloc(sizeof(struct iax2_peer));
                memset(peer, 0, sizeof(struct iax2_peer));
                peer->expire = -1;
@@ -4967,7 +4967,7 @@ static void delete_users(void){
        struct iax2_registry *reg, *regl;
 
        /* Delete all users */
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        for (user=userl.users;user;) {
                ast_free_ha(user->ha);
                free_context(user->contexts);
@@ -4976,7 +4976,7 @@ static void delete_users(void){
                free(userlast);
        }
        userl.users=NULL;
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
 
        for (reg = registrations;reg;) {
                regl = reg;
@@ -4986,30 +4986,30 @@ static void delete_users(void){
                free(regl);
        }
        registrations = NULL;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        for (peer=peerl.peers;peer;) {
                /* Assume all will be deleted, and we'll find out for sure later */
                peer->delme = 1;
                peer = peer->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
 }
 
 static void prune_peers(void){
        /* Prune peers who still are supposed to be deleted */
        struct iax2_peer *peer, *peerlast, *peernext;
        int x;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peerlast = NULL;
        for (peer=peerl.peers;peer;) {
                peernext = peer->next;
                if (peer->delme) {
                        for (x=0;x<IAX_MAX_CALLS;x++) {
-                               ast_pthread_mutex_lock(&iaxsl[x]);
+                               ast_mutex_lock(&iaxsl[x]);
                                if (iaxs[x] && (iaxs[x]->peerpoke == peer)) {
                                        iax2_destroy(x);
                                }
-                               ast_pthread_mutex_unlock(&iaxsl[x]);
+                               ast_mutex_unlock(&iaxsl[x]);
                        }
                        /* Delete it, it needs to disappear */
                        if (peer->expire > -1)
@@ -5027,7 +5027,7 @@ static void prune_peers(void){
                        peerlast = peer;
                peer=peernext;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
 }
 
 static void set_timing(void)
@@ -5157,19 +5157,19 @@ static int set_config(char *config_file, struct sockaddr_in* sin){
                                if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
                                        user = build_user(cat, ast_variable_browse(cfg, cat));
                                        if (user) {
-                                               ast_pthread_mutex_lock(&userl.lock);
+                                               ast_mutex_lock(&userl.lock);
                                                user->next = userl.users;
                                                userl.users = user;
-                                               ast_pthread_mutex_unlock(&userl.lock);
+                                               ast_mutex_unlock(&userl.lock);
                                        }
                                }
                                if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
                                        peer = build_peer(cat, ast_variable_browse(cfg, cat));
                                        if (peer) {
-                                               ast_pthread_mutex_lock(&peerl.lock);
+                                               ast_mutex_lock(&peerl.lock);
                                                peer->next = peerl.peers;
                                                peerl.peers = peer;
-                                               ast_pthread_mutex_unlock(&peerl.lock);
+                                               ast_mutex_unlock(&peerl.lock);
                                        }
                                } else if (strcasecmp(utype, "user")) {
                                        ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
@@ -5220,12 +5220,12 @@ static int cache_get_callno(char *data)
        for (x=0;x<IAX_MAX_CALLS; x++) {
                /* Look for an *exact match* call.  Once a call is negotiated, it can only
                   look up entries for a single context */
-               if (!pthread_mutex_trylock(&iaxsl[x])) {
+               if (!ast_mutex_trylock(&iaxsl[x])) {
                        if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) {
-                               ast_pthread_mutex_unlock(&iaxsl[x]);
+                               ast_mutex_unlock(&iaxsl[x]);
                                return x;
                        }
-                       ast_pthread_mutex_unlock(&iaxsl[x]);
+                       ast_mutex_unlock(&iaxsl[x]);
                }
        }
        memset(&ied, 0, sizeof(ied));
@@ -5264,7 +5264,7 @@ static int cache_get_callno(char *data)
                ast_log(LOG_WARNING, "Unable to create call\n");
                return -1;
        }
-       ast_pthread_mutex_lock(&iaxsl[callno]);
+       ast_mutex_lock(&iaxsl[callno]);
        strncpy(iaxs[callno]->dproot, data, sizeof(iaxs[callno]->dproot)-1);
        iaxs[callno]->capability = IAX_CAPABILITY_FULLBANDWIDTH;
 
@@ -5286,7 +5286,7 @@ static int cache_get_callno(char *data)
 #endif         
        /* Start the call going */
        send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_NEW, 0, ied.buf, ied.pos, -1);
-       ast_pthread_mutex_unlock(&iaxsl[callno]);
+       ast_mutex_unlock(&iaxsl[callno]);
        return callno;
 }
 
@@ -5380,7 +5380,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, char *data, cha
                /* Okay, now we wait */
                timeout = iaxdefaulttimeout * 1000;
                /* Temporarily unlock */
-               ast_pthread_mutex_unlock(&dpcache_lock);
+               ast_mutex_unlock(&dpcache_lock);
                /* Defer any dtmf */
                if (chan)
                        old = ast_channel_defer_dtmf(chan);
@@ -5404,7 +5404,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, char *data, cha
                if (!timeout) {
                        ast_log(LOG_WARNING, "Timeout waiting for %s exten %s\n", data, exten);
                }
-               ast_pthread_mutex_lock(&dpcache_lock);
+               ast_mutex_lock(&dpcache_lock);
                dp->waiters[x] = -1;
                close(com[1]);
                close(com[0]);
@@ -5446,13 +5446,13 @@ static int iax2_exists(struct ast_channel *chan, char *context, char *exten, int
 #endif
        if (priority != 1)
                return 0;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_EXISTS)
                        res= 1;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        if (!dp) {
                ast_log(LOG_WARNING, "Unable to make DP cache\n");
        }
@@ -5468,13 +5468,13 @@ static int iax2_canmatch(struct ast_channel *chan, char *context, char *exten, i
 #endif
        if (priority != 1)
                return 0;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_CANEXIST)
                        res= 1;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        if (!dp) {
                ast_log(LOG_WARNING, "Unable to make DP cache\n");
        }
@@ -5490,13 +5490,13 @@ static int iax2_matchmore(struct ast_channel *chan, char *context, char *exten,
 #endif
        if (priority != 1)
                return 0;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_MATCHMORE)
                        res= 1;
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        if (!dp) {
                ast_log(LOG_WARNING, "Unable to make DP cache\n");
        }
@@ -5515,7 +5515,7 @@ static int iax2_exec(struct ast_channel *chan, char *context, char *exten, int p
 #endif
        if (priority != 1)
                return -1;
-       ast_pthread_mutex_lock(&dpcache_lock);
+       ast_mutex_lock(&dpcache_lock);
        dp = find_cache(chan, data, context, exten, priority);
        if (dp) {
                if (dp->flags & CACHE_FLAG_EXISTS) {
@@ -5531,12 +5531,12 @@ static int iax2_exec(struct ast_channel *chan, char *context, char *exten, int p
                        if (option_verbose > 2)
                                ast_verbose(VERBOSE_PREFIX_3 "Executing Dial('%s')\n", req);
                } else {
-                       ast_pthread_mutex_unlock(&dpcache_lock);
+                       ast_mutex_unlock(&dpcache_lock);
                        ast_log(LOG_WARNING, "Can't execute non-existant extension '%s[@%s]' in data '%s'\n", exten, context, data);
                        return -1;
                }
        }
-       ast_pthread_mutex_unlock(&dpcache_lock);
+       ast_mutex_unlock(&dpcache_lock);
        dial = pbx_findapp("Dial");
        if (dial) {
                pbx_exec(chan, dial, req, newstack);
@@ -5587,7 +5587,7 @@ int load_module(void)
 #endif         
 
        for (x=0;x<IAX_MAX_CALLS;x++)
-               ast_pthread_mutex_init(&iaxsl[x]);
+               ast_mutex_init(&iaxsl[x]);
        
        io = io_context_create();
        sched = sched_context_create();
@@ -5597,9 +5597,9 @@ int load_module(void)
                return -1;
        }
 
-       ast_pthread_mutex_init(&iaxq.lock);
-       ast_pthread_mutex_init(&userl.lock);
-       ast_pthread_mutex_init(&peerl.lock);
+       ast_mutex_init(&iaxq.lock);
+       ast_mutex_init(&userl.lock);
+       ast_mutex_init(&peerl.lock);
 
        ast_cli_register(&cli_show_users);
        ast_cli_register(&cli_show_channels);
@@ -5653,10 +5653,10 @@ int load_module(void)
        }
        for (reg = registrations; reg; reg = reg->next)
                iax2_do_register(reg);
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        for (peer = peerl.peers; peer; peer = peer->next)
                iax2_poke_peer(peer);
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return res;
 }
 
@@ -5690,9 +5690,9 @@ int unload_module()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 662cf7c..7889d0f 100755 (executable)
@@ -49,15 +49,15 @@ static char *tdesc = "Local Proxy Channel Driver";
 static int capability = -1;
 
 static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 #define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
 
 /* Protect the interface list (of sip_pvt's) */
-static pthread_mutex_t locallock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t locallock = AST_MUTEX_INITIALIZER;
 
 static struct local_pvt {
-       pthread_mutex_t lock;                           /* Channel private lock */
+       ast_mutex_t lock;                               /* Channel private lock */
        char context[AST_MAX_EXTENSION];        /* Context to call */
        char exten[AST_MAX_EXTENSION];          /* Extension to call */
        int reqformat;                                          /* Requested format */
@@ -84,25 +84,25 @@ retrylock:
        if (p->cancelqueue) {
                /* We had a glare on the hangup.  Forget all this business,
                return and destroy p.  */
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                free(p);
                return -1;
        }
-       if (pthread_mutex_trylock(&other->lock)) {
+       if (ast_mutex_trylock(&other->lock)) {
                /* Failed to lock.  Release main lock and try again */
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                if (us)
-                       ast_pthread_mutex_unlock(&us->lock);
+                       ast_mutex_unlock(&us->lock);
                /* Wait just a bit */
                usleep(1);
                /* Only we can destroy ourselves, so we can't disappear here */
                if (us)
-                       ast_pthread_mutex_lock(&us->lock);
-               ast_pthread_mutex_lock(&p->lock);
+                       ast_mutex_lock(&us->lock);
+               ast_mutex_lock(&p->lock);
                goto retrylock;
        }
        ast_queue_frame(other, f, 0);
-       ast_pthread_mutex_unlock(&other->lock);
+       ast_mutex_unlock(&other->lock);
        p->glaredetect = 0;
        return 0;
 }
@@ -112,14 +112,14 @@ static int local_answer(struct ast_channel *ast)
        struct local_pvt *p = ast->pvt->pvt;
        int isoutbound = IS_OUTBOUND(ast, p);
        int res = -1;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (isoutbound) {
                /* Pass along answer since somebody answered us */
                struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
                res = local_queue_frame(p, isoutbound, &answer, ast);
        } else
                ast_log(LOG_WARNING, "Huh?  Local is being asked to answer?\n");
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -130,19 +130,19 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
        if (isoutbound && p->chan && p->chan->bridge && p->owner) {
                /* Masquerade bridged channel into owner */
                /* Lock other side first */
-               ast_pthread_mutex_lock(&p->chan->bridge->lock);
-               ast_pthread_mutex_lock(&p->owner->lock);
+               ast_mutex_lock(&p->chan->bridge->lock);
+               ast_mutex_lock(&p->owner->lock);
                ast_channel_masquerade(p->owner, p->chan->bridge);
-               ast_pthread_mutex_unlock(&p->owner->lock);
-               ast_pthread_mutex_unlock(&p->chan->bridge->lock);
+               ast_mutex_unlock(&p->owner->lock);
+               ast_mutex_unlock(&p->chan->bridge->lock);
                p->alreadymasqed = 1;
        } else if (!isoutbound && p->owner && p->owner->bridge && p->chan) {
                /* Masquerade bridged channel into chan */
-               ast_pthread_mutex_lock(&p->owner->bridge->lock);
-               ast_pthread_mutex_lock(&p->chan->lock);
+               ast_mutex_lock(&p->owner->bridge->lock);
+               ast_mutex_lock(&p->chan->lock);
                ast_channel_masquerade(p->chan, p->owner->bridge);
-               ast_pthread_mutex_unlock(&p->chan->lock);
-               ast_pthread_mutex_unlock(&p->owner->bridge->lock);
+               ast_mutex_unlock(&p->chan->lock);
+               ast_mutex_unlock(&p->owner->bridge->lock);
                p->alreadymasqed = 1;
        }
 }
@@ -161,27 +161,27 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
 
 
        /* Just queue for delivery to the other side */
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        res = local_queue_frame(p, isoutbound, f, ast);
        check_bridge(p, isoutbound);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
 static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
        struct local_pvt *p = newchan->pvt->pvt;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if ((p->owner != oldchan) && (p->chan != oldchan)) {
                ast_log(LOG_WARNING, "old channel wasn't %p but was %p/%p\n", oldchan, p->owner, p->chan);
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return -1;
        }
        if (p->owner == oldchan)
                p->owner = newchan;
        else
                p->chan = newchan;      
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return 0;
 }
 
@@ -192,10 +192,10 @@ static int local_indicate(struct ast_channel *ast, int condition)
        struct ast_frame f = { AST_FRAME_CONTROL, };
        int isoutbound = IS_OUTBOUND(ast, p);
        /* Queue up a frame representing the indication as a control frame */
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        f.subclass = condition;
        res = local_queue_frame(p, isoutbound, &f, ast);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -205,10 +205,10 @@ static int local_digit(struct ast_channel *ast, char digit)
        int res = -1;
        struct ast_frame f = { AST_FRAME_DTMF, };
        int isoutbound = IS_OUTBOUND(ast, p);
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        f.subclass = digit;
        res = local_queue_frame(p, isoutbound, &f, ast);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -231,7 +231,7 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout)
 static void local_destroy(struct local_pvt *p)
 {
        struct local_pvt *cur, *prev = NULL;
-       ast_pthread_mutex_lock(&locallock);
+       ast_mutex_lock(&locallock);
        cur = locals;
        while(cur) {
                if (cur == p) {
@@ -245,7 +245,7 @@ static void local_destroy(struct local_pvt *p)
                prev = cur;
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&locallock);
+       ast_mutex_unlock(&locallock);
        if (!cur)
                ast_log(LOG_WARNING, "Unable ot find local '%s@%s' in local list\n", p->exten, p->context);
 }
@@ -258,7 +258,7 @@ static int local_hangup(struct ast_channel *ast)
        struct local_pvt *cur, *prev=NULL;
        struct ast_channel *ochan = NULL;
        int glaredetect;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (isoutbound)
                p->chan = NULL;
        else
@@ -272,9 +272,9 @@ static int local_hangup(struct ast_channel *ast)
                   let local_queue do it. */
                if (p->glaredetect)
                        p->cancelqueue = 1;
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                /* Remove from list */
-               ast_pthread_mutex_lock(&locallock);
+               ast_mutex_lock(&locallock);
                cur = locals;
                while(cur) {
                        if (cur == p) {
@@ -287,7 +287,7 @@ static int local_hangup(struct ast_channel *ast)
                        prev = cur;
                        cur = cur->next;
                }
-               ast_pthread_mutex_unlock(&locallock);
+               ast_mutex_unlock(&locallock);
                /* And destroy */
                if (!glaredetect)
                        free(p);
@@ -298,7 +298,7 @@ static int local_hangup(struct ast_channel *ast)
                ochan = p->chan;
        else
                local_queue_frame(p, isoutbound, &f, NULL);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        if (ochan)
                ast_hangup(ochan);
        return 0;
@@ -311,7 +311,7 @@ static struct local_pvt *local_alloc(char *data, int format)
        tmp = malloc(sizeof(struct local_pvt));
        if (tmp) {
                memset(tmp, 0, sizeof(struct local_pvt));
-               ast_pthread_mutex_init(&tmp->lock);
+               ast_mutex_init(&tmp->lock);
                strncpy(tmp->exten, data, sizeof(tmp->exten) - 1);
                c = strchr(tmp->exten, '@');
                if (c) {
@@ -327,10 +327,10 @@ static struct local_pvt *local_alloc(char *data, int format)
                        tmp = NULL;
                } else {
                        /* Add to list */
-                       ast_pthread_mutex_lock(&locallock);
+                       ast_mutex_lock(&locallock);
                        tmp->next = locals;
                        locals = tmp;
-                       ast_pthread_mutex_unlock(&locallock);
+                       ast_mutex_unlock(&locallock);
                }
                
        }
@@ -389,9 +389,9 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
                tmp2->pvt->fixup = local_fixup;
                p->owner = tmp;
                p->chan = tmp2;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
                strncpy(tmp2->context, p->context, sizeof(tmp2->context)-1);
@@ -420,17 +420,17 @@ static int locals_show(int fd, int argc, char **argv)
 
        if (argc != 2)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&locallock);
+       ast_mutex_lock(&locallock);
        p = locals;
        while(p) {
-               ast_pthread_mutex_lock(&p->lock);
+               ast_mutex_lock(&p->lock);
                ast_cli(fd, "%s -- %s@%s\n", p->owner ? p->owner->name : "<unowned>", p->exten, p->context);
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                p = p->next;
        }
        if (!locals)
                ast_cli(fd, "No local channels in use\n");
-       ast_pthread_mutex_unlock(&locallock);
+       ast_mutex_unlock(&locallock);
        return RESULT_SUCCESS;
 }
 
@@ -464,7 +464,7 @@ int unload_module()
        /* First, take us out of the channel loop */
        ast_cli_unregister(&cli_show_locals);
        ast_channel_unregister(type);
-       if (!ast_pthread_mutex_lock(&locallock)) {
+       if (!ast_mutex_lock(&locallock)) {
                /* Hangup all interfaces if they have an owner */
                p = locals;
                while(p) {
@@ -473,7 +473,7 @@ int unload_module()
                        p = p->next;
                }
                locals = NULL;
-               ast_pthread_mutex_unlock(&locallock);
+               ast_mutex_unlock(&locallock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
@@ -484,9 +484,9 @@ int unload_module()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 691483e..19045e8 100755 (executable)
@@ -142,7 +142,7 @@ static int adsi = 0;
 
 
 static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 static int oseq;
 
 /* Wait up to 16 seconds for first digit (FXO logic) */
@@ -156,9 +156,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 pthread_mutex_t netlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
 
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
 
 /* This is the thread for the monitor which checks for input on the channels
    which are not currently in use.  */
@@ -219,7 +219,7 @@ struct mgcp_message {
 #define SUB_ALT  1
 
 struct mgcp_subchannel {
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
     int id;
     struct ast_channel *owner;
     struct mgcp_endpoint *parent;
@@ -247,7 +247,7 @@ struct mgcp_subchannel {
 #define TYPE_LINE              2
 
 struct mgcp_endpoint {
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
        char name[80];
     struct mgcp_subchannel *sub;        /* pointer to our current connection, channel and stuff */
        char accountcode[80];
@@ -307,7 +307,7 @@ static struct mgcp_gateway {
        struct mgcp_gateway *next;
 } *gateways;
 
-static pthread_mutex_t gatelock  = AST_MUTEX_INITIALIZER;
+static ast_mutex_t gatelock  = AST_MUTEX_INITIALIZER;
 
 static int mgcpsock  = -1;
 
@@ -526,7 +526,7 @@ static int mgcp_hangup(struct ast_channel *ast)
        if ((p->dtmfinband) && (p->dsp != NULL)){
            ast_dsp_free(p->dsp);
        }
-       ast_pthread_mutex_lock(&sub->lock);
+       ast_mutex_lock(&sub->lock);
 
        sub->owner = NULL;
        if (strlen(sub->cxident)) {
@@ -581,7 +581,7 @@ static int mgcp_hangup(struct ast_channel *ast)
             transmit_notify_request(sub, "vmwi(-)");
         }
     }
-       ast_pthread_mutex_unlock(&sub->lock);
+       ast_mutex_unlock(&sub->lock);
        return 0;
 }
 
@@ -592,7 +592,7 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
        int hasendpoints = 0;
        if (argc != 3) 
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&gatelock);
+       ast_mutex_lock(&gatelock);
        g = gateways;
        while(g) {
                e = g->endpoints;
@@ -607,7 +607,7 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
                }
                g = g->next;
        }
-       ast_pthread_mutex_unlock(&gatelock);
+       ast_mutex_unlock(&gatelock);
        return RESULT_SUCCESS;
 }
 
@@ -644,7 +644,7 @@ static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
                gname++;
        if ((c = strrchr(gname, ']')))
                *c = '\0';
-       ast_pthread_mutex_lock(&gatelock);
+       ast_mutex_lock(&gatelock);
        g = gateways;
        while(g) {
         if (!strcasecmp(g->name, gname)) {
@@ -666,7 +666,7 @@ static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
     if (!found) {
         ast_cli(fd, "   << Could not find endpoint >>     ");
     }
-       ast_pthread_mutex_unlock(&gatelock);
+       ast_mutex_unlock(&gatelock);
        return RESULT_SUCCESS;
 }
 
@@ -731,9 +731,9 @@ static struct ast_frame  *mgcp_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
        struct mgcp_subchannel *sub = ast->pvt->pvt;
-       ast_pthread_mutex_lock(&sub->lock);
+       ast_mutex_lock(&sub->lock);
        fr = mgcp_rtp_read(sub);
-       ast_pthread_mutex_unlock(&sub->lock);
+       ast_mutex_unlock(&sub->lock);
        return fr;
 }
 
@@ -756,11 +756,11 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
                }
        }
        if (sub) {
-               ast_pthread_mutex_lock(&sub->lock);
+               ast_mutex_lock(&sub->lock);
                if (sub->rtp) {
                        res =  ast_rtp_write(sub->rtp, frame);
                }
-               ast_pthread_mutex_unlock(&sub->lock);
+               ast_mutex_unlock(&sub->lock);
        }
        return res;
 }
@@ -892,9 +892,9 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
                if (i->amaflags)
                        tmp->amaflags = i->amaflags;
                sub->owner = tmp;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                tmp->callgroup = i->callgroup;
                tmp->pickupgroup = i->pickupgroup;
@@ -987,13 +987,13 @@ static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
 {
        /* Just deliver the audio directly */
        struct mgcp_endpoint *p = data;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        if (p->owner) {
                /* Generally, you lock in the order channel lock, followed by private
                   lock.  Since here we are doing the reverse, there is the possibility
                   of deadlock.  As a result, in the case of a deadlock, we simply fail out
                   here. */
-               if (!pthread_mutex_trylock(&p->owner->lock)) {
+               if (!ast_mutex_trylock(&p->owner->lock)) {
                        if (f->frametype == AST_FRAME_VOICE) {
                                if (f->subclass != p->owner->nativeformats) {
                                        ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
@@ -1006,10 +1006,10 @@ static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
                                }
                        }
                        ast_queue_frame(p->owner, f, 0);
-                       pthread_mutex_unlock(&p->owner->lock);
+                       ast_mutex_unlock(&p->owner->lock);
                }
        }
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return 0;
 }
 #endif
@@ -1032,7 +1032,7 @@ static struct mgcp_subchannel *find_subchannel(char *name, int msgid, struct soc
                *at = '\0';
                at++;
        }
-       ast_pthread_mutex_lock(&gatelock);
+       ast_mutex_lock(&gatelock);
        if (at && (at[0] == '[')) {
                at++;
                c = strrchr(at, ']');
@@ -1086,7 +1086,7 @@ static struct mgcp_subchannel *find_subchannel(char *name, int msgid, struct soc
                }
                g = g->next;
        }
-       ast_pthread_mutex_unlock(&gatelock);
+       ast_mutex_unlock(&gatelock);
        if (!sub) {
                if (name) {
                        if (g)
@@ -1724,7 +1724,7 @@ static void handle_response(struct mgcp_subchannel *sub, int result, int ident)
 
 static void start_rtp(struct mgcp_subchannel *sub)
 {
-               ast_pthread_mutex_lock(&sub->lock);
+               ast_mutex_lock(&sub->lock);
                /* Allocate the RTP now */
                sub->rtp = ast_rtp_new(sched, io, 1, 0);
                if (sub->rtp && sub->owner)
@@ -1739,7 +1739,7 @@ static void start_rtp(struct mgcp_subchannel *sub)
         snprintf(sub->callid, sizeof(sub->callid), "%08x%s", rand(), sub->txident);
                /* Transmit the connection create */
                transmit_connect_with_sdp(sub, NULL);
-               ast_pthread_mutex_unlock(&sub->lock);
+               ast_mutex_unlock(&sub->lock);
 }
 
 static void *mgcp_ss(void *data)
@@ -2479,9 +2479,9 @@ static void *do_monitor(void *data)
                /* Check for interfaces needing to be killed */
                /* Don't let anybody kill us right away.  Nobody should lock the interface list
                   and wait for the monitor list, but the other way around is okay. */
-               ast_pthread_mutex_lock(&monlock);
+               ast_mutex_lock(&monlock);
                /* Lock the network interface */
-               ast_pthread_mutex_lock(&netlock);
+               ast_mutex_lock(&netlock);
                p = packets;
                while(p) {
                        /* Handle any retransmissions */
@@ -2519,17 +2519,17 @@ static void *do_monitor(void *data)
 #endif
         
                /* Okay, now that we know what to do, release the network lock */
-               ast_pthread_mutex_unlock(&netlock);
+               ast_mutex_unlock(&netlock);
                /* And from now on, we're okay to be killed, so release the monitor lock as well */
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
                pthread_testcancel();
                /* Wait for sched or io */
                res = ast_sched_wait(sched);
                res = ast_io_wait(io, res);
-               ast_pthread_mutex_lock(&monlock);
+               ast_mutex_lock(&monlock);
                if (res >= 0) 
                        ast_sched_runq(sched);
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
        }
        /* Never reached */
        return NULL;
@@ -2541,12 +2541,12 @@ static int restart_monitor(void)
        /* If we're supposed to be stopped -- stay stopped */
        if (monitor_thread == -2)
                return 0;
-       if (ast_pthread_mutex_lock(&monlock)) {
+       if (ast_mutex_lock(&monlock)) {
                ast_log(LOG_WARNING, "Unable to lock monitor\n");
                return -1;
        }
        if (monitor_thread == pthread_self()) {
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
                ast_log(LOG_WARNING, "Cannot kill myself\n");
                return -1;
        }
@@ -2556,12 +2556,12 @@ static int restart_monitor(void)
        } else {
                /* Start a new monitor */
                if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {
-                       ast_pthread_mutex_unlock(&monlock);
+                       ast_mutex_unlock(&monlock);
                        ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
                        return -1;
                }
        }
-       ast_pthread_mutex_unlock(&monlock);
+       ast_mutex_unlock(&monlock);
        return 0;
 }
 
@@ -2932,10 +2932,10 @@ int load_module()
                                if (option_verbose > 2) {
                                        ast_verbose(VERBOSE_PREFIX_3 "Added gateway '%s'\n", g->name);
                 }
-                               ast_pthread_mutex_lock(&gatelock);
+                               ast_mutex_lock(&gatelock);
                                g->next = gateways;
                                gateways = g;
-                               ast_pthread_mutex_unlock(&gatelock);
+                               ast_mutex_unlock(&gatelock);
                        }
                }
                cat = ast_category_browse(cfg, cat);
@@ -2954,7 +2954,7 @@ int load_module()
        if (!ntohs(bindaddr.sin_port))
                bindaddr.sin_port = ntohs(DEFAULT_MGCP_PORT);
        bindaddr.sin_family = AF_INET;
-       pthread_mutex_lock(&netlock);
+       ast_mutex_lock(&netlock);
        if (mgcpsock > -1)
                close(mgcpsock);
        mgcpsock = socket(AF_INET, SOCK_DGRAM, 0);
@@ -2977,7 +2977,7 @@ int load_module()
                                ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
         }
        }
-       pthread_mutex_unlock(&netlock);
+       ast_mutex_unlock(&netlock);
        ast_destroy(cfg);
 
        /* Make sure we can register our mgcp channel type */
@@ -3015,7 +3015,7 @@ int unload_module()
        struct mgcp_endpoint *p, *pl;
        /* First, take us out of the channel loop */
        ast_channel_unregister(type);
-       if (!ast_pthread_mutex_lock(&gatelock)) {
+       if (!ast_mutex_lock(&gatelock)) {
                /* Hangup all interfaces if they have an owner */
                p = iflist;
                while(p) {
@@ -3024,25 +3024,25 @@ int unload_module()
                        p = p->next;
                }
                iflist = NULL;
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
-       if (!ast_pthread_mutex_lock(&monlock)) {
+       if (!ast_mutex_lock(&monlock)) {
                if (monitor_thread) {
                        pthread_cancel(monitor_thread);
                        pthread_kill(monitor_thread, SIGURG);
                        pthread_join(monitor_thread, NULL);
                }
                monitor_thread = -2;
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
 
-       if (!ast_pthread_mutex_lock(&iflock)) {
+       if (!ast_mutex_lock(&iflock)) {
                /* Destroy all the interfaces and free their memory */
                p = iflist;
                while(p) {
@@ -3052,7 +3052,7 @@ int unload_module()
                        free(pl);
                }
                iflist = NULL;
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
@@ -3064,9 +3064,9 @@ int unload_module()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 900eb0a..b620026 100755 (executable)
@@ -71,14 +71,14 @@ static int baudrate = 115200;
 
 static int stripmsd = 0;
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 /* Protect the interface list (of ast_modem_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
 
 /* Protect the monitoring thread, so only one process can kill or start it, and not
    when it's doing something critical. */
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
 
 /* This is the thread for the monitor which checks for input on the channels
    which are not currently in use.  */
@@ -421,11 +421,11 @@ static int modem_hangup(struct ast_channel *ast)
        memset(p->cid, 0, sizeof(p->cid));
        memset(p->dnid, 0, sizeof(p->dnid));
        ((struct ast_modem_pvt *)(ast->pvt->pvt))->owner = NULL;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt--;
        if (usecnt < 0) 
                ast_log(LOG_WARNING, "Usecnt < 0???\n");
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
@@ -525,9 +525,9 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
                if (strlen(i->dnid))
                        strncpy(tmp->exten, i->dnid, sizeof(tmp->exten) - 1);
                i->owner = tmp;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -570,14 +570,14 @@ static void *do_monitor(void *data)
        for(;;) {
                /* Don't let anybody kill us right away.  Nobody should lock the interface list
                   and wait for the monitor list, but the other way around is okay. */
-               if (ast_pthread_mutex_lock(&monlock)) {
+               if (ast_mutex_lock(&monlock)) {
                        ast_log(LOG_ERROR, "Unable to grab monitor lock\n");
                        return NULL;
                }
                /* Lock the interface list */
-               if (ast_pthread_mutex_lock(&iflock)) {
+               if (ast_mutex_lock(&iflock)) {
                        ast_log(LOG_ERROR, "Unable to grab interface lock\n");
-                       ast_pthread_mutex_unlock(&monlock);
+                       ast_mutex_unlock(&monlock);
                        return NULL;
                }
                /* Build the stuff we're going to select on, that is the socket of every
@@ -600,10 +600,10 @@ static void *do_monitor(void *data)
                        i = i->next;
                }
                /* Okay, now that we know what to do, release the interface lock */
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
                
                /* And from now on, we're okay to be killed, so release the monitor lock as well */
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
 #if 0
                ast_log(LOG_DEBUG, "In monitor, n=%d, pid=%d\n", n, getpid());
 #endif
@@ -618,7 +618,7 @@ static void *do_monitor(void *data)
                }
                /* Alright, lock the interface list again, and let's look and see what has
                   happened */
-               if (ast_pthread_mutex_lock(&iflock)) {
+               if (ast_mutex_lock(&iflock)) {
                        ast_log(LOG_WARNING, "Unable to lock the interface list\n");
                        continue;
                }
@@ -634,7 +634,7 @@ static void *do_monitor(void *data)
                        }
                        i=i->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        }
        /* Never reached */
        return NULL;
@@ -646,12 +646,12 @@ static int restart_monitor()
        /* If we're supposed to be stopped -- stay stopped */
        if (monitor_thread == -2)
                return 0;
-       if (ast_pthread_mutex_lock(&monlock)) {
+       if (ast_mutex_lock(&monlock)) {
                ast_log(LOG_WARNING, "Unable to lock monitor\n");
                return -1;
        }
        if (monitor_thread == pthread_self()) {
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
                ast_log(LOG_WARNING, "Cannot kill myself\n");
                return -1;
        }
@@ -663,11 +663,11 @@ static int restart_monitor()
        }
        /* Start a new monitor */
        if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
                ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
                return -1;
        }
-       ast_pthread_mutex_unlock(&monlock);
+       ast_mutex_unlock(&monlock);
        return 0;
 }
 
@@ -762,7 +762,7 @@ static struct ast_channel *modem_request(char *type, int format, void *data)
        }
 
        /* Search for an unowned channel */
-       if (ast_pthread_mutex_lock(&iflock)) {
+       if (ast_mutex_lock(&iflock)) {
                ast_log(LOG_ERROR, "Unable to lock interface list???\n");
                return NULL;
        }
@@ -799,7 +799,7 @@ static struct ast_channel *modem_request(char *type, int format, void *data)
        if (!p) 
                ast_log(LOG_WARNING, "Requested device '%s' does not exist\n", dev);
        
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return tmp;
 }
 
@@ -852,7 +852,7 @@ int load_module()
                ast_log(LOG_ERROR, "Unable to load config %s\n", config);
                return -1;
        }
-       if (ast_pthread_mutex_lock(&iflock)) {
+       if (ast_mutex_lock(&iflock)) {
                /* It's a little silly to lock it, but we mind as well just to be sure */
                ast_log(LOG_ERROR, "Unable to lock interface list???\n");
                return -1;
@@ -869,7 +869,7 @@ int load_module()
                                } else {
                                        ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
                                        ast_destroy(cfg);
-                                       ast_pthread_mutex_unlock(&iflock);
+                                       ast_mutex_unlock(&iflock);
                                        unload_module();
                                        return -1;
                                }
@@ -881,7 +881,7 @@ int load_module()
                        if (ast_load_resource(driver)) {
                                ast_log(LOG_ERROR, "Failed to load driver %s\n", driver);
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                unload_module();
                                return -1;
                        }
@@ -915,7 +915,7 @@ int load_module()
                }
                v = v->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */ 
                                                AST_FORMAT_SLINEAR, modem_request)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -934,7 +934,7 @@ int unload_module()
        struct ast_modem_pvt *p, *pl;
        /* First, take us out of the channel loop */
        ast_channel_unregister(type);
-       if (!ast_pthread_mutex_lock(&iflock)) {
+       if (!ast_mutex_lock(&iflock)) {
                /* Hangup all interfaces if they have an owner */
                p = iflist;
                while(p) {
@@ -943,24 +943,24 @@ int unload_module()
                        p = p->next;
                }
                iflist = NULL;
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
-       if (!ast_pthread_mutex_lock(&monlock)) {
+       if (!ast_mutex_lock(&monlock)) {
                if (monitor_thread > -1) {
                        pthread_cancel(monitor_thread);
                        pthread_join(monitor_thread, NULL);
                }
                monitor_thread = -2;
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
 
-       if (!ast_pthread_mutex_lock(&iflock)) {
+       if (!ast_mutex_lock(&iflock)) {
                /* Destroy all the interfaces and free their memory */
                p = iflist;
                while(p) {
@@ -973,7 +973,7 @@ int unload_module()
                        free(pl);
                }
                iflist = NULL;
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
@@ -985,9 +985,9 @@ int unload_module()
 int usecount(void)
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 3aa1978..4222e85 100755 (executable)
@@ -34,7 +34,7 @@ static char *breakcmd = "\0x10\0x03";
 static char *desc = "A/Open (Rockwell Chipset) ITU-2 VoiceModem Driver";
 
 static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char *aopen_idents[] = {
        /* Identify A/Open Modem */
@@ -363,17 +363,17 @@ static char *aopen_identify(struct ast_modem_pvt *p)
 
 static void aopen_incusecnt(void)
 {
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt++;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
 static void aopen_decusecnt(void)
 {
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt++;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
@@ -457,9 +457,9 @@ static struct ast_modem_driver aopen_driver =
 int usecount(void)
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 90cc878..10732dc 100755 (executable)
@@ -39,7 +39,7 @@ static char *breakcmd = "\020!";
 static char *desc = "BestData (Conexant V.90 Chipset) VoiceModem Driver";
 
 static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char *bestdata_idents[] = {
        /* Identify BestData Modem */
@@ -439,17 +439,17 @@ static char *bestdata_identify(struct ast_modem_pvt *p)
 
 static void bestdata_incusecnt(void)
 {
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt++;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
 static void bestdata_decusecnt(void)
 {
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt++;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
@@ -570,9 +570,9 @@ static struct ast_modem_driver bestdata_driver =
 int usecount(void)
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 8571882..c011a9f 100755 (executable)
@@ -34,7 +34,7 @@ static char *breakcmd = "\0x10\0x14\0x10\0x3";
 static char *desc = "ISDN4Linux Emulated Modem Driver";
 
 static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char *i4l_idents[] = {
        /* Identify ISDN4Linux Driver */
@@ -476,17 +476,17 @@ static char *i4l_identify(struct ast_modem_pvt *p)
 
 static void i4l_incusecnt(void)
 {
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt++;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
 static void i4l_decusecnt(void)
 {
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt++;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
@@ -597,9 +597,9 @@ static struct ast_modem_driver i4l_driver =
 int usecount(void)
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index f366f97..0cf50f5 100755 (executable)
@@ -41,7 +41,7 @@ static int usecnt =0;
 /* Only linear is allowed */
 static int prefformat = AST_FORMAT_SLINEAR;
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char context[AST_MAX_EXTENSION] = "default";
 
@@ -215,9 +215,9 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state)
                strncpy(tmp->exten, "s",  sizeof(tmp->exten) - 1);
                strcpy(tmp->language, "");
                i->owner = tmp;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -276,9 +276,9 @@ int unload_module()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 376f5e0..28f20d4 100755 (executable)
@@ -64,7 +64,7 @@ static int silencesuppression = 0;
 static int silencethreshold = 1000;
 
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char *type = "Console";
 static char *desc = "OSS Console Channel Driver";
@@ -490,9 +490,9 @@ static int oss_hangup(struct ast_channel *c)
        c->pvt->pvt = NULL;
        oss.owner = NULL;
        ast_verbose( " << Hangup on console >> \n");
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt--;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        if (hookstate) {
                if (autoanswer) {
                        /* Assume auto-hangup too */
@@ -712,9 +712,9 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
                        strncpy(tmp->language, language, sizeof(tmp->language)-1);
                p->owner = tmp;
                ast_setstate(tmp, state);
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -1029,9 +1029,9 @@ char *description()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }
 
index 80232c3..5ae642a 100755 (executable)
@@ -56,14 +56,14 @@ static int silencesupression = 0;
 
 static int prefformat = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 /* Protect the interface list (of phone_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
 
 /* Protect the monitoring thread, so only one process can kill or start it, and not
    when it's doing something critical. */
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
 
 /* This is the thread for the monitor which checks for input on the channels
    which are not currently in use.  */
@@ -221,11 +221,11 @@ static int phone_hangup(struct ast_channel *ast)
        p->dialtone = 0;
        memset(p->ext, 0, sizeof(p->ext));
        ((struct phone_pvt *)(ast->pvt->pvt))->owner = NULL;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt--;
        if (usecnt < 0) 
                ast_log(LOG_WARNING, "Usecnt < 0???\n");
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
@@ -640,9 +640,9 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
                if (strlen(i->callerid))
                        tmp->callerid = strdup(i->callerid);
                i->owner = tmp;
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (state == AST_STATE_RING) {
@@ -695,9 +695,9 @@ static void phone_check_exception(struct phone_pvt *i)
                                phone_new(i, AST_STATE_RING, i->context);
                                /* No need to restart monitor, we are the monitor */
                                if (i->owner) {
-                                       ast_pthread_mutex_lock(&usecnt_lock);
+                                       ast_mutex_lock(&usecnt_lock);
                                        usecnt--;
-                                       ast_pthread_mutex_unlock(&usecnt_lock);
+                                       ast_mutex_unlock(&usecnt_lock);
                                        ast_update_use_count();
                                }
                        } else if (!ast_canmatch_extension(NULL, i->context, i->ext, 1, i->callerid)) {