]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
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 0c5359812a65d371d79dea9db415f04c505e2e97..960df721ae519ecb0adbb3fa641012abb5245224 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 bf139e0b9a9eb4062dd3724bcac927b33cbcb9ed..c4be328dd7a3a1dc3b15dcdf0e87e9ab4b83ce8a 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 331e55072fbd40313e3da04db2211474a0db4a4d..4ea0947bb447e979cdc75fe1a39217250a8657b3 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 12b0ce590e7808104c3f30389554aa68eb04df58..a26392d0246876b0310cc6a1a62a263013ad5d35 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 8417833a903f59b23aaab7243da2159068837e4e..43440e435674053c6b8e847224e777f6df871843 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 a955fe32e33dbf6a5503dc2572131430738a191f..2dd8d07471c644c26e03dfbe3f488fded4ff5176 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 ccc38457477aac18234e13195b86d9835e246e76..8813c072277a1559529c91a873e5f11aacd56bf4 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 94e4555b5f557a2071e2ef01a98d7f963cfeaaeb..ebc6fc1e0e4cc8f629c8ce9a28d8e4a372f69c83 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 5f15c244c8fdca2a7fb554304987433ca73237b4..fc81c483b5e9439f955927c0517e7316cfecbf15 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 6be19f2609dd98e46d6817dc582d00c695db53ea..20b3e2cfaaad5b89bb23d4e45dba2cd1aa67f801 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 b8127cf0d0efbd8456ddb3c3a07d4a4e0d7d0f51..a2632eacc960ed5e236ffd8fdd09039016535f43 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 89a6db7c64e35fe85ada212217ddc270dc5650e2..c393631795b8a4279a65b49d71285cafda104790 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 53dd4e7e95277304e12f75092d7edfa572bc474d..74155d0a80fd9ee87b900fa148e1ce5b9904eb41 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 dfbce5722e57e6b9cbc94c811b2ff4de1e0abd3c..e7ec368b42aa657dfee9ee9bacfd3cd2e0658420 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 b9869916ab027f9784786c0fb05a2d1f6009ae7f..1d1c354bbfb14afe4e917711812dd972df2b74c7 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 83f4723af45ff878bf4677883ec3e581872b5e33..b6feec094ada14a153a8ff27367d95442979d1d1 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 662cf7c0cf41359edf0f8f0172f7c6ae02132bf4..7889d0fa303318768e7bdfe3d530babe2a16100f 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 691483ea8dce58a81d9afd66b7e38dfc70e1a047..19045e85b761231dac01b8e674256b10dc9466e1 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 900eb0ad5820a21fbe0a9b8b84dc69ef094c498d..b62002679a5f94031033c4a8c66c3a8137b0b2ea 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 3aa1978afc278b6f674cb549805f495d218a4420..4222e85cdd9ea068aa560debdbe0065459956864 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 90cc87828cf0471cf2f7b2b01234a206be1fbeaf..10732dca75f72acff8e3526798f810bc591f847f 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 857188277262c5fa4b68c233a417c11e157d5e66..c011a9fc8cad1ace67fca5e8409fe800590d43ab 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 f366f976e262e468f13a72a37256cb8c7d68fe27..0cf50f56ccf7e1015bafa6266a32afbdb844902b 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 376f5e05942db6d67896c23ac2bbb9a1f2de0272..28f20d48571c4d30c1a0cd3f25e2f9e32d1a6978 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 80232c3c883719e634476b6d250f341751ff444d..5ae642a1f6ebd6dc5bd260115d17d3314f9ec7a8 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)) {
@@ -707,9 +707,9 @@ static void phone_check_exception(struct phone_pvt *i)
                                        /* Check the default, too... */
                                        phone_new(i, AST_STATE_RING, "default");
                                        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();
                                        }
                                        /* XXX This should probably be justified better XXX */
@@ -732,9 +732,9 @@ static void phone_check_exception(struct phone_pvt *i)
                        if (i->mode == MODE_IMMEDIATE) {
                                phone_new(i, AST_STATE_RING, i->context);
                        } else if (i->mode == MODE_DIALTONE) {
-                               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();
                                /* Reset the extension */
                                i->ext[0] = '\0';
@@ -747,9 +747,9 @@ static void phone_check_exception(struct phone_pvt *i)
                        }
                } else {
                        if (i->dialtone) {
-                               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();
                        }
                        memset(i->ext, 0, sizeof(i->ext));
@@ -793,14 +793,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
@@ -834,10 +834,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);
                /* Wait indefinitely for something to happen */
                if (dotone) {
                        /* If we're ready to recycle the time, set it to 30 ms */
@@ -866,7 +866,7 @@ static void *do_monitor(void *data)
                        continue;
                /* 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;
                }
@@ -888,7 +888,7 @@ static void *do_monitor(void *data)
                        }
                        i=i->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        }
        /* Never reached */
        return NULL;
@@ -900,12 +900,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;
        }
@@ -917,11 +917,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;
 }
 
@@ -997,7 +997,7 @@ static struct ast_channel *phone_request(char *type, int format, void *data)
                return NULL;
        }
        /* 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;
        }
@@ -1011,7 +1011,7 @@ static struct ast_channel *phone_request(char *type, int format, void *data)
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        restart_monitor();
        return tmp;
 }
@@ -1053,7 +1053,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;
@@ -1070,7 +1070,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;
                                }
@@ -1118,7 +1118,7 @@ int load_module()
                }       
                v = v->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        /* Make sure we can register our Adtranphone channel type */
        if (ast_channel_register(type, tdesc, 
                         AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, phone_request)) {
@@ -1140,7 +1140,7 @@ int unload_module()
        struct phone_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) {
@@ -1149,24 +1149,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) {
@@ -1179,7 +1179,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;
@@ -1191,9 +1191,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 a1b9adc6b065e1bde0c6b89032c008e1745a7589..b4602275a66854fc258017f6640897cef34a3b93 100755 (executable)
@@ -100,16 +100,16 @@ static int srvlookup = 0;
 static int pedanticsipchecking = 0;
 
 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 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 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.  */
@@ -168,7 +168,7 @@ struct sip_route {
 };
 
 static struct sip_pvt {
-       pthread_mutex_t lock;                           /* Channel private lock */
+       ast_mutex_t lock;                               /* Channel private lock */
        char callid[80];                                        /* Global CallID */
        char randdata[80];      /* Random data */
        unsigned int ocseq;                                     /* Current outgoing seqno */
@@ -319,12 +319,12 @@ struct sip_peer {
 
 static struct ast_user_list {
        struct sip_user *users;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } userl = { NULL, AST_MUTEX_INITIALIZER };
 
 static struct ast_peer_list {
        struct sip_peer *peers;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
 } peerl = { NULL, AST_MUTEX_INITIALIZER };
 
 
@@ -337,7 +337,7 @@ static struct ast_peer_list {
 #define REG_STATE_NOAUTH          6
 
 struct sip_registry {
-       pthread_mutex_t lock;                           /* Channel private lock */
+       ast_mutex_t lock;                               /* Channel private lock */
        struct sockaddr_in addr;                /* Who we connect to for registration purposes */
        char username[80];                              /* Who we are registering as */
        char authuser[80];                              /* Who we *authenticate* as */
@@ -405,7 +405,7 @@ static int retrans_pkt(void *data)
 {
        struct sip_pkt *pkt=data;
        int res = 0;
-       ast_pthread_mutex_lock(&pkt->owner->lock);
+       ast_mutex_lock(&pkt->owner->lock);
        if (1 /* !p->owner->needdestroy */) {
                if (pkt->retrans < MAX_RETRANS) {
                        pkt->retrans++;
@@ -425,7 +425,7 @@ static int retrans_pkt(void *data)
                                ast_queue_hangup(pkt->owner->owner, 1);
                        } else {
                                /* If no owner, destroy now */
-                               ast_pthread_mutex_unlock(&pkt->owner->lock);
+                               ast_mutex_unlock(&pkt->owner->lock);
                                sip_destroy(pkt->owner);
                                pkt = NULL;
                        }
@@ -438,13 +438,13 @@ static int retrans_pkt(void *data)
                        ast_queue_hangup(pkt->owner->owner, 1);
                } else {
                        /* If no owner, destroy now */
-                       ast_pthread_mutex_unlock(&pkt->owner->lock);
+                       ast_mutex_unlock(&pkt->owner->lock);
                        sip_destroy(pkt->owner);
                        pkt=NULL;
                }
        }
        if (pkt)
-               ast_pthread_mutex_unlock(&pkt->owner->lock);
+               ast_mutex_unlock(&pkt->owner->lock);
        return res;
 }
 
@@ -611,7 +611,7 @@ static int create_addr(struct sip_pvt *r, char *peer)
        char host[256], *hostn;
 
        r->sa.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)) {
@@ -668,7 +668,7 @@ static int create_addr(struct sip_pvt *r, char *peer)
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (!p && !found) {
                if ((port=strchr(peer, ':'))) {
                        *port='\0';
@@ -710,16 +710,16 @@ static int create_addr(struct sip_pvt *r, char *peer)
 static int auto_congest(void *nothing)
 {
        struct sip_pvt *p = nothing;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        p->initid = -1;
        if (p->owner) {
-               if (!pthread_mutex_trylock(&p->owner->lock)) {
+               if (!ast_mutex_trylock(&p->owner->lock)) {
                        ast_log(LOG_NOTICE, "Auto-congesting %s\n", p->owner->name);
                        ast_queue_control(p->owner, AST_CONTROL_CONGESTION, 0);
-                       ast_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;
 }
 
@@ -856,11 +856,11 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
        /* Unlink us from the owner if we have one */
        if (p->owner) {
                if (lockowner)
-                       ast_pthread_mutex_lock(&p->owner->lock);
+                       ast_mutex_lock(&p->owner->lock);
                ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
                p->owner->pvt->pvt = NULL;
                if (lockowner)
-                       ast_pthread_mutex_unlock(&p->owner->lock);
+                       ast_mutex_unlock(&p->owner->lock);
        }
        cur = iflist;
        while(cur) {
@@ -894,7 +894,7 @@ static int find_user(struct sip_pvt *fup, int event)
        char name[256] = "";
        struct sip_user *u;
        strncpy(name, fup->username, sizeof(name) - 1);
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        u = userl.users;
        while(u) {
                if (!strcasecmp(u->name, name)) {
@@ -904,7 +904,7 @@ static int find_user(struct sip_pvt *fup, int event)
        }
        if (!u) {
                ast_log(LOG_DEBUG, "%s is not a local user\n", name);
-               ast_pthread_mutex_unlock(&userl.lock);
+               ast_mutex_unlock(&userl.lock);
                return 0;
        }
        if(event == 0) {
@@ -917,22 +917,22 @@ static int find_user(struct sip_pvt *fup, int event)
                if (u->incominglimit > 0 ) {
                        if (u->inUse >= u->incominglimit) {
                                ast_log(LOG_ERROR, "Call from user '%s' rejected due to usage limit of %d\n", u->name, u->incominglimit);
-                               ast_pthread_mutex_unlock(&userl.lock);
+                               ast_mutex_unlock(&userl.lock);
                                return -1; 
                        }
                }
                u->inUse++;
                ast_log(LOG_DEBUG, "Call from user '%s' is %d out of %d\n", u->name, u->inUse, u->incominglimit);
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        return 0;
 }
 
 static void sip_destroy(struct sip_pvt *p)
 {
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        __sip_destroy(p, 1);
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
 }
 
 static int transmit_response_reliable(struct sip_pvt *p, char *msg, struct sip_request *req);
@@ -949,13 +949,13 @@ static int sip_hangup(struct ast_channel *ast)
                ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
                return 0;
        }
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        ast_log(LOG_DEBUG, "find_user(%s)\n", p->username);
        find_user(p, 0);
        /* Determine how to disconnect */
        if (p->owner != ast) {
                ast_log(LOG_WARNING, "Huh?  We aren't the owner?\n");
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return 0;
        }
        if (!ast || (ast->_state != AST_STATE_UP))
@@ -992,7 +992,7 @@ static int sip_hangup(struct ast_channel *ast)
                }
        }
        p->needdestroy = needdestroy;
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return 0;
 }
 
@@ -1035,7 +1035,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                        return -1;
                }
                if (p) {
-                       ast_pthread_mutex_lock(&p->lock);
+                       ast_mutex_lock(&p->lock);
                        if (p->rtp) {
                                if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) {
                                        transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0);
@@ -1043,11 +1043,11 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                                }
                                res =  ast_rtp_write(p->rtp, frame);
                        }
-                       ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                }
        } else if (frame->frametype == AST_FRAME_VIDEO) {
                if (p) {
-                       ast_pthread_mutex_lock(&p->lock);
+                       ast_mutex_lock(&p->lock);
                        if (p->vrtp) {
                                if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) {
                                        transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0);
@@ -1055,7 +1055,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                                }
                                res =  ast_rtp_write(p->vrtp, frame);
                        }
-                       ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                }
        } else if (frame->frametype == AST_FRAME_IMAGE) {
                return 0;
@@ -1070,14 +1070,14 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
 static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
        struct sip_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;
 }
 
@@ -1220,9 +1220,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
                if (strlen(i->language))
                        strncpy(tmp->language, i->language, sizeof(tmp->language)-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();
                strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
                strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
@@ -1370,9 +1370,9 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
        struct sip_pvt *p = ast->pvt->pvt;
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        fr = sip_rtp_read(ast, p);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return fr;
 }
 
@@ -1427,7 +1427,7 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
                if (p->vrtp)
                        ast_rtp_setnat(p->vrtp, p->nat);
        }
-       ast_pthread_mutex_init(&p->lock);
+       ast_mutex_init(&p->lock);
 
        if (sin) {
                memcpy(&p->sa, sin, sizeof(p->sa));
@@ -1450,10 +1450,10 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
        strncpy(p->context, context, sizeof(p->context) - 1);
        strncpy(p->fromdomain, fromdomain, sizeof(p->fromdomain) - 1);
        /* Add to list */
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        p->next = iflist;
        iflist = p;
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        if (option_debug)
                ast_log(LOG_DEBUG, "Allocating new SIP call for %s\n", callid);
        return p;
@@ -1506,22 +1506,22 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
                ast_log(LOG_WARNING, "Call missing call ID from '%s'\n", inet_ntoa(sin->sin_addr));
                return NULL;
        }
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        p = iflist;
        while(p) {
                if (!strcmp(p->callid, callid) && 
                        (!pedanticsipchecking || !strlen(p->theirtag) || !strcmp(p->theirtag, tag))) {
                        /* Found the call */
-                       ast_pthread_mutex_lock(&p->lock);
-                       ast_pthread_mutex_unlock(&iflock);
+                       ast_mutex_lock(&p->lock);
+                       ast_mutex_unlock(&iflock);
                        return p;
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        p = sip_alloc(callid, sin, 1);
        if (p)
-               ast_pthread_mutex_lock(&p->lock);
+               ast_mutex_lock(&p->lock);
        return p;
 }
 
@@ -1923,11 +1923,15 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct s
                tmp = __get_header(orig, field, &start);
                if (strlen(tmp)) {
                        if (!copied && p->nat) {
+#ifdef THE_SIP_AUTHORS_CAN_SUCK_MY_GONADS
                                /* SLD: FIXME: Nice try, but the received= should not have a port */
                                /* SLD: FIXME: See RFC2543 BNF in Section 6.40.5 */
+                               /* MAS: Yup, RFC says you can't do it.  No way to indicate PAT...
+                                  good job fellas. */
                                if (ntohs(p->recv.sin_port) != DEFAULT_SIP_PORT)
                                        snprintf(new, sizeof(new), "%s;received=%s:%d", tmp, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
                                else
+#endif                         
                                        snprintf(new, sizeof(new), "%s;received=%s", tmp, inet_ntoa(p->recv.sin_addr));
                                add_header(req, field, new);
                        } else {
@@ -2759,9 +2763,9 @@ static int sip_reregister(void *data)
 static int sip_do_register(struct sip_registry *r)
 {
        int res;
-       ast_pthread_mutex_lock(&r->lock);
+       ast_mutex_lock(&r->lock);
        res=transmit_register(r, "REGISTER", NULL);
-       ast_pthread_mutex_unlock(&r->lock);
+       ast_mutex_unlock(&r->lock);
        return res;
 }
 
@@ -2771,7 +2775,7 @@ static int sip_reg_timeout(void *data)
        struct sip_registry *r=data;
        struct sip_pvt *p;
        int res;
-       ast_pthread_mutex_lock(&r->lock);
+       ast_mutex_lock(&r->lock);
        ast_log(LOG_NOTICE, "Registration for '%s@%s' timed out, trying again\n", r->username, inet_ntoa(r->addr.sin_addr)); 
        if (r->call) {
                /* Unlink us, destroy old call.  Locking is not relevent here because all this happens
@@ -2784,7 +2788,7 @@ static int sip_reg_timeout(void *data)
        r->regstate=REG_STATE_UNREGISTERED;
        r->timeout = -1;
        res=transmit_register(r, "REGISTER", NULL);
-       ast_pthread_mutex_unlock(&r->lock);
+       ast_mutex_unlock(&r->lock);
        return 0;
 }
 
@@ -3326,7 +3330,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
                *c = '\0';
        strncpy(p->exten, name, sizeof(p->exten) - 1);
        build_contact(p);
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peer = peerl.peers;
        while(peer) {
                if (!strcasecmp(peer->name, name) && peer->dynamic) {
@@ -3347,7 +3351,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
                }       
                peer = peer->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (!res) {
            ast_device_state_changed("SIP/%s", peer->name);
        }
@@ -3492,19 +3496,19 @@ static int get_refer_info(struct sip_pvt *p, struct sip_request *oreq)
                strncpy(p->refer_contact, "", sizeof(p->refer_contact) - 1);
                strncpy(p->remote_party_id, "", sizeof(p->remote_party_id) - 1);
                p->refer_call = NULL;
-               ast_pthread_mutex_lock(&iflock);
+               ast_mutex_lock(&iflock);
                /* Search interfaces and find the match */
                p2 = iflist;
                while(p2) {
                        if (!strcmp(p2->callid, tmp5)) {
                                /* Go ahead and lock it before returning */
-                               ast_pthread_mutex_lock(&p2->lock);
+                               ast_mutex_lock(&p2->lock);
                                p->refer_call = p2;
                                break;
                        }
                        p2 = p2->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
                if (p->refer_call)
                        return 0;
                else
@@ -3633,7 +3637,7 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
                strncpy(p->callerid, of, sizeof(p->callerid) - 1);
        if (!strlen(of))
                        return 0;
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        user = userl.users;
        while(user) {
                if (!strcasecmp(user->name, of)) {
@@ -3670,10 +3674,10 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
                }
                user = user->next;
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        if (!user) {
        /* If we didn't find a user match, check for peers */
-               ast_pthread_mutex_lock(&peerl.lock);
+               ast_mutex_lock(&peerl.lock);
                peer = peerl.peers;
                while(peer) {
                        if (!inaddrcmp(&peer->addr, &p->recv) || 
@@ -3705,7 +3709,7 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
                        }
                        peer = peer->next;
                }
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
        }
        return res;
 }
@@ -3750,7 +3754,7 @@ static int sip_show_inuse(int fd, int argc, char *argv[]) {
        char used[80];
        if (argc != 3) 
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&userl.lock);
+       ast_mutex_lock(&userl.lock);
        user = userl.users;
        ast_cli(fd, FORMAT, "Username", "inUse", "Limit");
        for(user=userl.users;user;user=user->next) {
@@ -3761,7 +3765,7 @@ static int sip_show_inuse(int fd, int argc, char *argv[]) {
                snprintf(used, sizeof(used), "%d", user->inUse);
                ast_cli(fd, FORMAT2, user->name, used, limits);
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -3774,13 +3778,13 @@ static int sip_show_users(int fd, int argc, char *argv[])
        struct sip_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->context,user->ha ? "Yes" : "No");
        }
-       ast_pthread_mutex_unlock(&userl.lock);
+       ast_mutex_unlock(&userl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 }
@@ -3793,7 +3797,7 @@ static int sip_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] = "";
@@ -3820,7 +3824,7 @@ static int sip_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
@@ -3856,14 +3860,14 @@ static int sip_show_registry(int fd, int argc, char *argv[])
        char host[80];
        if (argc != 3)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        ast_cli(fd, FORMAT2, "Host", "Username", "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));
                ast_cli(fd, FORMAT, host,
                                        reg->username, reg->refresh, regstate2str(reg->regstate));
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -3877,7 +3881,7 @@ static int sip_show_channels(int fd, int argc, char *argv[])
        int numchans = 0;
        if (argc != 3)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        cur = iflist;
        ast_cli(fd, FORMAT2, "Peer", "User/ANR", "Call ID", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
        while (cur) {
@@ -3893,7 +3897,7 @@ static int sip_show_channels(int fd, int argc, char *argv[])
                }
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        ast_cli(fd, "%d active SIP channel(s)\n", numchans);
        return RESULT_SUCCESS;
 #undef FORMAT
@@ -3905,7 +3909,7 @@ static char *complete_sipch(char *line, char *word, int pos, int state)
        int which=0;
        struct sip_pvt *cur;
        char *c = NULL;
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        cur = iflist;
        while(cur) {
                if (!strncasecmp(word, cur->callid, strlen(word))) {
@@ -3916,7 +3920,7 @@ static char *complete_sipch(char *line, char *word, int pos, int state)
                }
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return c;
 }
 
@@ -3926,7 +3930,7 @@ static int sip_show_channel(int fd, int argc, char *argv[])
        char tmp[256];
        if (argc != 4)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        cur = iflist;
        while(cur) {
                if (!strcasecmp(cur->callid, argv[3])) {
@@ -3950,7 +3954,7 @@ static int sip_show_channel(int fd, int argc, char *argv[])
                }
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        if (!cur) 
                ast_cli(fd, "No such SIP Call ID '%s'\n", argv[3]);
        return RESULT_SUCCESS;
@@ -4643,7 +4647,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                build_route(p, req, 0);
                                if (c) {
                                        /* Pre-lock the call */
-                                       ast_pthread_mutex_lock(&c->lock);
+                                       ast_mutex_lock(&c->lock);
                                }
                        }
                        
@@ -4660,10 +4664,10 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                        if (ast_pbx_start(c)) {
                                                ast_log(LOG_WARNING, "Failed to start PBX :(\n");
                                                /* Unlock locks so ast_hangup can do its magic */
-                                               ast_pthread_mutex_unlock(&c->lock);
-                                               ast_pthread_mutex_unlock(&p->lock);
+                                               ast_mutex_unlock(&c->lock);
+                                               ast_mutex_unlock(&p->lock);
                                                ast_hangup(c);
-                                               ast_pthread_mutex_lock(&p->lock);
+                                               ast_mutex_lock(&p->lock);
                                                transmit_response_reliable(p, "503 Unavailable", req);
                                                c = NULL;
                                        }
@@ -4672,16 +4676,16 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                        transmit_response_reliable(p, "503 Unavailable", req);
                                        p->alreadygone = 1;
                                        /* Unlock locks so ast_hangup can do its magic */
-                                       ast_pthread_mutex_unlock(&c->lock);
-                                       ast_pthread_mutex_unlock(&p->lock);
+                                       ast_mutex_unlock(&c->lock);
+                                       ast_mutex_unlock(&p->lock);
                                        ast_hangup(c);
-                                       ast_pthread_mutex_lock(&p->lock);
+                                       ast_mutex_lock(&p->lock);
                                        c = NULL;
                                } else {
-                                       ast_pthread_mutex_unlock(&c->lock);
-                                       ast_pthread_mutex_unlock(&p->lock);
+                                       ast_mutex_unlock(&c->lock);
+                                       ast_mutex_unlock(&p->lock);
                                        ast_hangup(c);
-                                       ast_pthread_mutex_lock(&p->lock);
+                                       ast_mutex_lock(&p->lock);
                                        c = NULL;
                                }
                                break;
@@ -4720,7 +4724,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                        if (p->refer_call) {
                                ast_log(LOG_DEBUG,"202 Accepted (supervised)\n");
                                attempt_transfer(p, p->refer_call);
-                               ast_pthread_mutex_unlock(&p->refer_call->lock);
+                               ast_mutex_unlock(&p->refer_call->lock);
                                p->refer_call = NULL;
                        } else {
                                ast_log(LOG_DEBUG,"202 Accepted (blind)\n");
@@ -4909,26 +4913,26 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
                return 1;
        }
        /* Process request, with netlock held */
-       ast_pthread_mutex_lock(&netlock);
+       ast_mutex_lock(&netlock);
        p = find_call(&req, &sin);
        if (p) {
 retrylock:
                /* Go ahead and lock the owner if it has one -- we may need it */
-               if (p->owner && pthread_mutex_trylock(&p->owner->lock)) {
+               if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
                        ast_log(LOG_DEBUG, "Failed to grab lock, trying again...\n");
-                       ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        /* Sleep infintismly short amount of time */
                        usleep(1);
-                       ast_pthread_mutex_lock(&p->lock);
+                       ast_mutex_lock(&p->lock);
                        goto retrylock;
                }
                memcpy(&p->recv, &sin, sizeof(p->recv));
                handle_request(p, &req, &sin);
                if (p->owner)
-                       ast_pthread_mutex_unlock(&p->owner->lock);
-               ast_pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->owner->lock);
+               ast_mutex_unlock(&p->lock);
        }
-       ast_pthread_mutex_unlock(&netlock);
+       ast_mutex_unlock(&netlock);
        return 1;
 }
 
@@ -4945,19 +4949,19 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
        
        /* Return now if it's the same thing we told them last time */
        if (((newmsgs << 8) | (oldmsgs)) == peer->lastmsgssent) {
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
                return 0;
        }
        
        p = sip_alloc(NULL, NULL, 0);
        if (!p) {
                ast_log(LOG_WARNING, "Unable to build sip pvt data for MWI\n");
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
                return -1;
        }
        strncpy(name, peer->name, sizeof(name) - 1);
        peer->lastmsgssent = ((newmsgs << 8) | (oldmsgs));
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (create_addr(p, name)) {
                /* Maybe they're not registered, etc. */
                sip_destroy(p);
@@ -4994,29 +4998,29 @@ static void *do_monitor(void *data)
        /* From here on out, we die whenever asked */
        for(;;) {
                /* Check for interfaces needing to be killed */
-               ast_pthread_mutex_lock(&iflock);
+               ast_mutex_lock(&iflock);
 restartsearch:         
                sip = iflist;
                while(sip) {
-                       ast_pthread_mutex_lock(&sip->lock);
+                       ast_mutex_lock(&sip->lock);
                        if (sip->needdestroy && !sip->packets) {
-                               ast_pthread_mutex_unlock(&sip->lock);
+                               ast_mutex_unlock(&sip->lock);
                                __sip_destroy(sip, 1);
                                goto restartsearch;
                        }
-                       ast_pthread_mutex_unlock(&sip->lock);
+                       ast_mutex_unlock(&sip->lock);
                        sip = sip->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
                /* 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);
                /* 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);
@@ -5026,10 +5030,10 @@ restartsearch:
                if (fastrestart)
                        res = 1;
                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_lock(&peerl.lock);
+               ast_mutex_lock(&peerl.lock);
                peer = peerl.peers;
                time(&t);
                fastrestart = 0;
@@ -5048,9 +5052,9 @@ restartsearch:
                if (!peer) {
                        /* Reset where we come from */
                        lastpeernum = -1;
-                       ast_pthread_mutex_unlock(&peerl.lock);
+                       ast_mutex_unlock(&peerl.lock);
                }
-               ast_pthread_mutex_unlock(&monlock);
+               ast_mutex_unlock(&monlock);
        }
        /* Never reached */
        return NULL;
@@ -5062,12 +5066,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;
        }
@@ -5077,12 +5081,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;
 }
 
@@ -5176,7 +5180,7 @@ static int sip_devicestate(void *data)
                ext = NULL;
        }
 
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        p = peerl.peers;
        while (p) {
                if (!strcasecmp(p->name, host)) {
@@ -5191,7 +5195,7 @@ static int sip_devicestate(void *data)
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        if (!p && !found) {
                hp = gethostbyname(host);
                if (hp)
@@ -5344,7 +5348,7 @@ static struct sip_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)) {    
@@ -5361,9 +5365,9 @@ static struct sip_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 sip_peer));
                memset(peer, 0, sizeof(struct sip_peer));
                peer->expire = -1;
@@ -5637,19 +5641,19 @@ static int reload_config(void)
                                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, "sip.conf");
@@ -5673,7 +5677,7 @@ static int reload_config(void)
        if (!ntohs(bindaddr.sin_port))
                bindaddr.sin_port = ntohs(DEFAULT_SIP_PORT);
        bindaddr.sin_family = AF_INET;
-       pthread_mutex_lock(&netlock);
+       ast_mutex_lock(&netlock);
        if ((sipsock > -1) && (ntohs(bindaddr.sin_port) != oldport)) {
                close(sipsock);
                sipsock = -1;
@@ -5706,7 +5710,7 @@ static int reload_config(void)
                        }
                }
        }
-       pthread_mutex_unlock(&netlock);
+       ast_mutex_unlock(&netlock);
 
        ast_destroy(cfg);
        return 0;
@@ -5787,14 +5791,14 @@ int load_module()
                        ast_log(LOG_WARNING, "Unable to create I/O context\n");
                }
        
-               ast_pthread_mutex_lock(&peerl.lock);
+               ast_mutex_lock(&peerl.lock);
                for (peer = peerl.peers; peer; peer = peer->next)
                        sip_poke_peer(peer);
 
                for (reg = registrations; reg; reg = reg->next) 
                        sip_do_register(reg);
 
-               ast_pthread_mutex_unlock(&peerl.lock);
+               ast_mutex_unlock(&peerl.lock);
                
                /* And start the monitor for the first time */
                restart_monitor();
@@ -5809,7 +5813,7 @@ static void delete_users(void)
        struct sip_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);
                userlast = user;
@@ -5817,7 +5821,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;
@@ -5827,20 +5831,20 @@ 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 sip_peer *peer, *peerlast, *peernext;
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        peerlast = NULL;
        for (peer=peerl.peers;peer;) {
                peernext = peer->next;
@@ -5861,7 +5865,7 @@ static void prune_peers(void)
                        peerlast = peer;
                peer=peernext;
        }
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
 }
 
 int reload(void)
@@ -5876,10 +5880,10 @@ int reload(void)
        restart_monitor();
        for (reg = registrations; reg; reg = reg->next) 
                sip_do_register(reg);
-       ast_pthread_mutex_lock(&peerl.lock);
+       ast_mutex_lock(&peerl.lock);
        for (peer = peerl.peers; peer; peer = peer->next)
                sip_poke_peer(peer);
-       ast_pthread_mutex_unlock(&peerl.lock);
+       ast_mutex_unlock(&peerl.lock);
        return 0;
 }
 
@@ -5889,7 +5893,7 @@ int unload_module()
        
        /* 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) {
@@ -5898,25 +5902,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) {
@@ -5926,7 +5930,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;
@@ -5938,9 +5942,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 4cbc71f2b901de3a2e8cb70f8c301ad590e5dc6b..37d8a1f525466d0124c78bd0acef8e04ba5787ea 100755 (executable)
@@ -53,14 +53,14 @@ static char context[AST_MAX_EXTENSION] = "default";
 static char language[MAX_LANGUAGE] = "";
 
 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 vofr_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.  */
@@ -457,11 +457,11 @@ static int vofr_hangup(struct ast_channel *ast)
        ast->state = AST_STATE_DOWN;
        ((struct vofr_pvt *)(ast->pvt->pvt))->owner = NULL;
        ((struct vofr_pvt *)(ast->pvt->pvt))->ringgothangup = 0;
-       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);
@@ -826,9 +826,9 @@ static struct ast_channel *vofr_new(struct vofr_pvt *i, int state)
                if (strlen(i->language))
                        strncpy(tmp->language, i->language, sizeof(tmp->language)-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();
                strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
                if (state != AST_STATE_DOWN) {
@@ -916,14 +916,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
@@ -947,10 +947,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);
                pthread_testcancel();
                /* Wait indefinitely for something to happen */
                res = ast_select(n + 1, &rfds, NULL, NULL, NULL);
@@ -963,7 +963,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;
                }
@@ -987,7 +987,7 @@ static void *do_monitor(void *data)
                        }
                        i=i->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        }
        /* Never reached */
        return NULL;
@@ -999,12 +999,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;
        }
@@ -1014,12 +1014,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;
 }
 
@@ -1119,7 +1119,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data)
                return NULL;
        }
        /* 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;
        }
@@ -1131,7 +1131,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data)
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        restart_monitor();
        return tmp;
 }
@@ -1148,7 +1148,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;
@@ -1165,7 +1165,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;
                                }
@@ -1176,7 +1176,7 @@ int load_module()
                }
                v = v->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        /* Make sure we can register our AdtranVoFR channel type */
        if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -1195,7 +1195,7 @@ int unload_module()
        struct vofr_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) {
@@ -1204,25 +1204,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) {
@@ -1235,7 +1235,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;
@@ -1247,9 +1247,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 7c7353bab2a5172013af6a97cc78f4fb9a6f4046..74f6c4ea8d0805d2132ebc7deb2348565adb8797 100755 (executable)
@@ -71,14 +71,14 @@ static int silencesupression = 0;
 
 static const int prefformat = AST_FORMAT_ALAW | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ADPCM;
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 /* Protect the interface list (of vpb_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.  */
@@ -110,11 +110,11 @@ static struct vpb_bridge_t {
      struct ast_frame **fo;
      int flags;
      
-     pthread_mutex_t lock;
+     ast_mutex_t lock;
      pthread_cond_t cond;
 } bridges[VPB_MAX_BRIDGES]; /* Bridges...*/
 
-static pthread_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
 
 static struct vpb_pvt {
 
@@ -148,7 +148,7 @@ static struct vpb_pvt {
     
      int lastgrunt;
 
-     pthread_mutex_t lock;
+     ast_mutex_t lock;
 
     int stopreads; /* Stop reading...*/
      pthread_t readthread;    /* For monitoring read channel. One per owned channel. */
@@ -166,7 +166,7 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
      
      /* Bridge channels, check if we can.  I believe we always can, so find a slot.*/
      
-     ast_pthread_mutex_lock(&bridge_lock); {
+     ast_mutex_lock(&bridge_lock); {
          for (i = 0; i < len; i++) 
               if (!bridges[i].inuse)
                    break;
@@ -180,7 +180,7 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
               pthread_mutex_init(&bridges[i].lock, NULL);
               pthread_cond_init(&bridges[i].cond, NULL);
          }            
-     } ast_pthread_mutex_unlock(&bridge_lock); 
+     } ast_mutex_unlock(&bridge_lock); 
 
      if (i == len) {
          ast_log(LOG_WARNING, "Failed to bridge %s and %s!\n", c0->name, c1->name);
@@ -188,13 +188,13 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
      } else {
 
          /* Set bridge pointers. You don't want to take these locks while holding bridge lock.*/
-         ast_pthread_mutex_lock(&p0->lock); {
+         ast_mutex_lock(&p0->lock); {
               p0->bridge = &bridges[i];
-         } ast_pthread_mutex_unlock(&p0->lock);
+         } ast_mutex_unlock(&p0->lock);
 
-         ast_pthread_mutex_lock(&p1->lock); {
+         ast_mutex_lock(&p1->lock); {
               p1->bridge = &bridges[i];
-         } ast_pthread_mutex_unlock(&p1->lock);
+         } ast_mutex_unlock(&p1->lock);
 
          if (option_verbose > 4) 
               ast_verbose(VERBOSE_PREFIX_3 
@@ -213,19 +213,19 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
      vpb_bridge(p0->handle, p1->handle, VPB_BRIDGE_OFF, 0); 
 
      
-     ast_pthread_mutex_lock(&bridge_lock); {
+     ast_mutex_lock(&bridge_lock); {
          bridges[i].inuse = 0;
          pthread_mutex_destroy(&bridges[i].lock);
          pthread_cond_destroy(&bridges[i].cond);       
-     } ast_pthread_mutex_unlock(&bridge_lock); 
+     } ast_mutex_unlock(&bridge_lock); 
      
-     ast_pthread_mutex_lock(&p0->lock); {
+     ast_mutex_lock(&p0->lock); {
          p0->bridge = NULL;
-     } ast_pthread_mutex_unlock(&p0->lock);
+     } ast_mutex_unlock(&p0->lock);
      
-     ast_pthread_mutex_lock(&p1->lock); {
+     ast_mutex_lock(&p1->lock); {
          p1->bridge = NULL;
-     } ast_pthread_mutex_unlock(&p1->lock);
+     } ast_mutex_unlock(&p1->lock);
 
      
      if (option_verbose > 4) 
@@ -318,7 +318,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
          ast_verbose(VERBOSE_PREFIX_3 " handle_owned: putting frame: [%d=>%d], bridge=%p\n",
                      f.frametype, f.subclass, (void *)p->bridge);
 
-     ast_pthread_mutex_lock(&p->lock); {
+     ast_mutex_lock(&p->lock); {
          if (p->bridge) { /* Check what happened, see if we need to report it. */
               switch (f.frametype) { 
               case AST_FRAME_DTMF:
@@ -350,12 +350,12 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
                    if (p->bridge->rc)
                         *p->bridge->rc = p->owner;
                    
-                   ast_pthread_mutex_lock(&p->bridge->lock); {
+                   ast_mutex_lock(&p->bridge->lock); {
                         pthread_cond_signal(&p->bridge->cond);
-                   } ast_pthread_mutex_unlock(&p->bridge->lock);                          
+                   } ast_mutex_unlock(&p->bridge->lock);                          
               }          
          }
-     } ast_pthread_mutex_unlock(&p->lock);
+     } ast_mutex_unlock(&p->lock);
      
      if (endbridge) return 0;
      
@@ -450,8 +450,8 @@ static void *do_monitor(void *unused)
               goto end_loop;
          
          str[0] = 0;
-         ast_pthread_mutex_lock(&monlock),
-              ast_pthread_mutex_lock(&iflock); {
+         ast_mutex_lock(&monlock),
+              ast_mutex_lock(&iflock); {
               struct vpb_pvt *p = iflist; /* Find the pvt structure */       
                
               vpb_translate_event(&e, str);
@@ -480,8 +480,8 @@ static void *do_monitor(void *unused)
                    monitor_handle_notowned(p, &e);
               
               done: (void)0;
-         } ast_pthread_mutex_unlock(&iflock);
-         ast_pthread_mutex_unlock(&monlock);
+         } ast_mutex_unlock(&iflock);
+         ast_mutex_unlock(&monlock);
          
      end_loop:
          tcounter += VPB_WAIT_TIMEOUT; /* Ok, not quite but will suffice. */
@@ -499,7 +499,7 @@ static int restart_monitor(void)
      /* If we're supposed to be stopped -- stay stopped */
      if (mthreadactive == -2)
          return 0;
-     ast_pthread_mutex_lock(&monlock); {
+     ast_mutex_lock(&monlock); {
          if (monitor_thread == pthread_self()) {
               ast_log(LOG_WARNING, "Cannot kill myself\n");
               error = -1;
@@ -531,7 +531,7 @@ static int restart_monitor(void)
 #endif
          }
      done: (void)0;
-     } ast_pthread_mutex_unlock(&monlock);
+     } ast_mutex_unlock(&monlock);
      
      return error;
 }
@@ -744,18 +744,18 @@ static int vpb_hangup(struct ast_channel *ast)
 
     ast_setstate(ast,AST_STATE_DOWN);
     
-    ast_pthread_mutex_lock(&p->lock); {    
+    ast_mutex_lock(&p->lock); {    
         p->lastinput = p->lastoutput  = -1;
         p->ext[0]  = 0;
         p->owner = NULL;
         p->dialtone = 0;
         p->calling = 0;
         ast->pvt->pvt = NULL;   
-    } ast_pthread_mutex_unlock(&p->lock);
+    } ast_mutex_unlock(&p->lock);
         
-    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();
 
     /* Stop thread doing reads. */
@@ -913,7 +913,7 @@ static void *do_chanreads(void *pvt)
             p->lastinput = fmt;
         } 
 
-        ast_pthread_mutex_lock(&p->lock); {
+        ast_mutex_lock(&p->lock); {
              if (p->bridge) 
                   if (p->bridge->c0 == p->owner && 
                       (p->bridge->flags & AST_BRIDGE_REC_CHANNEL_0))
@@ -925,7 +925,7 @@ static void *do_chanreads(void *pvt)
                        bridgerec = 0;
              else
                   bridgerec = 1;
-        } ast_pthread_mutex_unlock(&p->lock);
+        } ast_mutex_unlock(&p->lock);
         
         if (state == AST_STATE_UP && bridgerec) {  
              /* Read only if up and not bridged, or a bridge for which we can read. */
@@ -941,9 +941,9 @@ static void *do_chanreads(void *pvt)
              fr->datalen = readlen;
              fr->offset = AST_FRIENDLY_OFFSET;
 
-             ast_pthread_mutex_lock(&p->lock); {    
+             ast_mutex_lock(&p->lock); {    
                   if (p->owner) ast_queue_frame(p->owner, fr, 0);
-             } ast_pthread_mutex_unlock(&p->lock);
+             } ast_mutex_unlock(&p->lock);
         } else 
              p->stopreads = 1;
                 
@@ -1009,9 +1009,9 @@ static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context)
                i->lastinput = i->lastoutput = -1;
                i->lastgrunt  = tcounter; /* Assume at least one grunt tone seen now. */
 
-               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)) {
@@ -1047,7 +1047,7 @@ static struct ast_channel *vpb_request(char *type, int format, void *data)
      if (!s) 
          s = "";
      /* Search for an unowned channel */
-     ast_pthread_mutex_lock(&iflock); {
+     ast_mutex_lock(&iflock); {
          p = iflist;
          while(p) {
               if (strncmp(s, p->dev + 4, sizeof p->dev) == 0) 
@@ -1057,7 +1057,7 @@ static struct ast_channel *vpb_request(char *type, int format, void *data)
                    }
               p = p->next;
          }
-     } ast_pthread_mutex_unlock(&iflock);
+     } ast_mutex_unlock(&iflock);
 
 
      if (option_verbose > 2) 
@@ -1114,7 +1114,7 @@ int load_module()
        
        vpb_seterrormode(VPB_DEVELOPMENT);
        
-       ast_pthread_mutex_lock(&iflock); {
+       ast_mutex_lock(&iflock); {
             v = ast_variable_browse(cfg, "interfaces");
             while(v) {
                  /* Create the interface list */
@@ -1176,7 +1176,7 @@ int load_module()
                  gruntdetect_timeout = 1000;
 
        done: (void)0;
-       } ast_pthread_mutex_unlock(&iflock);
+       } ast_mutex_unlock(&iflock);
 
        
        ast_destroy(cfg);
@@ -1205,7 +1205,7 @@ int unload_module()
        /* First, take us out of the channel loop */
        ast_channel_unregister(type);
 
-       ast_pthread_mutex_lock(&iflock); {
+       ast_mutex_lock(&iflock); {
             /* Hangup all interfaces if they have an owner */
             p = iflist;
             while(p) {
@@ -1214,17 +1214,17 @@ int unload_module()
                  p = p->next;
             }
             iflist = NULL;
-       } ast_pthread_mutex_unlock(&iflock);
+       } ast_mutex_unlock(&iflock);
 
-       ast_pthread_mutex_lock(&monlock); {
+       ast_mutex_lock(&monlock); {
             if (mthreadactive > -1) {
                  pthread_cancel(monitor_thread);
                  pthread_join(monitor_thread, NULL);
             }
             mthreadactive = -2;
-       } ast_pthread_mutex_unlock(&monlock);
+       } ast_mutex_unlock(&monlock);
 
-       ast_pthread_mutex_lock(&iflock); {
+       ast_mutex_lock(&iflock); {
                /* Destroy all the interfaces and free their memory */
 
                while(iflist) {
@@ -1238,11 +1238,11 @@ int unload_module()
                     free(p);
                }
                iflist = NULL;
-       } ast_pthread_mutex_unlock(&iflock);
+       } ast_mutex_unlock(&iflock);
        
-       ast_pthread_mutex_lock(&bridge_lock); {
+       ast_mutex_lock(&bridge_lock); {
             memset(bridges, 0, sizeof bridges);             
-       } ast_pthread_mutex_unlock(&bridge_lock);
+       } ast_mutex_unlock(&bridge_lock);
        pthread_mutex_destroy(&bridge_lock);
 
        tcounter = 0;
@@ -1253,9 +1253,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 382890e054566ed16609d2f1f080f557c28254c0..09a2db606394dc5ff527567f4972e516368b33a9 100755 (executable)
@@ -200,14 +200,14 @@ static int gendigittimeout = 8000;
 static int matchdigittimeout = 3000;
 
 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 zt_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.  */
@@ -260,7 +260,7 @@ static int r2prot = -1;
 #ifdef ZAPATA_PRI
 struct zt_pri {
        pthread_t master;                       /* Thread of master */
-       pthread_mutex_t lock;           /* Mutex */
+       ast_mutex_t lock;               /* Mutex */
        char idleext[AST_MAX_EXTENSION];                /* Where to idle extra calls */
        char idlecontext[AST_MAX_EXTENSION];            /* What context to use for idle */
        char idledial[AST_MAX_EXTENSION];               /* What to dial before dumping */
@@ -299,7 +299,7 @@ static int pritype = PRI_CPE;
 
 static inline void pri_rel(struct zt_pri *pri)
 {
-       ast_pthread_mutex_unlock(&pri->lock);
+       ast_mutex_unlock(&pri->lock);
 }
 
 static int switchtype = PRI_SWITCH_NI2;
@@ -337,7 +337,7 @@ struct zt_subchannel {
 #define MAX_SLAVES     4
 
 static struct zt_pvt {
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
        struct ast_channel *owner;      /* Our current active owner (if applicable) */
                /* Up to three channels can be associated with this call */
                
@@ -457,12 +457,12 @@ static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
        int res;
        /* Grab the lock first */
        do {
-           res = pthread_mutex_trylock(&pri->lock);
+           res = ast_mutex_trylock(&pri->lock);
                if (res) {
-                       ast_pthread_mutex_unlock(&pvt->lock);
+                       ast_mutex_unlock(&pvt->lock);
                        /* Release the lock and try again */
                        usleep(1);
-                       ast_pthread_mutex_lock(&pvt->lock);
+                       ast_mutex_lock(&pvt->lock);
                }
        } while(res);
        /* Then break the select */
@@ -1490,7 +1490,7 @@ static int zt_hangup(struct ast_channel *ast)
                return 0;
        }
        
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        
        index = zt_get_index(ast, p, 1);
 
@@ -1726,17 +1726,17 @@ static int zt_hangup(struct ast_channel *ast)
        p->callwaitingrepeat = 0;
        p->cidcwexpire = 0;
        ast->pvt->pvt = NULL;
-       ast_pthread_mutex_unlock(&p->lock);
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_unlock(&p->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);
 
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        tmp = iflist;
        prev = NULL;
        if (p->destroy) {
@@ -1750,7 +1750,7 @@ static int zt_hangup(struct ast_channel *ast)
                        }
                }
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return 0;
 }
 
@@ -1761,13 +1761,13 @@ static int zt_answer(struct ast_channel *ast)
        int index;
        int oldstate = ast->_state;
        ast_setstate(ast, AST_STATE_UP);
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        index = zt_get_index(ast, p, 0);
        if (index < 0)
                index = SUB_REAL;
        /* nothing to do if a radio channel */
        if (p->radio) {
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return 0;
        }
        switch(p->sig) {
@@ -1823,13 +1823,13 @@ static int zt_answer(struct ast_channel *ast)
                break;
 #endif                 
        case 0:
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return 0;
        default:
                ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
                res = -1;
        }
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return res;
 }
 
@@ -2061,8 +2061,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        /* cant do pseudo-channels here */
        if ((!p0->sig) || (!p1->sig)) return -2;
                
-       ast_pthread_mutex_lock(&c0->lock);
-       ast_pthread_mutex_lock(&c1->lock);
+       ast_mutex_lock(&c0->lock);
+       ast_mutex_lock(&c1->lock);
        op0 = p0 = c0->pvt->pvt;
        op1 = p1 = c1->pvt->pvt;
        ofd1 = c0->fds[0];
@@ -2076,12 +2076,12 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
 
 
 
-       ast_pthread_mutex_lock(&p0->lock);
-       if (pthread_mutex_trylock(&p1->lock)) {
+       ast_mutex_lock(&p0->lock);
+       if (ast_mutex_trylock(&p1->lock)) {
                /* Don't block, due to potential for deadlock */
-               ast_pthread_mutex_unlock(&p0->lock);
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&p0->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
                return -3;
        }
@@ -2184,11 +2184,11 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        t1 = p0->subs[SUB_REAL].inthreeway;
        t2 = p1->subs[SUB_REAL].inthreeway;
 
-       ast_pthread_mutex_unlock(&p0->lock);
-       ast_pthread_mutex_unlock(&p1->lock);
+       ast_mutex_unlock(&p0->lock);
+       ast_mutex_unlock(&p1->lock);
 
-       ast_pthread_mutex_unlock(&c0->lock);
-       ast_pthread_mutex_unlock(&c1->lock);
+       ast_mutex_unlock(&c0->lock);
+       ast_mutex_unlock(&c1->lock);
 
        /* Native bridge failed */
        if ((!master || !slave) && !nothingok) {
@@ -2205,16 +2205,16 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        for (;;) {
                /* Here's our main loop...  Start by locking things, looking for private parts, 
                   and then balking if anything is wrong */
-               ast_pthread_mutex_lock(&c0->lock);
-               ast_pthread_mutex_lock(&c1->lock);
+               ast_mutex_lock(&c0->lock);
+               ast_mutex_lock(&c1->lock);
                p0 = c0->pvt->pvt;
                p1 = c1->pvt->pvt;
                if (op0 == p0)
                        i1 = zt_get_index(c0, p0, 1);
                if (op1 == p1)
                        i2 = zt_get_index(c1, p1, 1);
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                if ((op0 != p0) || (op1 != p1) || 
                    (ofd1 != c0->fds[0]) || 
                        (ofd2 != c1->fds[0]) ||
@@ -2984,7 +2984,7 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
        int index;
        struct ast_frame *f;
 
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
 
        index = zt_get_index(ast, p, 1);
        
@@ -3062,7 +3062,7 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
                        ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", event2str(res));
                }
                f = &p->subs[index].f;
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return f;
        }
        if (!p->radio) ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
@@ -3070,11 +3070,11 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
        if (ast != p->owner) {
                ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
                f = &p->subs[index].f;
-               ast_pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return f;
        }
        f = zt_handle_event(ast);
-       ast_pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return f;
 }
 
@@ -3087,7 +3087,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
        struct ast_frame *f;
        
 
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        
        index = zt_get_index(ast, p, 0);
        
@@ -3103,7 +3103,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
        /* Hang up if we don't really exist */
        if (index < 0)  {
                ast_log(LOG_WARNING, "We dont exist?\n");
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        
@@ -3125,11 +3125,11 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                {
                        p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
                }
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }
        if (p->ringt == 1) {
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        else if (p->ringt > 0) 
@@ -3141,7 +3141,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                p->subs[index].f.frametype = AST_FRAME_CONTROL;
                p->subs[index].f.subclass = AST_CONTROL_RINGING;
                ast_setstate(ast, AST_STATE_RINGING);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }
 
@@ -3156,7 +3156,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                p->subs[index].f.frametype = AST_FRAME_CONTROL;
                p->subs[index].f.subclass = AST_CONTROL_ANSWER;
                ast_setstate(ast, AST_STATE_UP);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }       
        
@@ -3177,7 +3177,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                }
        } else {
                ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
@@ -3189,18 +3189,18 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                if (res == -1)  {
                        if (errno == EAGAIN) {
                                /* Return "NULL" frame if there is nobody there */
-                               pthread_mutex_unlock(&p->lock);
+                               ast_mutex_unlock(&p->lock);
                                return &p->subs[index].f;
                        } else
                                ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
                }
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
                ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
                f = zt_handle_event(ast);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return f;
        }
        if (p->tdd) { /* if in TDD mode, see if we receive that */
@@ -3219,7 +3219,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                        p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
                        p->subs[index].f.datalen = 1;
                        *((char *) p->subs[index].f.data) = c;
-                       pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        return &p->subs[index].f;
                }
        }
@@ -3354,7 +3354,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                f = &p->subs[index].f;
        }
 #endif 
-       pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return f;
 }
 
@@ -3621,9 +3621,9 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
                }
                i->subs[index].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();
                strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
                /* Copy call forward info */
@@ -4484,7 +4484,7 @@ static void *do_monitor(void *data)
 #endif
        for(;;) {
                /* 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");
                        return NULL;
                }
@@ -4515,7 +4515,7 @@ 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);
                
                pthread_testcancel();
                /* Wait at least a second for something to happen */
@@ -4531,7 +4531,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;
                }
@@ -4649,7 +4649,7 @@ static void *do_monitor(void *data)
                        }
                        i=i->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        }
        /* Never reached */
        return NULL;
@@ -4664,12 +4664,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;
        }
@@ -4685,7 +4685,7 @@ static int restart_monitor(void)
        } else {
                /* Start a new monitor */
                if (pthread_create(&monitor_thread, &attr, 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;
                }
@@ -4693,7 +4693,7 @@ static int restart_monitor(void)
 #if 0
        printf("Created thread %ld detached in restart monitor\n", monitor_thread);
 #endif
-       ast_pthread_mutex_unlock(&monlock);
+       ast_mutex_unlock(&monlock);
        return 0;
 }
 
@@ -5006,7 +5006,7 @@ static struct zt_pvt *mkintf(int channel, int signalling, int radio)
                        tmp->propconfno = -1;
                }
                tmp->transfer = transfer;
-               ast_pthread_mutex_init(&tmp->lock);
+               ast_mutex_init(&tmp->lock);
                strncpy(tmp->language, language, sizeof(tmp->language)-1);
                strncpy(tmp->musicclass, musicclass, sizeof(tmp->musicclass)-1);
                strncpy(tmp->context, context, sizeof(tmp->context)-1);
@@ -5211,7 +5211,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
                channelmatch = x;
        }
        /* 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;
        }
@@ -5270,7 +5270,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
                else
                        p = p->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        restart_monitor();
        return tmp;
 }
@@ -5457,7 +5457,7 @@ static void *pri_dchannel(void *vpri)
                FD_SET(pri->fd, &rfds);
                FD_SET(pri->fd, &efds);
                time(&t);
-               ast_pthread_mutex_lock(&pri->lock);
+               ast_mutex_lock(&pri->lock);
                if (pri->resetting && pri->up) {
                        if (!pri->resetchannel)
                                pri_check_restart(pri);
@@ -5561,12 +5561,12 @@ static void *pri_dchannel(void *vpri)
                        tv.tv_sec = 60;
                        tv.tv_usec = 0;
                }
-               pthread_mutex_unlock(&pri->lock);
+               ast_mutex_unlock(&pri->lock);
 
                e = NULL;
                res = ast_select(pri->fd + 1, &rfds, NULL, &efds, &tv);
 
-               ast_pthread_mutex_lock(&pri->lock);
+               ast_mutex_lock(&pri->lock);
                if (!res) {
                        /* Just a timeout, run the scheduler */
                        e = pri_schedule_run(pri->pri);
@@ -5606,21 +5606,21 @@ static void *pri_dchannel(void *vpri)
                                                if (option_verbose > 2)
                                                        ast_verbose(VERBOSE_PREFIX_3 "B-channel %d restarted on span %d\n", 
                                                                chan, pri->span);
-                                               ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+                                               ast_mutex_lock(&pri->pvt[chan]->lock);
                                                /* Force soft hangup if appropriate */
                                                if (pri->pvt[chan]->owner)
                                                        pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-                                               ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+                                               ast_mutex_unlock(&pri->pvt[chan]->lock);
                                        }
                                } else {
                                        if (option_verbose > 2)
                                                ast_verbose(VERBOSE_PREFIX_2 "Restart on requested on entire span %d\n", pri->span);
                                        for (x=1;x <= pri->channels;x++)
                                                if ((x != pri->dchannel) && pri->pvt[x]) {
-                                                       ast_pthread_mutex_lock(&pri->pvt[x]->lock);
+                                                       ast_mutex_lock(&pri->pvt[x]->lock);
                                                        if (pri->pvt[x]->owner)
                                                                pri->pvt[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-                                                       ast_pthread_mutex_unlock(&pri->pvt[x]->lock);
+                                                       ast_mutex_unlock(&pri->pvt[x]->lock);
                                                }
                                }
                                break;
@@ -5876,7 +5876,7 @@ static void *pri_dchannel(void *vpri)
                                if (chan) {
                                        chan = pri_fixup(pri, chan, e->hangup.call);
                                        if (chan) {
-                                               ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+                                               ast_mutex_lock(&pri->pvt[chan]->lock);
                                                if (!pri->pvt[chan]->alreadyhungup) {
                                                        /* we're calling here zt_hangup so once we get there we need to clear p->call after calling pri_hangup */
                                                        pri->pvt[chan]->alreadyhungup = 1;
@@ -5894,7 +5894,7 @@ static void *pri_dchannel(void *vpri)
                                                        pri_reset(pri->pri, chan);
                                                        pri->pvt[chan]->resetting = 1;
                                                }
-                                               ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+                                               ast_mutex_unlock(&pri->pvt[chan]->lock);
                                        } else {
                                                ast_log(LOG_WARNING, "Hangup on bad channel %d\n", e->hangup.channel);
                                        }
@@ -5915,7 +5915,7 @@ static void *pri_dchannel(void *vpri)
                                if (chan) {
                                        chan = pri_fixup(pri, chan, e->hangup.call);
                                        if (chan) {
-                                               ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+                                               ast_mutex_lock(&pri->pvt[chan]->lock);
                                                if (pri->pvt[chan]->owner) {
                                                        pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                        if (option_verbose > 2) 
@@ -5927,7 +5927,7 @@ static void *pri_dchannel(void *vpri)
                                                        pri_reset(pri->pri, chan);
                                                        pri->pvt[chan]->resetting = 1;
                                                }
-                                               ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+                                               ast_mutex_unlock(&pri->pvt[chan]->lock);
                                        } else {
                                                ast_log(LOG_WARNING, "Hangup REQ on bad channel %d\n", e->hangup.channel);
                                        }
@@ -5945,14 +5945,14 @@ static void *pri_dchannel(void *vpri)
                                if (chan) {
                                        chan = pri_fixup(pri, chan, e->hangup.call);
                                        if (chan) {
-                                               ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+                                               ast_mutex_lock(&pri->pvt[chan]->lock);
                                                pri->pvt[chan]->call = NULL;
                                                pri->pvt[chan]->resetting = 0;
                                                if (pri->pvt[chan]->owner) {
                                                        if (option_verbose > 2) 
                                                                ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup ACK\n", chan, pri->span);
                                                }
-                                               ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+                                               ast_mutex_unlock(&pri->pvt[chan]->lock);
                                        }
                                }
                                break;
@@ -5968,7 +5968,7 @@ static void *pri_dchannel(void *vpri)
                                        for (x=1;x<=pri->channels;x++) {
                                                if (pri->pvt[x] && pri->pvt[x]->resetting) {
                                                        chan = x;
-                                                       ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+                                                       ast_mutex_lock(&pri->pvt[chan]->lock);
                                                        ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d span %d\n", chan, pri->span);
                                                        if (pri->pvt[chan]->owner) {
                                                                ast_log(LOG_WARNING, "Got restart ack on channel %d with owner\n", chan);
@@ -5977,7 +5977,7 @@ static void *pri_dchannel(void *vpri)
                                                        pri->pvt[chan]->resetting = 0;
                                                        if (option_verbose > 2)
                                                                ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span);
-                                                       ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+                                                       ast_mutex_unlock(&pri->pvt[chan]->lock);
                                                        if (pri->resetting)
                                                                pri_check_restart(pri);
                                                        break;
@@ -5993,7 +5993,7 @@ static void *pri_dchannel(void *vpri)
                                }
                                if ((chan >= 1) && (chan <= pri->channels)) {
                                        if (pri->pvt[chan]) {
-                                               ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+                                               ast_mutex_lock(&pri->pvt[chan]->lock);
                                                if (pri->pvt[chan]->owner) {
                                                        ast_log(LOG_WARNING, "Got restart ack on channel %d with owner\n", chan);
                                                        pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -6001,7 +6001,7 @@ static void *pri_dchannel(void *vpri)
                                                pri->pvt[chan]->resetting = 0;
                                                if (option_verbose > 2)
                                                        ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span);
-                                               ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+                                               ast_mutex_unlock(&pri->pvt[chan]->lock);
                                                if (pri->resetting)
                                                        pri_check_restart(pri);
                                        }
@@ -6031,7 +6031,7 @@ static void *pri_dchannel(void *vpri)
                        if (option_debug)
                                ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
                }
-               pthread_mutex_unlock(&pri->lock);
+               ast_mutex_unlock(&pri->lock);
        }
        /* Never reached */
        return NULL;
@@ -6302,7 +6302,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
        if (argc != 3)
                return RESULT_SHOWUSAGE;
 
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        ast_cli(fd, FORMAT2, "Chan. Num.", "Extension", "Context", "Language", "MusicOnHold");
        
        tmp = iflist;
@@ -6310,7 +6310,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
                ast_cli(fd, FORMAT, tmp->channel, tmp->exten, tmp->context, tmp->language, tmp->musicclass);
                tmp = tmp->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -6327,7 +6327,7 @@ static int zap_show_channel(int fd, int argc, char **argv)
                return RESULT_SHOWUSAGE;
        channel = atoi(argv[3]);
 
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        tmp = iflist;
        while (tmp) {
                if (tmp->channel == channel) {
@@ -6392,14 +6392,14 @@ static int zap_show_channel(int fd, int argc, char **argv)
                                ast_cli(fd, "Actual Confmute: %s\n", x ? "Yes" : "No");
                        }
 #endif
-                       ast_pthread_mutex_unlock(&iflock);
+                       ast_mutex_unlock(&iflock);
                        return RESULT_SUCCESS;
                }
                tmp = tmp->next;
        }
        
        ast_cli(fd, "Unable to find given channel %d\n", channel);
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return RESULT_FAILURE;
 }
 
@@ -6457,7 +6457,7 @@ int load_module()
        }
        
 
-       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;
@@ -6469,7 +6469,7 @@ int load_module()
                        if (cur_signalling < 0) {
                                ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                unload_module();
                                return -1;
                        }
@@ -6486,7 +6486,7 @@ int load_module()
                                } else {
                                        ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
                                        ast_destroy(cfg);
-                                       ast_pthread_mutex_unlock(&iflock);
+                                       ast_mutex_unlock(&iflock);
                                        unload_module();
                                        return -1;
                                }
@@ -6504,7 +6504,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;
                                        }
@@ -6738,7 +6738,7 @@ int load_module()
                        else {
                                ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                unload_module();
                                return -1;
                        }
@@ -6755,7 +6755,7 @@ int load_module()
                        ast_log(LOG_WARNING, "Ignoring %s\n", v->name);
                v = v->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        /* Make sure we can register our Zap channel type */
        if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR |  AST_FORMAT_ULAW, zt_request)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -6814,7 +6814,7 @@ int unload_module()
        ast_cli_unregister(&cli_show_channels);
        ast_cli_unregister(&cli_show_channel);
        ast_cli_unregister(&cli_destroy_channel);
-       if (!ast_pthread_mutex_lock(&iflock)) {
+       if (!ast_mutex_lock(&iflock)) {
                /* Hangup all interfaces if they have an owner */
                p = iflist;
                while(p) {
@@ -6823,25 +6823,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) {
@@ -6857,7 +6857,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;
@@ -6937,7 +6937,7 @@ static int reload_zt(void)
        }
        
 
-       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;
@@ -6959,7 +6959,7 @@ static int reload_zt(void)
                        if (cur_signalling < 0) {
                                ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                return -1;
                        }
                        stringp=v->value;
@@ -6973,7 +6973,7 @@ static int reload_zt(void)
                                } else {
                                        ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
                                        ast_destroy(cfg);
-                                       ast_pthread_mutex_unlock(&iflock);
+                                       ast_mutex_unlock(&iflock);
                                        return -1;
                                }
                                if (finish < start) {
@@ -6990,7 +6990,7 @@ static int reload_zt(void)
                                        } 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);
                                                return -1;
                                        }
                                }
@@ -7094,7 +7094,7 @@ static int reload_zt(void)
                        else {
                                ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                return -1;
                        }
                } else if (!strcasecmp(v->name, "minunused")) {
@@ -7116,7 +7116,7 @@ static int reload_zt(void)
                if (tmp->destroy) {
                        if (destroy_channel(prev, tmp, 0)) {
                                ast_log(LOG_ERROR, "Unable to destroy chan_zap channel %d\n", tmp->channel);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                return -1;
                        }
                        tmp = tmp->next;
@@ -7126,7 +7126,7 @@ static int reload_zt(void)
                }
        }
 
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
 
        ast_destroy(cfg);
 #if 0
@@ -7270,9 +7270,9 @@ int reload(void)
 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 79324cadfc75465db83baad782ebafc913e1c570..c81b6e5c6ed48fdbe00012880ded754b19cd51ae 100755 (executable)
@@ -188,14 +188,14 @@ static int gendigittimeout = 8000;
 static int matchdigittimeout = 3000;
 
 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 zt_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.  */
@@ -245,7 +245,7 @@ static int r2prot = -1;
 #ifdef ZAPATA_PRI
 struct zt_pri {
        pthread_t master;                       /* Thread of master */
-       pthread_mutex_t lock;           /* Mutex */
+       ast_mutex_t lock;               /* Mutex */
        char idleext[AST_MAX_EXTENSION];                /* Where to idle extra calls */
        char idlecontext[AST_MAX_EXTENSION];            /* What context to use for idle */
        char idledial[AST_MAX_EXTENSION];               /* What to dial before dumping */
@@ -285,7 +285,7 @@ static inline int pri_grab(struct zt_pri *pri)
 {
        int res;
        /* Grab the lock first */
-    res = ast_pthread_mutex_lock(&pri->lock);
+    res = ast_mutex_lock(&pri->lock);
        if (res)
                return res;
        /* Then break the select */
@@ -295,7 +295,7 @@ static inline int pri_grab(struct zt_pri *pri)
 
 static inline void pri_rel(struct zt_pri *pri)
 {
-       ast_pthread_mutex_unlock(&pri->lock);
+       ast_mutex_unlock(&pri->lock);
 }
 
 static int switchtype = PRI_SWITCH_NI2;
@@ -334,7 +334,7 @@ struct zt_subchannel {
 #define MAX_SLAVES     4
 
 static struct zt_pvt {
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
        struct ast_channel *owner;      /* Our current active owner (if applicable) */
                /* Up to three channels can be associated with this call */
                
@@ -1502,16 +1502,16 @@ static int zt_hangup(struct ast_channel *ast)
        p->callwaitingrepeat = 0;
        ast->pvt->pvt = NULL;
        ast_setstate(ast, AST_STATE_DOWN);
-       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);
 
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        tmp = iflist;
        prev = NULL;
        if (p->destroy) {
@@ -1525,7 +1525,7 @@ static int zt_hangup(struct ast_channel *ast)
                        }
                }
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return 0;
 }
 
@@ -1809,8 +1809,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        /* cant do pseudo-channels here */
        if ((!p0->sig) || (!p1->sig)) return -2;
 
-       ast_pthread_mutex_lock(&c0->lock);
-       ast_pthread_mutex_lock(&c1->lock);
+       ast_mutex_lock(&c0->lock);
+       ast_mutex_lock(&c1->lock);
        op0 = p0 = c0->pvt->pvt;
        op1 = p1 = c1->pvt->pvt;
        ofd1 = c0->fds[0];
@@ -1824,12 +1824,12 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
 
 
 
-       ast_pthread_mutex_lock(&p0->lock);
-       if (pthread_mutex_trylock(&p1->lock)) {
+       ast_mutex_lock(&p0->lock);
+       if (ast_mutex_trylock(&p1->lock)) {
                /* Don't block, due to potential for deadlock */
-               ast_pthread_mutex_unlock(&p0->lock);
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&p0->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
                return -3;
        }
@@ -1923,11 +1923,11 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        t1 = p0->subs[SUB_REAL].inthreeway;
        t2 = p1->subs[SUB_REAL].inthreeway;
 
-       ast_pthread_mutex_unlock(&p0->lock);
-       ast_pthread_mutex_unlock(&p1->lock);
+       ast_mutex_unlock(&p0->lock);
+       ast_mutex_unlock(&p1->lock);
 
-       ast_pthread_mutex_unlock(&c0->lock);
-       ast_pthread_mutex_unlock(&c1->lock);
+       ast_mutex_unlock(&c0->lock);
+       ast_mutex_unlock(&c1->lock);
 
        /* Native bridge failed */
        if ((!master || !slave) && !nothingok)
@@ -1939,16 +1939,16 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        for (;;) {
                /* Here's our main loop...  Start by locking things, looking for private parts, 
                   and then balking if anything is wrong */
-               ast_pthread_mutex_lock(&c0->lock);
-               ast_pthread_mutex_lock(&c1->lock);
+               ast_mutex_lock(&c0->lock);
+               ast_mutex_lock(&c1->lock);
                p0 = c0->pvt->pvt;
                p1 = c1->pvt->pvt;
                if (op0 == p0)
                        i1 = zt_get_index(c0, p0, 1);
                if (op1 == p1)
                        i2 = zt_get_index(c1, p1, 1);
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                if ((op0 != p0) || (op1 != p1) || 
                    (ofd1 != c0->fds[0]) || 
                        (ofd2 != c1->fds[0]) ||
@@ -2709,7 +2709,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
        struct ast_frame *f;
        
 
-       ast_pthread_mutex_lock(&p->lock);
+       ast_mutex_lock(&p->lock);
        
        index = zt_get_index(ast, p, 0);
        
@@ -2725,7 +2725,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
        /* Hang up if we don't really exist */
        if (index < 0)  {
                ast_log(LOG_WARNING, "We dont exist?\n");
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        
@@ -2747,11 +2747,11 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                {
                        p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
                }
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }
        if (p->ringt == 1) {
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        else if (p->ringt > 0) 
@@ -2763,7 +2763,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                p->subs[index].f.frametype = AST_FRAME_CONTROL;
                p->subs[index].f.subclass = AST_CONTROL_RINGING;
                ast_setstate(ast, AST_STATE_RINGING);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }
 
@@ -2778,7 +2778,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                p->subs[index].f.frametype = AST_FRAME_CONTROL;
                p->subs[index].f.subclass = AST_CONTROL_ANSWER;
                ast_setstate(ast, AST_STATE_UP);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }       
        
@@ -2822,7 +2822,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                        p->subs[index].f.subclass = AST_CONTROL_ANSWER;
                        ast_setstate(ast, AST_STATE_UP);
                }
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }
        
@@ -2843,7 +2843,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                }
        } else {
                ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
@@ -2854,7 +2854,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
        if (res < 0) {
                if (res == -1) 
                        ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return NULL;
        }
        if (res != READ_SIZE) {
@@ -2884,7 +2884,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                                        }
                                        p->callwaitcas = 0;
                                        /* Return NULL */
-                                       pthread_mutex_unlock(&p->lock);
+                                       ast_mutex_unlock(&p->lock);
                                        return &p->subs[index].f;
                                } else {
                                        strncpy(p->subs[index].dtmfq + strlen(p->subs[index].dtmfq), zap_dtmfbuf(p->subs[index].z), sizeof(p->subs[index].dtmfq) - strlen(p->subs[index].dtmfq)-1);
@@ -2892,7 +2892,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                                }
                        }
                } else {
-                       pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        return zt_handle_event(ast);
                }
                if (strlen(p->subs[index].dtmfq)) {
@@ -2916,12 +2916,12 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                                                ast_log(LOG_DEBUG, "Fax already handled\n");
                                p->subs[index].f.frametype = AST_FRAME_NULL;
                                p->subs[index].f.subclass = 0;
-                               pthread_mutex_unlock(&p->lock);
+                               ast_mutex_unlock(&p->lock);
                                return &p->subs[index].f;
                        }
                        p->subs[index].f.frametype = AST_FRAME_DTMF;
                }
-               pthread_mutex_unlock(&p->lock);
+               ast_mutex_unlock(&p->lock);
                return &p->subs[index].f;
        }
        if (p->tdd) { /* if in TDD mode, see if we receive that */
@@ -2940,7 +2940,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                        p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
                        p->subs[index].f.datalen = 1;
                        *((char *) p->subs[index].f.data) = c;
-                       pthread_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&p->lock);
                        return &p->subs[index].f;
                }
        }
@@ -2998,7 +2998,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                }
        } else 
                f = &p->subs[index].f; 
-       pthread_mutex_unlock(&p->lock);
+       ast_mutex_unlock(&p->lock);
        return f;
 }
 
@@ -3240,9 +3240,9 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
                }
                i->subs[index].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();
                strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
                /* Copy call forward info */
@@ -4018,7 +4018,7 @@ static void *do_monitor(void *data)
 #endif
        for(;;) {
                /* 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");
                        return NULL;
                }
@@ -4049,7 +4049,7 @@ 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);
                
                pthread_testcancel();
                /* Wait at least a second for something to happen */
@@ -4065,7 +4065,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;
                }
@@ -4183,7 +4183,7 @@ static void *do_monitor(void *data)
                        }
                        i=i->next;
                }
-               ast_pthread_mutex_unlock(&iflock);
+               ast_mutex_unlock(&iflock);
        }
        /* Never reached */
        return NULL;
@@ -4198,12 +4198,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;
        }
@@ -4219,7 +4219,7 @@ static int restart_monitor(void)
        } else {
                /* Start a new monitor */
                if (pthread_create(&monitor_thread, &attr, 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;
                }
@@ -4227,7 +4227,7 @@ static int restart_monitor(void)
 #if 0
        printf("Created thread %ld detached in restart monitor\n", monitor_thread);
 #endif
-       ast_pthread_mutex_unlock(&monlock);
+       ast_mutex_unlock(&monlock);
        return 0;
 }
 
@@ -4729,7 +4729,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
                channelmatch = x;
        }
        /* 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;
        }
@@ -4788,7 +4788,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
                }
                p = p->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        restart_monitor();
        return tmp;
 }
@@ -4992,7 +4992,7 @@ static void *pri_dchannel(void *vpri)
                FD_SET(pri->fd, &rfds);
                FD_SET(pri->fd, &efds);
                time(&t);
-               ast_pthread_mutex_lock(&pri->lock);
+               ast_mutex_lock(&pri->lock);
                if (pri->resetting && pri->up) {
                        /* Look for a resetable channel and go */
                        if ((t - pri->lastreset) > 0) {
@@ -5111,12 +5111,12 @@ static void *pri_dchannel(void *vpri)
                        tv.tv_sec = 60;
                        tv.tv_usec = 0;
                }
-               pthread_mutex_unlock(&pri->lock);
+               ast_mutex_unlock(&pri->lock);
 
                e = NULL;
                res = ast_select(pri->fd + 1, &rfds, NULL, &efds, &tv);
 
-               ast_pthread_mutex_lock(&pri->lock);
+               ast_mutex_lock(&pri->lock);
                if (!res) {
                        /* Just a timeout, run the scheduler */
                        e = pri_schedule_run(pri->pri);
@@ -5421,7 +5421,7 @@ static void *pri_dchannel(void *vpri)
                        if (option_debug)
                                ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
                }
-               pthread_mutex_unlock(&pri->lock);
+               ast_mutex_unlock(&pri->lock);
        }
        /* Never reached */
        return NULL;
@@ -5690,7 +5690,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
        if (argc != 3)
                return RESULT_SHOWUSAGE;
 
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        ast_cli(fd, FORMAT2, "Chan. Num.", "Extension", "Context", "Language", "MusicOnHold");
        
        tmp = iflist;
@@ -5698,7 +5698,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
                ast_cli(fd, FORMAT, tmp->channel, tmp->exten, tmp->context, tmp->language, tmp->musicclass);
                tmp = tmp->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -5714,7 +5714,7 @@ static int zap_show_channel(int fd, int argc, char **argv)
                return RESULT_SHOWUSAGE;
        channel = atoi(argv[3]);
 
-       ast_pthread_mutex_lock(&iflock);
+       ast_mutex_lock(&iflock);
        tmp = iflist;
        while (tmp) {
                if (tmp->channel == channel) {
@@ -5764,14 +5764,14 @@ static int zap_show_channel(int fd, int argc, char **argv)
                                ast_cli(fd, "\n");
                        }
 #endif
-                       ast_pthread_mutex_unlock(&iflock);
+                       ast_mutex_unlock(&iflock);
                        return RESULT_SUCCESS;
                }
                tmp = tmp->next;
        }
        
        ast_cli(fd, "Unable to find given channel %d\n", channel);
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        return RESULT_FAILURE;
 }
 
@@ -5829,7 +5829,7 @@ int load_module()
        }
        
 
-       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;
@@ -5841,7 +5841,7 @@ int load_module()
                        if (cur_signalling < 0) {
                                ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                unload_module();
                                return -1;
                        }
@@ -5858,7 +5858,7 @@ int load_module()
                                } else {
                                        ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
                                        ast_destroy(cfg);
-                                       ast_pthread_mutex_unlock(&iflock);
+                                       ast_mutex_unlock(&iflock);
                                        unload_module();
                                        return -1;
                                }
@@ -5876,7 +5876,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;
                                        }
@@ -6066,7 +6066,7 @@ int load_module()
                        else {
                                ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                unload_module();
                                return -1;
                        }
@@ -6081,7 +6081,7 @@ int load_module()
                        ast_log(LOG_DEBUG, "Ignoring %s\n", v->name);
                v = v->next;
        }
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
        /* Make sure we can register our Zap channel type */
        if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR |  AST_FORMAT_ULAW, zt_request)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -6140,7 +6140,7 @@ int unload_module()
        ast_cli_unregister(&cli_show_channels);
        ast_cli_unregister(&cli_show_channel);
        ast_cli_unregister(&cli_destroy_channel);
-       if (!ast_pthread_mutex_lock(&iflock)) {
+       if (!ast_mutex_lock(&iflock)) {
                /* Hangup all interfaces if they have an owner */
                p = iflist;
                while(p) {
@@ -6149,25 +6149,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) {
@@ -6183,7 +6183,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;
@@ -6262,7 +6262,7 @@ static int reload_zt(void)
        }
        
 
-       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;
@@ -6284,7 +6284,7 @@ static int reload_zt(void)
                        if (cur_signalling < 0) {
                                ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                return -1;
                        }
                        stringp=v->value;
@@ -6298,7 +6298,7 @@ static int reload_zt(void)
                                } else {
                                        ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
                                        ast_destroy(cfg);
-                                       ast_pthread_mutex_unlock(&iflock);
+                                       ast_mutex_unlock(&iflock);
                                        return -1;
                                }
                                if (finish < start) {
@@ -6315,7 +6315,7 @@ static int reload_zt(void)
                                        } 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);
                                                return -1;
                                        }
                                }
@@ -6417,7 +6417,7 @@ static int reload_zt(void)
                        else {
                                ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
                                ast_destroy(cfg);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                return -1;
                        }
                } else if (!strcasecmp(v->name, "minunused")) {
@@ -6439,7 +6439,7 @@ static int reload_zt(void)
                if (tmp->destroy) {
                        if (destroy_channel(prev, tmp, 0)) {
                                ast_log(LOG_ERROR, "Unable to destroy chan_zap channel %d\n", tmp->channel);
-                               ast_pthread_mutex_unlock(&iflock);
+                               ast_mutex_unlock(&iflock);
                                return -1;
                        }
                        tmp = tmp->next;
@@ -6449,7 +6449,7 @@ static int reload_zt(void)
                }
        }
 
-       ast_pthread_mutex_unlock(&iflock);
+       ast_mutex_unlock(&iflock);
 
        ast_destroy(cfg);
 #if 0
@@ -6593,9 +6593,9 @@ int reload(void)
 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;
 }
 
diff --git a/cli.c b/cli.c
index d45f6b84bbddca71bd840c69f96afc3d773de7e8..4708f7f5766615d574afa4ca0b6ede35f1f9d6b7 100755 (executable)
--- a/cli.c
+++ b/cli.c
@@ -44,7 +44,7 @@ void ast_cli(int fd, char *fmt, ...)
        write(fd, stuff, strlen(stuff));
 }
 
-pthread_mutex_t clilock = AST_MUTEX_INITIALIZER;
+ast_mutex_t clilock = AST_MUTEX_INITIALIZER;
 
 
 struct ast_cli_entry *helpers = NULL;
@@ -155,7 +155,7 @@ static int handle_unload(int fd, int argc, char *argv[])
 #define MODLIST_FORMAT  "%-20s %-40.40s %-10d\n"
 #define MODLIST_FORMAT2 "%-20s %-40.40s %-10s\n"
 
-static pthread_mutex_t climodentrylock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t climodentrylock = AST_MUTEX_INITIALIZER;
 static int climodentryfd = -1;
 
 static int modlist_modentry(char *module, char *description, int usecnt)
@@ -263,12 +263,12 @@ static int handle_modlist(int fd, int argc, char *argv[])
 {
        if (argc != 2)
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&climodentrylock);
+       ast_mutex_lock(&climodentrylock);
        climodentryfd = fd;
        ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
        ast_update_module_list(modlist_modentry);
        climodentryfd = -1;
-       ast_pthread_mutex_unlock(&climodentrylock);
+       ast_mutex_unlock(&climodentrylock);
        return RESULT_SUCCESS;
 }
 
@@ -655,7 +655,7 @@ static char *find_best(char *argv[])
 int ast_cli_unregister(struct ast_cli_entry *e)
 {
        struct ast_cli_entry *cur, *l=NULL;
-       ast_pthread_mutex_lock(&clilock);
+       ast_mutex_lock(&clilock);
        cur = helpers;
        while(cur) {
                if (e == cur) {
@@ -674,7 +674,7 @@ int ast_cli_unregister(struct ast_cli_entry *e)
                l = cur;
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&clilock);
+       ast_mutex_unlock(&clilock);
        return 0;
 }
 
@@ -683,10 +683,10 @@ int ast_cli_register(struct ast_cli_entry *e)
        struct ast_cli_entry *cur, *l=NULL;
        char fulle[80] ="", fulltst[80] ="";
        static int len;
-       ast_pthread_mutex_lock(&clilock);
+       ast_mutex_lock(&clilock);
        join2(fulle, sizeof(fulle), e->cmda);
        if (find_cli(e->cmda, -1)) {
-               ast_pthread_mutex_unlock(&clilock);
+               ast_mutex_unlock(&clilock);
                ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", fulle);
                return -1;
        }
@@ -716,7 +716,7 @@ int ast_cli_register(struct ast_cli_entry *e)
                        helpers = e;
                e->next = NULL;
        }
-       ast_pthread_mutex_unlock(&clilock);
+       ast_mutex_unlock(&clilock);
        return 0;
 }
 
@@ -926,7 +926,7 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
        if ((dup = parse_args(text, &x, argv))) {
                join(matchstr, sizeof(matchstr), argv);
                if (lock)
-                       ast_pthread_mutex_lock(&clilock);
+                       ast_mutex_lock(&clilock);
                e1 = builtins;
                e2 = helpers;
                while(e1->cmda[0] || e2) {
@@ -959,7 +959,7 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
                                        }
                                        if (res) {
                                                if (lock)
-                                                       ast_pthread_mutex_unlock(&clilock);
+                                                       ast_mutex_unlock(&clilock);
                                                free(dup);
                                                return res ? strdup(res) : NULL;
                                        }
@@ -970,13 +970,13 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
                                   command can have this occur */
                                fullcmd = e->generator(text, word, (strlen(word) ? (x - 1) : (x)), state);
                                if (lock)
-                                       ast_pthread_mutex_unlock(&clilock);
+                                       ast_mutex_unlock(&clilock);
                                return fullcmd;
                        }
                        
                }
                if (lock)
-                       ast_pthread_mutex_unlock(&clilock);
+                       ast_mutex_unlock(&clilock);
                free(dup);
        }
        return NULL;
@@ -997,11 +997,11 @@ int ast_cli_command(int fd, char *s)
        if ((dup = parse_args(s, &x, argv))) {
                /* We need at least one entry, or ignore */
                if (x > 0) {
-                       ast_pthread_mutex_lock(&clilock);
+                       ast_mutex_lock(&clilock);
                        e = find_cli(argv, 0);
                        if (e)
                                e->inuse++;
-                       ast_pthread_mutex_unlock(&clilock);
+                       ast_mutex_unlock(&clilock);
                        if (e) {
                                switch(e->handler(fd, x, argv)) {
                                case RESULT_SHOWUSAGE:
@@ -1011,9 +1011,9 @@ int ast_cli_command(int fd, char *s)
                        } else 
                                ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
                        if (e) {
-                               ast_pthread_mutex_lock(&clilock);
+                               ast_mutex_lock(&clilock);
                                e->inuse--;
-                               ast_pthread_mutex_unlock(&clilock);
+                               ast_mutex_unlock(&clilock);
                        }
                }
                free(dup);
index 3d1496c6c88da1b12bd28c0826ae1765c9a2c150..4b66342622ba6bb919b7101f339b441d3d8ac469 100755 (executable)
@@ -27,7 +27,7 @@
 
 #define BUFFER_SIZE   8096     /* size for the translation buffers */
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt = 0;
 
 static char *tdesc = "A-law and Mulaw direct Coder/Decoder";
@@ -274,13 +274,13 @@ int
 unload_module (void)
 {
   int res;
-  ast_pthread_mutex_lock (&localuser_lock);
+  ast_mutex_lock (&localuser_lock);
   res = ast_unregister_translator (&ulawtoalaw);
   if (!res)
     res = ast_unregister_translator (&alawtoulaw);
   if (localusecnt)
     res = -1;
-  ast_pthread_mutex_unlock (&localuser_lock);
+  ast_mutex_unlock (&localuser_lock);
   return res;
 }
 
index 641f28b7e14c9de21eccb8ad3e689b9ef7d8dc57..5845383678defcf0d5d45ed2eb2c9418826dd936 100755 (executable)
@@ -28,7 +28,7 @@
 
 #define BUFFER_SIZE   8096     /* size for the translation buffers */
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt = 0;
 
 static char *tdesc = "Adaptive Differential PCM Coder/Decoder";
@@ -500,13 +500,13 @@ int
 unload_module (void)
 {
   int res;
-  ast_pthread_mutex_lock (&localuser_lock);
+  ast_mutex_lock (&localuser_lock);
   res = ast_unregister_translator (&lintoadpcm);
   if (!res)
     res = ast_unregister_translator (&adpcmtolin);
   if (localusecnt)
     res = -1;
-  ast_pthread_mutex_unlock (&localuser_lock);
+  ast_mutex_unlock (&localuser_lock);
   return res;
 }
 
index 192b112c9a97da10678db4cc344b0b8f61150c75..08baba4bd4c181d56bf4b91d49dfb206e258499a 100755 (executable)
@@ -26,7 +26,7 @@
 
 #define BUFFER_SIZE   8096     /* size for the translation buffers */
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt = 0;
 
 static char *tdesc = "A-law Coder/Decoder";
@@ -332,13 +332,13 @@ int
 unload_module (void)
 {
   int res;
-  ast_pthread_mutex_lock (&localuser_lock);
+  ast_mutex_lock (&localuser_lock);
   res = ast_unregister_translator (&lintoalaw);
   if (!res)
     res = ast_unregister_translator (&alawtolin);
   if (localusecnt)
     res = -1;
-  ast_pthread_mutex_unlock (&localuser_lock);
+  ast_mutex_unlock (&localuser_lock);
   return res;
 }
 
index 94ae898aa1ce5e7d9fa6060861b55222fe9d75f3..423d246956ea0571eaf67cdbf6a73846034224d0 100755 (executable)
@@ -56,7 +56,7 @@
 #include "slin_g723_ex.h"
 #include "g723_slin_ex.h"
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt=0;
 
 #ifdef ANNEX_B
@@ -363,13 +363,13 @@ static struct ast_translator lintog723 =
 int unload_module(void)
 {
        int res;
-       ast_pthread_mutex_lock(&localuser_lock);
+       ast_mutex_lock(&localuser_lock);
        res = ast_unregister_translator(&lintog723);
        if (!res)
                res = ast_unregister_translator(&g723tolin);
        if (localusecnt)
                res = -1;
-       ast_pthread_mutex_unlock(&localuser_lock);
+       ast_mutex_unlock(&localuser_lock);
        return res;
 }
 
index 68efbf92bbb6d59bca502814667e59c83df13b57..f0efe1a825326d2a70c251981762a932ca9f5e6d 100755 (executable)
@@ -39,7 +39,7 @@
 #include "slin_gsm_ex.h"
 #include "gsm_slin_ex.h"
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt=0;
 
 static char *tdesc = "GSM/PCM16 (signed linear) Codec Translator";
@@ -253,13 +253,13 @@ static struct ast_translator lintogsm =
 int unload_module(void)
 {
        int res;
-       ast_pthread_mutex_lock(&localuser_lock);
+       ast_mutex_lock(&localuser_lock);
        res = ast_unregister_translator(&lintogsm);
        if (!res)
                res = ast_unregister_translator(&gsmtolin);
        if (localusecnt)
                res = -1;
-       ast_pthread_mutex_unlock(&localuser_lock);
+       ast_mutex_unlock(&localuser_lock);
        return res;
 }
 
index 014151b873a90a747af20c4951d25d588bc91ede..e11c9703e15ac157e1cfe435935644c965501000 100755 (executable)
@@ -35,7 +35,7 @@
 
 #define USE_ILBC_ENHANCER      0
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt=0;
 
 static char *tdesc = "iLBC/PCM16 (signed linear) Codec Translator";
@@ -245,13 +245,13 @@ static struct ast_translator lintoilbc =
 int unload_module(void)
 {
        int res;
-       ast_pthread_mutex_lock(&localuser_lock);
+       ast_mutex_lock(&localuser_lock);
        res = ast_unregister_translator(&lintoilbc);
        if (!res)
                res = ast_unregister_translator(&ilbctolin);
        if (localusecnt)
                res = -1;
-       ast_pthread_mutex_unlock(&localuser_lock);
+       ast_mutex_unlock(&localuser_lock);
        return res;
 }
 
index 3c5d2c3abdebbb5191311153c44f9c3c6dc47187..ffd1ddc23d8360c820a0a90e54ebfbc08c813bb1 100755 (executable)
@@ -43,7 +43,7 @@
 
 #define LPC10_BYTES_IN_COMPRESSED_FRAME (LPC10_BITS_IN_COMPRESSED_FRAME + 7)/8
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt=0;
 
 static char *tdesc = "LPC10 2.4kbps (signed linear) Voice Coder";
@@ -330,13 +330,13 @@ static struct ast_translator lintolpc10 =
 int unload_module(void)
 {
        int res;
-       ast_pthread_mutex_lock(&localuser_lock);
+       ast_mutex_lock(&localuser_lock);
        res = ast_unregister_translator(&lintolpc10);
        if (!res)
                res = ast_unregister_translator(&lpc10tolin);
        if (localusecnt)
                res = -1;
-       ast_pthread_mutex_unlock(&localuser_lock);
+       ast_mutex_unlock(&localuser_lock);
        return res;
 }
 
index 09215ddd7d00a2366ffd638cc4bf6d3e94bfb428..9ff3961aaba7fd1aec615263b9937b2767d03534 100755 (executable)
@@ -41,7 +41,7 @@
 #define MAX_FRAME_SIZE 1441
 #define MAX_OUTPUT_LEN 2304
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt=0;
 
 static char *tdesc = "MP3/PCM16 (signed linear) Translator (Decoder only)";
@@ -287,11 +287,11 @@ static struct ast_translator mp3tolin =
 int unload_module(void)
 {
        int res;
-       ast_pthread_mutex_lock(&localuser_lock);
+       ast_mutex_lock(&localuser_lock);
        res = ast_unregister_translator(&mp3tolin);
        if (localusecnt)
                res = -1;
-       ast_pthread_mutex_unlock(&localuser_lock);
+       ast_mutex_unlock(&localuser_lock);
        return res;
 }
 
index 3c2e4f51995d2064052c780ceb0f44a64522c908..ae731fafa350ed65eb9715bad7bca124e29006d0 100755 (executable)
@@ -37,7 +37,7 @@
 #include "slin_speex_ex.h"
 #include "speex_slin_ex.h"
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt=0;
 
 static char *tdesc = "Speex/PCM16 (signed linear) Codec Translator";
@@ -275,13 +275,13 @@ static struct ast_translator lintospeex =
 int unload_module(void)
 {
        int res;
-       ast_pthread_mutex_lock(&localuser_lock);
+       ast_mutex_lock(&localuser_lock);
        res = ast_unregister_translator(&lintospeex);
        if (!res)
                res = ast_unregister_translator(&speextolin);
        if (localusecnt)
                res = -1;
-       ast_pthread_mutex_unlock(&localuser_lock);
+       ast_mutex_unlock(&localuser_lock);
        return res;
 }
 
index d536bf052a8cc9ca1467224298e1ff05103ad975..41101897d36dde26e19b7ef421287929141138d2 100755 (executable)
@@ -26,7 +26,7 @@
 
 #define BUFFER_SIZE   8096     /* size for the translation buffers */
 
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
 static int localusecnt = 0;
 
 static char *tdesc = "Mu-law Coder/Decoder";
@@ -332,13 +332,13 @@ int
 unload_module (void)
 {
   int res;
-  ast_pthread_mutex_lock (&localuser_lock);
+  ast_mutex_lock (&localuser_lock);
   res = ast_unregister_translator (&lintoulaw);
   if (!res)
     res = ast_unregister_translator (&ulawtolin);
   if (localusecnt)
     res = -1;
-  ast_pthread_mutex_unlock (&localuser_lock);
+  ast_mutex_unlock (&localuser_lock);
   return res;
 }
 
diff --git a/db.c b/db.c
index 6e5be88e210c447f2b09c27fee2c81fc3339fd3c..815ace4b89bee10943dbb412d5a1591b125b27f5 100755 (executable)
--- a/db.c
+++ b/db.c
@@ -37,7 +37,7 @@
 #include "astconf.h"
 
 static DB *astdb;
-static pthread_mutex_t dblock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t dblock = AST_MUTEX_INITIALIZER;
 
 static int dbinit(void) 
 {
@@ -84,7 +84,7 @@ int ast_db_deltree(const char *family, const char *keytree)
        else
                strcpy(prefix, "");
        
-       ast_pthread_mutex_lock(&dblock);
+       ast_mutex_lock(&dblock);
        if (dbinit()) 
                return -1;
        
@@ -102,7 +102,7 @@ int ast_db_deltree(const char *family, const char *keytree)
                }
        }
        astdb->sync(astdb, 0);
-       ast_pthread_mutex_unlock(&dblock);
+       ast_mutex_unlock(&dblock);
        return 0;
 }
 
@@ -112,9 +112,9 @@ int ast_db_put(const char *family, const char *keys, char *value)
        DBT key, data;
        int res;
 
-       ast_pthread_mutex_lock(&dblock);
+       ast_mutex_lock(&dblock);
        if (dbinit()) {
-               ast_pthread_mutex_unlock(&dblock);
+               ast_mutex_unlock(&dblock);
                return -1;
        }
 
@@ -127,7 +127,7 @@ int ast_db_put(const char *family, const char *keys, char *value)
        data.size = strlen(value) + 1;
        res = astdb->put(astdb, &key, &data, 0);
        astdb->sync(astdb, 0);
-       ast_pthread_mutex_unlock(&dblock);
+       ast_mutex_unlock(&dblock);
        if (res)
                ast_log(LOG_WARNING, "Unable to put value '%s' for key '%s' in family '%s'\n", value, keys, family);
        return res;
@@ -139,9 +139,9 @@ int ast_db_get(const char *family, const char *keys, char *value, int valuelen)
        DBT key, data;
        int res;
 
-       ast_pthread_mutex_lock(&dblock);
+       ast_mutex_lock(&dblock);
        if (dbinit()) {
-               ast_pthread_mutex_unlock(&dblock);
+               ast_mutex_unlock(&dblock);
                return -1;
        }
 
@@ -154,7 +154,7 @@ int ast_db_get(const char *family, const char *keys, char *value, int valuelen)
        
        res = astdb->get(astdb, &key, &data, 0);
        
-       ast_pthread_mutex_unlock(&dblock);
+       ast_mutex_unlock(&dblock);
 
        /* Be sure to NULL terminate our data either way */
        if (res) {
@@ -180,9 +180,9 @@ int ast_db_del(const char *family, const char *keys)
        DBT key;
        int res;
 
-       ast_pthread_mutex_lock(&dblock);
+       ast_mutex_lock(&dblock);
        if (dbinit()) {
-               ast_pthread_mutex_unlock(&dblock);
+               ast_mutex_unlock(&dblock);
                return -1;
        }
        
@@ -194,7 +194,7 @@ int ast_db_del(const char *family, const char *keys)
        res = astdb->del(astdb, &key, 0);
        astdb->sync(astdb, 0);
        
-       ast_pthread_mutex_unlock(&dblock);
+       ast_mutex_unlock(&dblock);
 
        if (res) 
                ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
@@ -276,9 +276,9 @@ static int database_show(int fd, int argc, char *argv[])
                strcpy(prefix, "");
        } else
                return RESULT_SHOWUSAGE;
-       ast_pthread_mutex_lock(&dblock);
+       ast_mutex_lock(&dblock);
        if (dbinit()) {
-               ast_pthread_mutex_unlock(&dblock);
+               ast_mutex_unlock(&dblock);
                ast_cli(fd, "Database unavailable\n");
                return RESULT_SUCCESS;  
        }
@@ -300,7 +300,7 @@ static int database_show(int fd, int argc, char *argv[])
                                ast_cli(fd, "%-50s: %-25s\n", keys, values);
                }
        }
-       ast_pthread_mutex_unlock(&dblock);
+       ast_mutex_unlock(&dblock);
        return RESULT_SUCCESS;  
 }
 
@@ -323,9 +323,9 @@ struct ast_db_entry *ast_db_gettree(const char *family, const char *keytree)
                        snprintf(prefix, sizeof(prefix), "/%s", family);
        } else
                strcpy(prefix, "");
-       ast_pthread_mutex_lock(&dblock);
+       ast_mutex_lock(&dblock);
        if (dbinit()) {
-               ast_pthread_mutex_unlock(&dblock);
+               ast_mutex_unlock(&dblock);
                ast_log(LOG_WARNING, "Database unavailable\n");
                return NULL;    
        }
@@ -358,7 +358,7 @@ struct ast_db_entry *ast_db_gettree(const char *family, const char *keytree)
                                }
                }
        }
-       ast_pthread_mutex_unlock(&dblock);
+       ast_mutex_unlock(&dblock);
        return ret;     
 }
 
diff --git a/enum.c b/enum.c
index 73141f0a89b5af8f2cec1c6802747b196803d24d..4bb5bd3bb2b747e2ca50aee3f21620bae8049245 100755 (executable)
--- a/enum.c
+++ b/enum.c
@@ -76,7 +76,7 @@ static struct enum_search {
 
 static int enumver = 0;
 
-static pthread_mutex_t enumlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t enumlock = AST_MUTEX_INITIALIZER;
 
 static int skip_name(unsigned char *s, int len)
 {
@@ -291,7 +291,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
 #endif 
        
        for(;;) {
-               ast_pthread_mutex_lock(&enumlock);
+               ast_mutex_lock(&enumlock);
                if (version != enumver) {
                        /* Ooh, a reload... */
                        s = toplevs;
@@ -301,7 +301,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
                if (s) {
                        strcpy(tmp + newpos, s->toplev);
                }
-               ast_pthread_mutex_unlock(&enumlock);
+               ast_mutex_unlock(&enumlock);
                if (!s)
                        break;
                res = res_nsearch(&enumstate, tmp, C_IN, T_NAPTR, answer, sizeof(answer));
@@ -344,7 +344,7 @@ int ast_enum_init(void)
        struct ast_variable *v;
 
        /* Destroy existing list */
-       ast_pthread_mutex_lock(&enumlock);
+       ast_mutex_lock(&enumlock);
        s = toplevs;
        while(s) {
                sl = s;
@@ -374,7 +374,7 @@ int ast_enum_init(void)
                toplevs = enum_newtoplev(TOPLEV);
        }
        enumver++;
-       ast_pthread_mutex_unlock(&enumlock);
+       ast_mutex_unlock(&enumlock);
        return 0;
 }
 
diff --git a/file.c b/file.c
index 314ad7f7594b1605d51a66f005eba5f1942aae26..bad5f814e55e5a5fbd4c4e4af0ccca10ab84501a 100755 (executable)
--- a/file.c
+++ b/file.c
@@ -78,7 +78,7 @@ struct ast_filestream {
        struct ast_channel *owner;
 };
 
-static pthread_mutex_t formatlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t formatlock = AST_MUTEX_INITIALIZER;
 
 static struct ast_format *formats = NULL;
 
@@ -94,14 +94,14 @@ int ast_format_register(char *name, char *exts, int format,
                                                char * (*getcomment)(struct ast_filestream *))
 {
        struct ast_format *tmp;
-       if (ast_pthread_mutex_lock(&formatlock)) {
+       if (ast_mutex_lock(&formatlock)) {
                ast_log(LOG_WARNING, "Unable to lock format list\n");
                return -1;
        }
        tmp = formats;
        while(tmp) {
                if (!strcasecmp(name, tmp->name)) {
-                       ast_pthread_mutex_unlock(&formatlock);
+                       ast_mutex_unlock(&formatlock);
                        ast_log(LOG_WARNING, "Tried to register '%s' format, already registered\n", name);
                        return -1;
                }
@@ -110,7 +110,7 @@ int ast_format_register(char *name, char *exts, int format,
        tmp = malloc(sizeof(struct ast_format));
        if (!tmp) {
                ast_log(LOG_WARNING, "Out of memory\n");
-               ast_pthread_mutex_unlock(&formatlock);
+               ast_mutex_unlock(&formatlock);
                return -1;
        }
        strncpy(tmp->name, name, sizeof(tmp->name)-1);
@@ -127,7 +127,7 @@ int ast_format_register(char *name, char *exts, int format,
        tmp->getcomment = getcomment;
        tmp->next = formats;
        formats = tmp;
-       ast_pthread_mutex_unlock(&formatlock);
+       ast_mutex_unlock(&formatlock);
        if (option_verbose > 1)
                ast_verbose( VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s\n", name, exts);
        return 0;
@@ -136,7 +136,7 @@ int ast_format_register(char *name, char *exts, int format,
 int ast_format_unregister(char *name)
 {
        struct ast_format *tmp, *tmpl = NULL;
-       if (ast_pthread_mutex_lock(&formatlock)) {
+       if (ast_mutex_lock(&formatlock)) {
                ast_log(LOG_WARNING, "Unable to lock format list\n");
                return -1;
        }
@@ -148,7 +148,7 @@ int ast_format_unregister(char *name)
                        else
                                formats = tmp->next;
                        free(tmp);
-                       ast_pthread_mutex_unlock(&formatlock);
+                       ast_mutex_unlock(&formatlock);
                        if (option_verbose > 1)
                                ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name);
                        return 0;
@@ -310,7 +310,7 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action
        if (action == ACTION_OPEN)
                ret = -1;
        /* Check for a specific format */
-       if (ast_pthread_mutex_lock(&formatlock)) {
+       if (ast_mutex_lock(&formatlock)) {
                ast_log(LOG_WARNING, "Unable to lock format list\n");
                if (action == ACTION_EXISTS)
                        return 0;
@@ -397,7 +397,7 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action
                }
                f = f->next;
        }
-       ast_pthread_mutex_unlock(&formatlock);
+       ast_mutex_unlock(&formatlock);
        if ((action == ACTION_EXISTS) || (action == ACTION_OPEN))
                res = ret ? ret : -1;
        return res;
@@ -731,7 +731,7 @@ struct ast_filestream *ast_writefile(char *filename, char *type, char *comment,
        struct ast_filestream *fs=NULL;
        char *fn;
        char *ext;
-       if (ast_pthread_mutex_lock(&formatlock)) {
+       if (ast_mutex_lock(&formatlock)) {
                ast_log(LOG_WARNING, "Unable to lock format list\n");
                return NULL;
        }
@@ -770,7 +770,7 @@ struct ast_filestream *ast_writefile(char *filename, char *type, char *comment,
                }
                f = f->next;
        }
-       ast_pthread_mutex_unlock(&formatlock);
+       ast_mutex_unlock(&formatlock);
        if (!f) 
                ast_log(LOG_WARNING, "No such format '%s'\n", type);
        return fs;
index 8ce2ec266a9874c8318849bc2adb57e0ff6ac9a3..2431d3dee2750706469d7c8b75484e591bb9ffad 100755 (executable)
@@ -42,7 +42,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t g723_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t g723_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "g723sf";
@@ -56,7 +56,7 @@ static struct ast_filestream *g723_open(int fd)
           and be sure it's a valid file.  */
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
-               if (ast_pthread_mutex_lock(&g723_lock)) {
+               if (ast_mutex_lock(&g723_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock g723 list\n");
                        free(tmp);
                        return NULL;
@@ -73,7 +73,7 @@ static struct ast_filestream *g723_open(int fd)
                tmp->orig.tv_usec = 0;
                tmp->orig.tv_sec = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&g723_lock);
+               ast_mutex_unlock(&g723_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -86,7 +86,7 @@ static struct ast_filestream *g723_rewrite(int fd, char *comment)
           and be sure it's a valid file.  */
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
-               if (ast_pthread_mutex_lock(&g723_lock)) {
+               if (ast_mutex_lock(&g723_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock g723 list\n");
                        free(tmp);
                        return NULL;
@@ -98,7 +98,7 @@ static struct ast_filestream *g723_rewrite(int fd, char *comment)
                tmp->orig.tv_usec = 0;
                tmp->orig.tv_sec = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&g723_lock);
+               ast_mutex_unlock(&g723_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -113,7 +113,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s)
 static void g723_close(struct ast_filestream *s)
 {
        struct ast_filestream *tmp, *tmpl = NULL;
-       if (ast_pthread_mutex_lock(&g723_lock)) {
+       if (ast_mutex_lock(&g723_lock)) {
                ast_log(LOG_WARNING, "Unable to lock g723 list\n");
                return;
        }
@@ -136,7 +136,7 @@ static void g723_close(struct ast_filestream *s)
                        ast_sched_del(s->owner->sched, s->owner->streamid);
                s->owner->streamid = -1;
        }
-       ast_pthread_mutex_unlock(&g723_lock);
+       ast_mutex_unlock(&g723_lock);
        ast_update_use_count();
        if (!tmp) 
                ast_log(LOG_WARNING, "Freeing a filestream we don't seem to own\n");
@@ -335,7 +335,7 @@ int load_module()
 int unload_module()
 {
        struct ast_filestream *tmp, *tmpl;
-       if (ast_pthread_mutex_lock(&g723_lock)) {
+       if (ast_mutex_lock(&g723_lock)) {
                ast_log(LOG_WARNING, "Unable to lock g723 list\n");
                return -1;
        }
@@ -347,19 +347,19 @@ int unload_module()
                tmp = tmp->next;
                free(tmpl);
        }
-       ast_pthread_mutex_unlock(&g723_lock);
+       ast_mutex_unlock(&g723_lock);
        return ast_format_unregister(name);
 }      
 
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&g723_lock)) {
+       if (ast_mutex_lock(&g723_lock)) {
                ast_log(LOG_WARNING, "Unable to lock g723 list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&g723_lock);
+       ast_mutex_unlock(&g723_lock);
        return res;
 }
 
index a2336c94b4d7cefd9f192b81e7437d30bf5cc8d2..81765985f750816b224cad768a7e293bae753396 100755 (executable)
@@ -48,7 +48,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t g729_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t g729_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "g729";
@@ -63,7 +63,7 @@ static struct ast_filestream *g729_open(int fd)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&g729_lock)) {
+               if (ast_mutex_lock(&g729_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock g729 list\n");
                        free(tmp);
                        return NULL;
@@ -76,7 +76,7 @@ static struct ast_filestream *g729_open(int fd)
                tmp->fr.src = name;
                tmp->fr.mallocd = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&g729_lock);
+               ast_mutex_unlock(&g729_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -90,14 +90,14 @@ static struct ast_filestream *g729_rewrite(int fd, char *comment)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&g729_lock)) {
+               if (ast_mutex_lock(&g729_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock g729 list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&g729_lock);
+               ast_mutex_unlock(&g729_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -106,12 +106,12 @@ static struct ast_filestream *g729_rewrite(int fd, char *comment)
 
 static void g729_close(struct ast_filestream *s)
 {
-       if (ast_pthread_mutex_lock(&g729_lock)) {
+       if (ast_mutex_lock(&g729_lock)) {
                ast_log(LOG_WARNING, "Unable to lock g729 list\n");
                return;
        }
        glistcnt--;
-       ast_pthread_mutex_unlock(&g729_lock);
+       ast_mutex_unlock(&g729_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -226,12 +226,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&g729_lock)) {
+       if (ast_mutex_lock(&g729_lock)) {
                ast_log(LOG_WARNING, "Unable to lock g729 list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&g729_lock);
+       ast_mutex_unlock(&g729_lock);
        return res;
 }
 
index 49d53df2757143307a30dc98db9bf5e2fcd627e6..078d79d3331a04b8bf4e4788d37e26266524aacd 100755 (executable)
@@ -50,7 +50,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t gsm_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t gsm_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "gsm";
@@ -65,7 +65,7 @@ static struct ast_filestream *gsm_open(int fd)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&gsm_lock)) {
+               if (ast_mutex_lock(&gsm_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock gsm list\n");
                        free(tmp);
                        return NULL;
@@ -78,7 +78,7 @@ static struct ast_filestream *gsm_open(int fd)
                tmp->fr.src = name;
                tmp->fr.mallocd = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&gsm_lock);
+               ast_mutex_unlock(&gsm_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -92,14 +92,14 @@ static struct ast_filestream *gsm_rewrite(int fd, char *comment)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&gsm_lock)) {
+               if (ast_mutex_lock(&gsm_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock gsm list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&gsm_lock);
+               ast_mutex_unlock(&gsm_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -108,12 +108,12 @@ static struct ast_filestream *gsm_rewrite(int fd, char *comment)
 
 static void gsm_close(struct ast_filestream *s)
 {
-       if (ast_pthread_mutex_lock(&gsm_lock)) {
+       if (ast_mutex_lock(&gsm_lock)) {
                ast_log(LOG_WARNING, "Unable to lock gsm list\n");
                return;
        }
        glistcnt--;
-       ast_pthread_mutex_unlock(&gsm_lock);
+       ast_mutex_unlock(&gsm_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -235,12 +235,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&gsm_lock)) {
+       if (ast_mutex_lock(&gsm_lock)) {
                ast_log(LOG_WARNING, "Unable to lock gsm list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&gsm_lock);
+       ast_mutex_unlock(&gsm_lock);
        return res;
 }
 
index 19a57ed5abc1f58e087c6b6e969c84b2d92967f5..6e0f8edad44c0babf3dbd18fa3c758afff1b8c6d 100755 (executable)
@@ -49,7 +49,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t h263_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t h263_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "h263";
@@ -71,7 +71,7 @@ static struct ast_filestream *h263_open(int fd)
                
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&h263_lock)) {
+               if (ast_mutex_lock(&h263_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock h263 list\n");
                        free(tmp);
                        return NULL;
@@ -84,7 +84,7 @@ static struct ast_filestream *h263_open(int fd)
                tmp->fr.src = name;
                tmp->fr.mallocd = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&h263_lock);
+               ast_mutex_unlock(&h263_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -98,14 +98,14 @@ static struct ast_filestream *h263_rewrite(int fd, char *comment)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&h263_lock)) {
+               if (ast_mutex_lock(&h263_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock h263 list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&h263_lock);
+               ast_mutex_unlock(&h263_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -114,12 +114,12 @@ static struct ast_filestream *h263_rewrite(int fd, char *comment)
 
 static void h263_close(struct ast_filestream *s)
 {
-       if (ast_pthread_mutex_lock(&h263_lock)) {
+       if (ast_mutex_lock(&h263_lock)) {
                ast_log(LOG_WARNING, "Unable to lock h263 list\n");
                return;
        }
        glistcnt--;
-       ast_pthread_mutex_unlock(&h263_lock);
+       ast_mutex_unlock(&h263_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -250,12 +250,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&h263_lock)) {
+       if (ast_mutex_lock(&h263_lock)) {
                ast_log(LOG_WARNING, "Unable to lock h263 list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&h263_lock);
+       ast_mutex_unlock(&h263_lock);
        return res;
 }
 
index 7f6b6992c0f6c64486e9af1ab0ffff2d1c6eff58..bff51d6868d032039c3b8d5b1b7b6cc6219fafe9 100755 (executable)
@@ -43,7 +43,7 @@ struct ast_filestream {
 
 
 static struct ast_filestream *glist = NULL;
-static pthread_mutex_t mp3_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t mp3_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "mp3";
@@ -59,7 +59,7 @@ static struct ast_filestream *mp3_open(int fd)
           and be sure it's a valid file.  */
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
-               if (ast_pthread_mutex_lock(&mp3_lock)) {
+               if (ast_mutex_lock(&mp3_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
                        free(tmp);
                        return NULL;
@@ -68,7 +68,7 @@ static struct ast_filestream *mp3_open(int fd)
                tmp->last.tv_usec = 0;
                tmp->last.tv_sec = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&mp3_lock);
+               ast_mutex_unlock(&mp3_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -81,14 +81,14 @@ static struct ast_filestream *mp3_rewrite(int fd, char *comment)
           and be sure it's a valid file.  */
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
-               if (ast_pthread_mutex_lock(&mp3_lock)) {
+               if (ast_mutex_lock(&mp3_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&mp3_lock);
+               ast_mutex_unlock(&mp3_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -97,12 +97,12 @@ static struct ast_filestream *mp3_rewrite(int fd, char *comment)
 
 static void mp3_close(struct ast_filestream *s)
 {
-       if (ast_pthread_mutex_lock(&mp3_lock)) {
+       if (ast_mutex_lock(&mp3_lock)) {
                ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
                return;
        }
        glistcnt--;
-       ast_pthread_mutex_unlock(&mp3_lock);
+       ast_mutex_unlock(&mp3_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -213,12 +213,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&mp3_lock)) {
+       if (ast_mutex_lock(&mp3_lock)) {
                ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&mp3_lock);
+       ast_mutex_unlock(&mp3_lock);
        return res;
 }
 
index fe384ca5f6431a618a4b7f53986e49ebd0bd6c9a..ab3ba2205e70967a4492e700a784f6c69a3c472f 100755 (executable)
@@ -46,7 +46,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "pcm";
@@ -61,7 +61,7 @@ static struct ast_filestream *pcm_open(int fd)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (pthread_mutex_lock(&pcm_lock)) {
+               if (ast_mutex_lock(&pcm_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                        free(tmp);
                        return NULL;
@@ -74,7 +74,7 @@ static struct ast_filestream *pcm_open(int fd)
                tmp->fr.src = name;
                tmp->fr.mallocd = 0;
                glistcnt++;
-               pthread_mutex_unlock(&pcm_lock);
+               ast_mutex_unlock(&pcm_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -88,14 +88,14 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (pthread_mutex_lock(&pcm_lock)) {
+               if (ast_mutex_lock(&pcm_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               pthread_mutex_unlock(&pcm_lock);
+               ast_mutex_unlock(&pcm_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -104,11 +104,11 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
 
 static void pcm_close(struct ast_filestream *s)
 {
-       if (pthread_mutex_lock(&pcm_lock)) {
+       if (ast_mutex_lock(&pcm_lock)) {
                ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                return;
        }
-       pthread_mutex_unlock(&pcm_lock);
+       ast_mutex_unlock(&pcm_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -215,12 +215,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (pthread_mutex_lock(&pcm_lock)) {
+       if (ast_mutex_lock(&pcm_lock)) {
                ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                return -1;
        }
        res = glistcnt;
-       pthread_mutex_unlock(&pcm_lock);
+       ast_mutex_unlock(&pcm_lock);
        return res;
 }
 
index ef17680d7dce5097efacac9c55951819b5d2a7b5..abc450f24a21cc8a839786d0b2050c983dc1df2c 100755 (executable)
@@ -53,7 +53,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "alaw";
@@ -84,7 +84,7 @@ static struct ast_filestream *pcm_open(int fd)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (pthread_mutex_lock(&pcm_lock)) {
+               if (ast_mutex_lock(&pcm_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                        free(tmp);
                        return NULL;
@@ -100,7 +100,7 @@ static struct ast_filestream *pcm_open(int fd)
                tmp->start_time = get_time();
 #endif
                glistcnt++;
-               pthread_mutex_unlock(&pcm_lock);
+               ast_mutex_unlock(&pcm_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -114,7 +114,7 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (pthread_mutex_lock(&pcm_lock)) {
+               if (ast_mutex_lock(&pcm_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                        free(tmp);
                        return NULL;
@@ -124,7 +124,7 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
                tmp->start_time = get_time();
 #endif
                glistcnt++;
-               pthread_mutex_unlock(&pcm_lock);
+               ast_mutex_unlock(&pcm_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -133,12 +133,12 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
 
 static void pcm_close(struct ast_filestream *s)
 {
-       if (pthread_mutex_lock(&pcm_lock)) {
+       if (ast_mutex_lock(&pcm_lock)) {
                ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                return;
        }
        glistcnt--;
-       pthread_mutex_unlock(&pcm_lock);
+       ast_mutex_unlock(&pcm_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -293,12 +293,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (pthread_mutex_lock(&pcm_lock)) {
+       if (ast_mutex_lock(&pcm_lock)) {
                ast_log(LOG_WARNING, "Unable to lock pcm list\n");
                return -1;
        }
        res = glistcnt;
-       pthread_mutex_unlock(&pcm_lock);
+       ast_mutex_unlock(&pcm_lock);
        return res;
 }
 
index 00c8e16ebf1089cb89062e413d379faf2f97971b..9ea35ffd58a9699c11a11d8388387e67c1a6ebbf 100755 (executable)
@@ -48,7 +48,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t vox_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t vox_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "vox";
@@ -171,7 +171,7 @@ static struct ast_filestream *vox_open(int fd)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&vox_lock)) {
+               if (ast_mutex_lock(&vox_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock vox list\n");
                        free(tmp);
                        return NULL;
@@ -185,7 +185,7 @@ static struct ast_filestream *vox_open(int fd)
                tmp->fr.mallocd = 0;
                tmp->lasttimeout = -1;
                glistcnt++;
-               ast_pthread_mutex_unlock(&vox_lock);
+               ast_mutex_unlock(&vox_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -199,14 +199,14 @@ static struct ast_filestream *vox_rewrite(int fd, char *comment)
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
                memset(tmp, 0, sizeof(struct ast_filestream));
-               if (ast_pthread_mutex_lock(&vox_lock)) {
+               if (ast_mutex_lock(&vox_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock vox list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&vox_lock);
+               ast_mutex_unlock(&vox_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -215,12 +215,12 @@ static struct ast_filestream *vox_rewrite(int fd, char *comment)
 
 static void vox_close(struct ast_filestream *s)
 {
-       if (ast_pthread_mutex_lock(&vox_lock)) {
+       if (ast_mutex_lock(&vox_lock)) {
                ast_log(LOG_WARNING, "Unable to lock vox list\n");
                return;
        }
        glistcnt--;
-       ast_pthread_mutex_unlock(&vox_lock);
+       ast_mutex_unlock(&vox_lock);
        ast_update_use_count();
        close(s->fd);
        free(s);
@@ -324,12 +324,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&vox_lock)) {
+       if (ast_mutex_lock(&vox_lock)) {
                ast_log(LOG_WARNING, "Unable to lock vox list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&vox_lock);
+       ast_mutex_unlock(&vox_lock);
        return res;
 }
 
index c80d47e748864c6bc48768b2b24b32a7e9b3c535..3771df354525d74c8156d8b2d377d288b351e3d6 100755 (executable)
@@ -52,7 +52,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "wav";
@@ -312,7 +312,7 @@ static struct ast_filestream *wav_open(int fd)
                        free(tmp);
                        return NULL;
                }
-               if (ast_pthread_mutex_lock(&wav_lock)) {
+               if (ast_mutex_lock(&wav_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock wav list\n");
                        free(tmp);
                        return NULL;
@@ -327,7 +327,7 @@ static struct ast_filestream *wav_open(int fd)
                tmp->fr.mallocd = 0;
                tmp->bytes = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&wav_lock);
+               ast_mutex_unlock(&wav_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -345,14 +345,14 @@ static struct ast_filestream *wav_rewrite(int fd, char *comment)
                        free(tmp);
                        return NULL;
                }
-               if (ast_pthread_mutex_lock(&wav_lock)) {
+               if (ast_mutex_lock(&wav_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock wav list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&wav_lock);
+               ast_mutex_unlock(&wav_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -362,12 +362,12 @@ static struct ast_filestream *wav_rewrite(int fd, char *comment)
 static void wav_close(struct ast_filestream *s)
 {
        char zero = 0;
-       if (ast_pthread_mutex_lock(&wav_lock)) {
+       if (ast_mutex_lock(&wav_lock)) {
                ast_log(LOG_WARNING, "Unable to lock wav list\n");
                return;
        }
        glistcnt--;
-       ast_pthread_mutex_unlock(&wav_lock);
+       ast_mutex_unlock(&wav_lock);
        ast_update_use_count();
        /* Pad to even length */
        if (s->bytes & 0x1)
@@ -554,12 +554,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&wav_lock)) {
+       if (ast_mutex_lock(&wav_lock)) {
                ast_log(LOG_WARNING, "Unable to lock wav list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&wav_lock);
+       ast_mutex_unlock(&wav_lock);
        return res;
 }
 
index a9a1e83134a29a9b202a0f44ff4930cf857ed372..fbb97d6abc0b185fe387923fd815b8ec5df4dfbf 100755 (executable)
@@ -53,7 +53,7 @@ struct ast_filestream {
 };
 
 
-static pthread_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
 static int glistcnt = 0;
 
 static char *name = "wav49";
@@ -331,7 +331,7 @@ static struct ast_filestream *wav_open(int fd)
                        free(tmp);
                        return NULL;
                }
-               if (ast_pthread_mutex_lock(&wav_lock)) {
+               if (ast_mutex_lock(&wav_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock wav list\n");
                        free(tmp);
                        return NULL;
@@ -345,7 +345,7 @@ static struct ast_filestream *wav_open(int fd)
                tmp->fr.mallocd = 0;
                tmp->secondhalf = 0;
                glistcnt++;
-               ast_pthread_mutex_unlock(&wav_lock);
+               ast_mutex_unlock(&wav_lock);
                ast_update_use_count();
        }
        return tmp;
@@ -363,14 +363,14 @@ static struct ast_filestream *wav_rewrite(int fd, char *comment)
                        free(tmp);
                        return NULL;
                }
-               if (ast_pthread_mutex_lock(&wav_lock)) {
+               if (ast_mutex_lock(&wav_lock)) {
                        ast_log(LOG_WARNING, "Unable to lock wav list\n");
                        free(tmp);
                        return NULL;
                }
                tmp->fd = fd;
                glistcnt++;
-               ast_pthread_mutex_unlock(&wav_lock);
+               ast_mutex_unlock(&wav_lock);
                ast_update_use_count();
        } else
                ast_log(LOG_WARNING, "Out of memory\n");
@@ -380,7 +380,7 @@ static struct ast_filestream *wav_rewrite(int fd, char *comment)
 static void wav_close(struct ast_filestream *s)
 {
        char zero = 0;
-       ast_pthread_mutex_unlock(&wav_lock);
+       ast_mutex_unlock(&wav_lock);
        ast_update_use_count();
        /* Pad to even length */
        if (s->bytes & 0x1)
@@ -533,12 +533,12 @@ int unload_module()
 int usecount()
 {
        int res;
-       if (ast_pthread_mutex_lock(&wav_lock)) {
+       if (ast_mutex_lock(&wav_lock)) {
                ast_log(LOG_WARNING, "Unable to lock wav list\n");
                return -1;
        }
        res = glistcnt;
-       ast_pthread_mutex_unlock(&wav_lock);
+       ast_mutex_unlock(&wav_lock);
        return res;
 }
 
diff --git a/frame.c b/frame.c
index ec5c59dda2205a69efa64e5c2c0397a45f20298c..6143671e7cf33723bb607aa8a84f15ec7d3b98b5 100755 (executable)
--- a/frame.c
+++ b/frame.c
@@ -28,7 +28,7 @@
 #ifdef TRACE_FRAMES
 static int headers = 0;
 static struct ast_frame *headerlist = NULL;
-static pthread_mutex_t framelock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t framelock = AST_MUTEX_INITIALIZER;
 #endif
 
 #define SMOOTHER_SIZE 8000
@@ -154,12 +154,12 @@ static struct ast_frame *ast_frame_header_new(void)
        if (f) {
                headers++;
                f->prev = NULL;
-               ast_pthread_mutex_lock(&framelock);
+               ast_mutex_lock(&framelock);
                f->next = headerlist;
                if (headerlist)
                        headerlist->prev = f;
                headerlist = f;
-               pthread_mutex_unlock(&framelock);
+               ast_mutex_unlock(&framelock);
        }
 #endif 
        return f;
@@ -183,14 +183,14 @@ void ast_frfree(struct ast_frame *fr)
        if (fr->mallocd & AST_MALLOCD_HDR) {
 #ifdef TRACE_FRAMES
                headers--;
-               ast_pthread_mutex_lock(&framelock);
+               ast_mutex_lock(&framelock);
                if (fr->next)
                        fr->next->prev = fr->prev;
                if (fr->prev)
                        fr->prev->next = fr->next;
                else
                        headerlist = fr->next;
-               pthread_mutex_unlock(&framelock);
+               ast_mutex_unlock(&framelock);
 #endif                 
                free(fr);
        }
@@ -542,11 +542,11 @@ static int show_frame_stats(int fd, int argc, char *argv[])
        ast_cli(fd, "---------------------------\n");
        ast_cli(fd, "Total allocated headers: %d\n", headers);
        ast_cli(fd, "Queue Dump:\n");
-       ast_pthread_mutex_lock(&framelock);
+       ast_mutex_lock(&framelock);
        for (f=headerlist; f; f = f->next) {
                ast_cli(fd, "%d.  Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
        }
-       pthread_mutex_unlock(&framelock);
+       ast_mutex_unlock(&framelock);
        return RESULT_SUCCESS;
 }
 
diff --git a/image.c b/image.c
index 7ee2b080ac744dacc990c1e7c2b7e3440e40a7fe..1b07b77b25a7b84ac0e9cc522e2c706a817f3fa2 100755 (executable)
--- a/image.c
+++ b/image.c
 #include "astconf.h"
 
 static struct ast_imager *list;
-static pthread_mutex_t listlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t listlock = AST_MUTEX_INITIALIZER;
 
 int ast_image_register(struct ast_imager *img)
 {
        if (option_verbose > 1)
                ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc);
-       ast_pthread_mutex_lock(&listlock);
+       ast_mutex_lock(&listlock);
        img->next = list;
        list = img;
-       ast_pthread_mutex_unlock(&listlock);
+       ast_mutex_unlock(&listlock);
        return 0;
 }
 
 void ast_image_unregister(struct ast_imager *img)
 {
        struct ast_imager *i, *prev = NULL;
-       ast_pthread_mutex_lock(&listlock);
+       ast_mutex_lock(&listlock);
        i = list;
        while(i) {
                if (i == img) {
@@ -62,7 +62,7 @@ void ast_image_unregister(struct ast_imager *img)
                prev = i;
                i = i->next;
        }
-       ast_pthread_mutex_unlock(&listlock);
+       ast_mutex_unlock(&listlock);
        if (i && (option_verbose > 1))
                ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc);
 }
@@ -112,7 +112,7 @@ struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
        int len=0;
        struct ast_frame *f = NULL;
 #if 0 /* We need to have some sort of read-only lock */
-       ast_pthread_mutex_lock(&listlock);
+       ast_mutex_lock(&listlock);
 #endif 
        i = list;
        while(!found && i) {
@@ -152,7 +152,7 @@ struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
        } else
                ast_log(LOG_WARNING, "Image file '%s' not found\n", filename);
 #if 0
-       ast_pthread_mutex_unlock(&listlock);
+       ast_mutex_unlock(&listlock);
 #endif 
        return f;
 }
index 5fe9d22754028438edc1ed78ed9c01f22178f58d..7cd2470e0f32b08dc171cf3d3787bd8bef4b8d07 100755 (executable)
@@ -97,7 +97,7 @@ struct ast_channel {
        /*! If anyone is blocking, this is them */
        pthread_t blocker;                      
        /*! Lock, can be used to lock a channel for some operations */
-       pthread_mutex_t lock;                   
+       ast_mutex_t lock;                       
        /*! Procedure causing blocking */
        char *blockproc;                        
 
index 0ee0fac1d92a1126e97b00a2c40900570114cf93..9b8ebca5c9e9fdbb36d2d9e50aae754da427f088 100755 (executable)
@@ -22,6 +22,8 @@
 #ifndef _ASTERISK_INDICATIONS_H
 #define _ASTERISK_INDICATIONS_H
 
+#include <asterisk/lock.h>
+
 /* forward reference */
 struct ast_channel;
 
@@ -70,6 +72,6 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char* tonelist,
 void ast_playtones_stop(struct ast_channel *chan);
 
 extern struct tone_zone *tone_zones;
-extern pthread_mutex_t tzlock;
+extern ast_mutex_t tzlock;
 
 #endif
index c1a3d9de356f416323eb339f746f3cecb8256e00..30e09a0156bb20cd11929e7660df226d4d221a25 100755 (executable)
@@ -2,25 +2,26 @@
 #define ASTERISK_LINKEDLISTS_H
 
 #include <pthread.h>
+#include <asterisk/lock.h>
 
 #define AST_LIST_LOCK(head)                                            \
-       ast_pthread_mutex_lock(&head->lock) 
+       ast_mutex_lock(&head->lock) 
        
 #define AST_LIST_UNLOCK(head)                                          \
-       ast_pthread_mutex_unlock(&head->lock)
+       ast_mutex_unlock(&head->lock)
 
 #define AST_LIST_HEAD(name, type)                                      \
 struct name {                                                          \
        struct type *first;                                             \
-       pthread_mutex_t lock;                                           \
+       ast_mutex_t lock;                                               \
 }
 
 #define AST_LIST_HEAD_INITIALIZER(head)                                        \
-       { NULL, PTHREAD_MUTEX_INITIALIZER }
+       { NULL, AST_MUTEX_INITIALIZER }
        
 #define AST_LIST_HEAD_SET(head,entry) do {                             \
        (head)->first=(entry);                                          \
-       pthread_mutex_init(&(head)->lock,NULL);                         \
+       ast_pthread_mutex_init(&(head)->lock,NULL);                             \
 } while (0)
 
 #define AST_LIST_ENTRY(type)                                           \
@@ -39,7 +40,7 @@ struct {                                                              \
 
 #define AST_LIST_HEAD_INIT(head) {                                             \
        (head)->first = NULL;                                           \
-       pthread_mutex_init(&(head)->lock,NULL);                         \
+       ast_pthread_mutex_init(&(head)->lock,NULL);                             \
 }
 
 #define AST_LIST_INSERT_AFTER(listelm, elm, field) do {                \
index d27e295b49470026ac32a58b766943a560afeeae..092672cae8434908212abc86fa0bfe64529c0130 100755 (executable)
 // #define AST_MUTEX_INITIALIZER      PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 // #define AST_MUTEX_KIND             PTHREAD_MUTEX_RECURSIVE_NP
 #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-#define AST_MUTEX_INITIALIZER         PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
+#define AST_MUTEX_INITIALIZER         { PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, NULL, 0, NULL, 0 }
 #else
 #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-#define AST_MUTEX_INITIALIZER         PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#define AST_MUTEX_INITIALIZER         { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, NULL, 0, NULL, 0 }
 #else
-#define AST_MUTEX_INITIALIZER         PTHREAD_MUTEX_INITIALIZER
+#define AST_MUTEX_INITIALIZER         { PTHREAD_MUTEX_INITIALIZER, NULL, 0, NULL, 0 }
 #endif
 #endif
 #ifdef PTHREAD_MUTEX_ERRORCHECK_NP
 #define AST_MUTEX_KIND                PTHREAD_MUTEX_ERRORCHECK
 #endif
 
-struct mutex_info {
-       pthread_mutex_t *mutex;
+struct ast_mutex_info {
+       pthread_mutex_t mutex;
        char *file;
        int lineno;
        char *func;
-       struct mutex_info *next;
+       pthread_t thread;
 };
 
-static inline int ast_pthread_mutex_init(pthread_mutex_t *t) {
+typedef struct ast_mutex_info ast_mutex_t;
+
+static inline int ast_mutex_init(ast_mutex_t *t) {
        static pthread_mutexattr_t  attr;
        static int  init = 1;
+       int res;
        extern int  pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int);
 
        if (init) {
@@ -60,45 +63,87 @@ static inline int ast_pthread_mutex_init(pthread_mutex_t *t) {
                pthread_mutexattr_setkind_np(&attr, AST_MUTEX_KIND);
                init = 0;
        }
-       return pthread_mutex_init(t, &attr);
+       res = pthread_mutex_init(&t->mutex, &attr);
+       t->file = NULL;
+       t->lineno = 0;
+       t->func = 0;
+       t->thread  = 0;
+       return res;
 }
 
-static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *func, pthread_mutex_t *t) {
+static inline int ast_pthread_mutex_init(ast_mutex_t *t, pthread_mutexattr_t *attr) 
+{
        int res;
-       int tries = TRIES;
-       do {
-               res = pthread_mutex_trylock(t);
-               /* If we can't run, yield */
-               if (res) {
-                       sched_yield();
-                       usleep(1);
-               }
-       } while(res && tries--);
-       if (res) {
-               fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n", 
-                               filename, lineno, func, strerror(res));
-               if ((res = pthread_mutex_lock(t)))
-                        fprintf(stderr, "%s line %d (%s): Error waiting for mutex: %s\n", 
-                               filename, lineno, func, strerror(res));
-                else
-                       fprintf(stderr, "%s line %d (%s): Got it eventually...\n",
-                              filename, lineno, func);
+       res = pthread_mutex_init(&t->mutex, attr);
+       t->file = NULL;
+       t->lineno = 0;
+       t->func = 0;
+       t->thread  = 0;
+       return res;
+}
+
+static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *func, ast_mutex_t *t) {
+       int res;
+       res = pthread_mutex_lock(&t->mutex);
+       if (!res) {
+               t->file = filename;
+               t->lineno = lineno;
+               t->func = func;
+               t->thread = pthread_self();
+       } else {
+               fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n",
+                       filename, lineno, func, strerror(errno));
        }
        return res;
 }
 
-#define ast_pthread_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+#define ast_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
 
-static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *func, pthread_mutex_t *t) {
+static inline int __ast_pthread_mutex_trylock(char *filename, int lineno, char *func, ast_mutex_t *t) {
        int res;
-       res = pthread_mutex_unlock(t);
+       res = pthread_mutex_trylock(&t->mutex);
+       if (!res) {
+               t->file = filename;
+               t->lineno = lineno;
+               t->func = func;
+               t->thread = pthread_self();
+       }
+       return res;
+}
+
+#define ast_mutex_trylock(a) __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+
+static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *func, ast_mutex_t *t) {
+       int res;
+       /* Assumes lock is actually held */
+       t->file = NULL;
+       t->lineno = 0;
+       t->func = NULL;
+       t->thread = 0;
+       res = pthread_mutex_unlock(&t->mutex);
        if (res) 
                fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n", 
                                filename, lineno, func, strerror(res));
        return res;
 }
 
-#define ast_pthread_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+#define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+
+static inline int __ast_pthread_mutex_destroy(char *filename, int lineno, char *func, ast_mutex_t *t)
+{
+       int res;
+       t->file = NULL;
+       t->lineno = 0;
+       t->func = NULL;
+       t->thread = 0;
+       res = pthread_mutex_destroy(&t->mutex);
+       if (res) 
+               fprintf(stderr, "%s line %d (%s): Error destroying mutex: %s\n",
+                               filename, lineno, func, strerror(res));
+       return res;
+}
+
+#define ast_mutex_destroy(a) __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
 
 #else
 
@@ -109,10 +154,44 @@ static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *f
 #define AST_MUTEX_KIND             PTHREAD_NORMAL
 #endif
 
-#define ast_pthread_mutex_init(mutex) pthread_mutex_init(mutex, NULL)
-#define ast_pthread_mutex_lock pthread_mutex_lock
-#define ast_pthread_mutex_unlock pthread_mutex_unlock
+typedef pthread_mutex_t ast_mutex_t;
+
+static inline int ast_mutex_lock(ast_mutex_t *t)
+{
+       return pthread_mutex_lock(t);
+}
+
+static inline int ast_mutex_unlock(ast_mutex_t *t)
+{
+       return pthread_mutex_unlock(t);
+}
+
+static inline int ast_mutex_trylock(ast_mutex_t *t)
+{
+       return pthread_mutex_trylock(t);
+}
+
+static inline int ast_pthread_mutex_init(ast_mutex_t *t, const pthread_mutexattr_t *mutexattr)
+{
+       return pthread_mutex_init(t, mutexattr);
+}
+
+static inline int ast_mutex_init(ast_mutex_t *t)
+{
+       return pthread_mutex_init(t, NULL);
+}
 
+static inline int ast_mutex_destroy(ast_mutex_t *t)
+{
+       return pthread_mutex_destroy(t);
+}
 #endif
 
+#define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t
+#define pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock
+#define pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock
+#define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock
+#define pthread_mutex_init use_ast_pthread_mutex_init_instead_of_pthread_mutex_init
+#define pthread_mutex_destroy use_ast_pthread_mutex_destroy_instead_of_pthread_mutex_destroy
+
 #endif
index d5171ecc2e009f376bad0f02b382b0a77a8ac505..66da69017926871b9a342de2301397ba5d2a5e13 100755 (executable)
@@ -23,6 +23,8 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+#include <asterisk/lock.h>
+
 /* 
  * Call management packages are text fields of the form a: b.  There is
  * always exactly one space after the colon.
@@ -53,7 +55,7 @@
 
 struct mansession {
        pthread_t t;
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
        struct sockaddr_in sin;
        int fd;
        int blocking;
index 39eabce8e6b74c7a483593893748728b4c373f3b..b7a5184e8fc5bd5e2f9dc531cea71ff517457e24 100755 (executable)
@@ -152,7 +152,7 @@ void ast_unregister_atexit(void (*func)(void));
                                                                struct localuser *next; \
                                                        }
 
-#define LOCAL_USER_DECL static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER; \
+#define LOCAL_USER_DECL static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER; \
                                                static struct localuser *localusers = NULL; \
                                                static int localusecnt = 0;
 
@@ -162,18 +162,18 @@ void ast_unregister_atexit(void (*func)(void));
                ast_log(LOG_WARNING, "Out of memory\n"); \
                return -1; \
        } \
-       pthread_mutex_lock(&localuser_lock); \
+       ast_mutex_lock(&localuser_lock); \
        u->chan = chan; \
        u->next = localusers; \
        localusers = u; \
        localusecnt++; \
-       pthread_mutex_unlock(&localuser_lock); \
+       ast_mutex_unlock(&localuser_lock); \
        ast_update_use_count(); \
 }
 
 #define LOCAL_USER_REMOVE(u) { \
        struct localuser *uc, *ul = NULL; \
-       pthread_mutex_lock(&localuser_lock); \
+       ast_mutex_lock(&localuser_lock); \
        uc = localusers; \
        while (uc) { \
                if (uc == u) { \
@@ -188,13 +188,13 @@ void ast_unregister_atexit(void (*func)(void));
        }\
        free(u); \
        localusecnt--; \
-       pthread_mutex_unlock(&localuser_lock); \
+       ast_mutex_unlock(&localuser_lock); \
        ast_update_use_count(); \
 }
 
 #define STANDARD_HANGUP_LOCALUSERS { \
        struct localuser *u, *ul; \
-       pthread_mutex_lock(&localuser_lock); \
+       ast_mutex_lock(&localuser_lock); \
        u = localusers; \
        while(u) { \
                ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD); \
@@ -202,14 +202,14 @@ void ast_unregister_atexit(void (*func)(void));
                u = u->next; \
                free(ul); \
        } \
-       pthread_mutex_unlock(&localuser_lock); \
+       ast_mutex_unlock(&localuser_lock); \
        localusecnt=0; \
 }
 
 #define STANDARD_USECOUNT(res) { \
-       pthread_mutex_lock(&localuser_lock); \
+       ast_mutex_lock(&localuser_lock); \
        res = localusecnt; \
-       pthread_mutex_unlock(&localuser_lock); \
+       ast_mutex_unlock(&localuser_lock); \
 }
        
        
index 62500a790448fd3a3249e976eddb9c7e0450b22a..180b948b27904aba6cefabf302d4badad05cb852 100755 (executable)
@@ -27,9 +27,6 @@
 #include <asterisk/channel.h>
 #include <asterisk/logger.h>
 
-#define PTHREAD_MUTEX_LOCK(a) ast_pthread_mutex_lock(a)
-#define PTHREAD_MUTEX_UNLOCK(a) ast_pthread_mutex_unlock(a)
-
 struct playtones_item {
        int freq1;
        int freq2;
@@ -213,7 +210,7 @@ static struct tone_zone *current_tonezone;
 
 /* Protect the tone_zones list (highly unlikely that two things would change
  * it at the same time, but still! */
-pthread_mutex_t tzlock = AST_MUTEX_INITIALIZER;
+ast_mutex_t tzlock = AST_MUTEX_INITIALIZER;
 
 /* Set global indication country */
 int ast_set_indication_country(const char *country)
@@ -243,7 +240,7 @@ struct tone_zone *ast_get_indication_zone(const char *country)
        if (country == NULL)
                return 0;       /* not a single country insight */
 
-       if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return 0;
        }
@@ -255,12 +252,12 @@ struct tone_zone *ast_get_indication_zone(const char *country)
                                        country = tz->alias;
                                        break;
                                }
-                               PTHREAD_MUTEX_UNLOCK(&tzlock);
+                               ast_mutex_unlock(&tzlock);
                                return tz;
                        }
                }
        } while (++alias_loop<20 && tz);
-       PTHREAD_MUTEX_UNLOCK(&tzlock);
+       ast_mutex_unlock(&tzlock);
        if (alias_loop==20)
                ast_log(LOG_NOTICE,"Alias loop for '%s' forcefull broken\n",country);
        /* nothing found, sorry */
@@ -280,19 +277,19 @@ struct tone_zone_sound *ast_get_indication_tone(const struct tone_zone *zone, co
        if (zone == NULL)
                return 0;       /* not a single country insight */
 
-       if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return 0;
        }
        for (ts=zone->tones; ts; ts=ts->next) {
                if (strcasecmp(indication,ts->name)==0) {
                        /* found indication! */
-                       PTHREAD_MUTEX_UNLOCK(&tzlock);
+                       ast_mutex_unlock(&tzlock);
                        return ts;
                }
        }
        /* nothing found, sorry */
-       PTHREAD_MUTEX_UNLOCK(&tzlock);
+       ast_mutex_unlock(&tzlock);
        return 0;
 }
 
@@ -316,7 +313,7 @@ int ast_register_indication_country(struct tone_zone *zone)
 {
        struct tone_zone *tz,*pz;
 
-       if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return -1;
        }
@@ -333,7 +330,7 @@ int ast_register_indication_country(struct tone_zone *zone)
                                current_tonezone = zone;
                        /* now free the previous zone */
                        free_zone(tz);
-                       PTHREAD_MUTEX_UNLOCK(&tzlock);
+                       ast_mutex_unlock(&tzlock);
                        return 0;
                }
        }
@@ -343,7 +340,7 @@ int ast_register_indication_country(struct tone_zone *zone)
                pz->next = zone;
        else
                tone_zones = zone;
-       PTHREAD_MUTEX_UNLOCK(&tzlock);
+       ast_mutex_unlock(&tzlock);
 
        ast_verbose(VERBOSE_PREFIX_3 "Registered indication country '%s'\n",zone->country);
        return 0;
@@ -356,7 +353,7 @@ int ast_unregister_indication_country(const char *country)
        struct tone_zone *tz, *pz = NULL, *tmp;
        int res = -1;
 
-       if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return -1;
        }
@@ -387,7 +384,7 @@ int ast_unregister_indication_country(const char *country)
                        tz = tz->next;
                }
        }
-       PTHREAD_MUTEX_UNLOCK(&tzlock);
+       ast_mutex_unlock(&tzlock);
        return res;
 }
 
@@ -401,7 +398,7 @@ int ast_register_indication(struct tone_zone *zone, const char *indication, cons
        if (zone->alias[0])
                return -1;
 
-       if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return -2;
        }
@@ -418,7 +415,7 @@ int ast_register_indication(struct tone_zone *zone, const char *indication, cons
                ts = malloc(sizeof(struct tone_zone_sound));
                if (!ts) {
                        ast_log(LOG_WARNING, "Out of memory\n");
-                       PTHREAD_MUTEX_UNLOCK(&tzlock);
+                       ast_mutex_unlock(&tzlock);
                        return -2;
                }
                ts->next = NULL;
@@ -427,14 +424,14 @@ int ast_register_indication(struct tone_zone *zone, const char *indication, cons
        ts->data = strdup(tonelist);
        if (ts->name==NULL || ts->data==NULL) {
                ast_log(LOG_WARNING, "Out of memory\n");
-               PTHREAD_MUTEX_UNLOCK(&tzlock);
+               ast_mutex_unlock(&tzlock);
                return -2;
        }
        if (ps)
                ps->next = ts;
        else
                zone->tones = ts;
-       PTHREAD_MUTEX_UNLOCK(&tzlock);
+       ast_mutex_unlock(&tzlock);
        return 0;
 }
 
@@ -448,7 +445,7 @@ int ast_unregister_indication(struct tone_zone *zone, const char *indication)
        if (zone->alias[0])
                return -1;
 
-       if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return -1;
        }
@@ -474,6 +471,6 @@ int ast_unregister_indication(struct tone_zone *zone, const char *indication)
                }
        }
        /* indication not found, goodbye */
-       PTHREAD_MUTEX_UNLOCK(&tzlock);
+       ast_mutex_unlock(&tzlock);
        return res;
 }
index 757352f78eb59a70aa6fcb83861672a2c69f5d2f..de5674c12d7fc32d7557391a9ca24990c20fea38 100755 (executable)
--- a/loader.c
+++ b/loader.c
@@ -94,7 +94,7 @@ static struct loadupdate {
        struct loadupdate *next;
 } *updaters = NULL;
 
-static pthread_mutex_t modlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t modlock = AST_MUTEX_INITIALIZER;
 
 static struct module *module_list=NULL;
 
@@ -102,7 +102,7 @@ int ast_unload_resource(char *resource_name, int force)
 {
        struct module *m, *ml = NULL;
        int res = -1;
-       if (ast_pthread_mutex_lock(&modlock))
+       if (ast_mutex_lock(&modlock))
                ast_log(LOG_WARNING, "Failed to lock\n");
        m = module_list;
        while(m) {
@@ -112,7 +112,7 @@ int ast_unload_resource(char *resource_name, int force)
                                        ast_log(LOG_WARNING, "Warning:  Forcing removal of module %s with use count %d\n", resource_name, res);
                                else {
                                        ast_log(LOG_WARNING, "Soft unload failed, '%s' has use count %d\n", resource_name, res);
-                                       ast_pthread_mutex_unlock(&modlock);
+                                       ast_mutex_unlock(&modlock);
                                        return -1;
                                }
                        }
@@ -120,7 +120,7 @@ int ast_unload_resource(char *resource_name, int force)
                        if (res) {
                                ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name);
                                if (force <= AST_FORCE_FIRM) {
-                                       ast_pthread_mutex_unlock(&modlock);
+                                       ast_mutex_unlock(&modlock);
                                        return -1;
                                } else
                                        ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n");
@@ -135,7 +135,7 @@ int ast_unload_resource(char *resource_name, int force)
                ml = m;
                m = m->next;
        }
-       ast_pthread_mutex_unlock(&modlock);
+       ast_mutex_unlock(&modlock);
        ast_update_use_count();
        return res;
 }
@@ -150,7 +150,7 @@ void ast_module_reload(void)
        ast_rtp_reload();
        time(&ast_lastreloadtime);
 
-       ast_pthread_mutex_lock(&modlock);
+       ast_mutex_lock(&modlock);
        m = module_list;
        while(m) {
                if (m->reload) {
@@ -160,7 +160,7 @@ void ast_module_reload(void)
                }
                m = m->next;
        }
-       ast_pthread_mutex_unlock(&modlock);
+       ast_mutex_unlock(&modlock);
 }
 
 int ast_load_resource(char *resource_name)
@@ -198,13 +198,13 @@ int ast_load_resource(char *resource_name)
 #endif
        }
        
-       if (ast_pthread_mutex_lock(&modlock))
+       if (ast_mutex_lock(&modlock))
                ast_log(LOG_WARNING, "Failed to lock\n");
        m = module_list;
        while(m) {
                if (!strcasecmp(m->resource, resource_name)) {
                        ast_log(LOG_WARNING, "Module '%s' already exists\n", resource_name);
-                       ast_pthread_mutex_unlock(&modlock);
+                       ast_mutex_unlock(&modlock);
                        return -1;
                }
                m = m->next;
@@ -212,7 +212,7 @@ int ast_load_resource(char *resource_name)
        m = malloc(sizeof(struct module));      
        if (!m) {
                ast_log(LOG_WARNING, "Out of memory\n");
-               ast_pthread_mutex_unlock(&modlock);
+               ast_mutex_unlock(&modlock);
                return -1;
        }
        strncpy(m->resource, resource_name, sizeof(m->resource)-1);
@@ -225,7 +225,7 @@ int ast_load_resource(char *resource_name)
        if (!m->lib) {
                ast_log(LOG_WARNING, "%s\n", dlerror());
                free(m);
-               ast_pthread_mutex_unlock(&modlock);
+               ast_mutex_unlock(&modlock);
                return -1;
        }
        m->load_module = dlsym(m->lib, "load_module");
@@ -279,7 +279,7 @@ int ast_load_resource(char *resource_name)
                ast_log(LOG_WARNING, "%d error(s) loading module %s, aborted\n", errors, fn);
                dlclose(m->lib);
                free(m);
-               ast_pthread_mutex_unlock(&modlock);
+               ast_mutex_unlock(&modlock);
                return -1;
        }
        if (!fully_booted) {
@@ -294,7 +294,7 @@ int ast_load_resource(char *resource_name)
        m->next = module_list;
        
        module_list = m;
-       ast_pthread_mutex_unlock(&modlock);
+       ast_mutex_unlock(&modlock);
        if ((res = m->load_module())) {
                ast_log(LOG_WARNING, "%s: load_module failed, returning %d\n", m->resource, res);
                ast_unload_resource(resource_name, 0);
@@ -307,7 +307,7 @@ int ast_load_resource(char *resource_name)
 static int ast_resource_exists(char *resource)
 {
        struct module *m;
-       if (ast_pthread_mutex_lock(&modlock))
+       if (ast_mutex_lock(&modlock))
                ast_log(LOG_WARNING, "Failed to lock\n");
        m = module_list;
        while(m) {
@@ -315,7 +315,7 @@ static int ast_resource_exists(char *resource)
                        break;
                m = m->next;
        }
-       ast_pthread_mutex_unlock(&modlock);
+       ast_mutex_unlock(&modlock);
        if (m)
                return -1;
        else
@@ -414,14 +414,14 @@ void ast_update_use_count(void)
        /* Notify any module monitors that the use count for a 
           resource has changed */
        struct loadupdate *m;
-       if (ast_pthread_mutex_lock(&modlock))
+       if (ast_mutex_lock(&modlock))
                ast_log(LOG_WARNING, "Failed to lock\n");
        m = updaters;
        while(m) {
                m->updater();
                m = m->next;
        }
-       ast_pthread_mutex_unlock(&modlock);
+       ast_mutex_unlock(&modlock);
        
 }
 
@@ -429,7 +429,7 @@ int ast_update_module_list(int (*modentry)(char *module, char *description, int
 {
        struct module *m;
        int unlock = -1;
-       if (pthread_mutex_trylock(&modlock))
+       if (ast_mutex_trylock(&modlock))
                unlock = 0;
        m = module_list;
        while(m) {
@@ -437,7 +437,7 @@ int ast_update_module_list(int (*modentry)(char *module, char *description, int
                m = m->next;
        }
        if (unlock)
-               ast_pthread_mutex_unlock(&modlock);
+               ast_mutex_unlock(&modlock);
        return 0;
 }
 
@@ -447,11 +447,11 @@ int ast_loader_register(int (*v)(void))
        /* XXX Should be more flexible here, taking > 1 verboser XXX */
        if ((tmp = malloc(sizeof (struct loadupdate)))) {
                tmp->updater = v;
-               if (ast_pthread_mutex_lock(&modlock))
+               if (ast_mutex_lock(&modlock))
                        ast_log(LOG_WARNING, "Failed to lock\n");
                tmp->next = updaters;
                updaters = tmp;
-               ast_pthread_mutex_unlock(&modlock);
+               ast_mutex_unlock(&modlock);
                return 0;
        }
        return -1;
@@ -461,7 +461,7 @@ int ast_loader_unregister(int (*v)(void))
 {
        int res = -1;
        struct loadupdate *tmp, *tmpl=NULL;
-       if (ast_pthread_mutex_lock(&modlock))
+       if (ast_mutex_lock(&modlock))
                ast_log(LOG_WARNING, "Failed to lock\n");
        tmp = updaters;
        while(tmp) {
@@ -477,6 +477,6 @@ int ast_loader_unregister(int (*v)(void))
        }
        if (tmp)
                res = 0;
-       ast_pthread_mutex_unlock(&modlock);
+       ast_mutex_unlock(&modlock);
        return res;
 }
index 66375de27a1ad01f38a3a3be1cd62e86daccdf67..30d37b11faf573c9fbcc4acbb0df0a4621951b3b 100755 (executable)
--- a/logger.c
+++ b/logger.c
@@ -31,8 +31,8 @@
 
 #define MAX_MSG_QUEUE 200
 
-static pthread_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
-static pthread_mutex_t loglock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t loglock = AST_MUTEX_INITIALIZER;
 
 static struct msglist {
        char *msg;
@@ -131,7 +131,7 @@ static void init_logger_chain(void)
        struct ast_config *cfg;
        struct ast_variable *var;
 
-       ast_pthread_mutex_lock(&loglock);
+       ast_mutex_lock(&loglock);
 
        /* Free anything that is here */
        f = logfiles;
@@ -145,13 +145,13 @@ static void init_logger_chain(void)
 
        logfiles = NULL;
 
-       ast_pthread_mutex_unlock(&loglock);
+       ast_mutex_unlock(&loglock);
        cfg = ast_load("logger.conf");
-       ast_pthread_mutex_lock(&loglock);
+       ast_mutex_lock(&loglock);
        
        /* If no config file, we're fine */
        if (!cfg) {
-               ast_pthread_mutex_unlock(&loglock);
+               ast_mutex_unlock(&loglock);
                return;
        }
        var = ast_variable_browse(cfg, "logfiles");
@@ -168,7 +168,7 @@ static void init_logger_chain(void)
                logfiles = make_logfile("ignore", "", -1);
        }
        ast_destroy(cfg);
-       ast_pthread_mutex_unlock(&loglock);
+       ast_mutex_unlock(&loglock);
        
 
 }
@@ -199,13 +199,13 @@ int init_logger(void)
 int reload_logger(void)
 {
        char tmp[AST_CONFIG_MAX_PATH];
-       ast_pthread_mutex_lock(&loglock);
+       ast_mutex_lock(&loglock);
        if (eventlog)
                fclose(eventlog);
        mkdir((char *)ast_config_AST_LOG_DIR, 0755);
        snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
        eventlog = fopen((char *)tmp, "a");
-       ast_pthread_mutex_unlock(&loglock);
+       ast_mutex_unlock(&loglock);
 
        if (eventlog) {
                init_logger_chain();
@@ -235,7 +235,7 @@ extern void ast_log(int level, const char *file, int line, const char *function,
        if (!option_verbose && !option_debug && (!level)) {
                return;
        }
-       ast_pthread_mutex_lock(&loglock);
+       ast_mutex_lock(&loglock);
        if (level == 1 /* Event */) {
                time(&t);
                localtime_r(&t,&tm);
@@ -285,7 +285,7 @@ extern void ast_log(int level, const char *file, int line, const char *function,
                        fflush(stdout);
                }
        }
-       ast_pthread_mutex_unlock(&loglock);
+       ast_mutex_unlock(&loglock);
 }
 
 extern void ast_verbose(const char *fmt, ...)
@@ -297,7 +297,7 @@ extern void ast_verbose(const char *fmt, ...)
        struct verb *v;
        va_list ap;
        va_start(ap, fmt);
-       ast_pthread_mutex_lock(&msglist_lock);
+       ast_mutex_lock(&msglist_lock);
        vsnprintf(stuff + pos, sizeof(stuff) - pos, fmt, ap);
        opos = pos;
        pos = strlen(stuff);
@@ -346,20 +346,20 @@ extern void ast_verbose(const char *fmt, ...)
        else 
                replacelast = pos = 0;
        va_end(ap);
-       ast_pthread_mutex_unlock(&msglist_lock);
+       ast_mutex_unlock(&msglist_lock);
 }
 
 int ast_verbose_dmesg(void (*v)(const char *string, int opos, int replacelast, int complete))
 {
        struct msglist *m;
        m = list;
-       ast_pthread_mutex_lock(&msglist_lock);
+       ast_mutex_lock(&msglist_lock);
        while(m) {
                /* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
                v(m->msg, 0, 0, 1);
                m = m->next;
        }
-       ast_pthread_mutex_unlock(&msglist_lock);
+       ast_mutex_unlock(&msglist_lock);
        return 0;
 }
 
@@ -370,7 +370,7 @@ int ast_register_verbose(void (*v)(const char *string, int opos, int replacelast
        /* XXX Should be more flexible here, taking > 1 verboser XXX */
        if ((tmp = malloc(sizeof (struct verb)))) {
                tmp->verboser = v;
-               ast_pthread_mutex_lock(&msglist_lock);
+               ast_mutex_lock(&msglist_lock);
                tmp->next = verboser;
                verboser = tmp;
                m = list;
@@ -379,7 +379,7 @@ int ast_register_verbose(void (*v)(const char *string, int opos, int replacelast
                        v(m->msg, 0, 0, 1);
                        m = m->next;
                }
-               ast_pthread_mutex_unlock(&msglist_lock);
+               ast_mutex_unlock(&msglist_lock);
                return 0;
        }
        return -1;
@@ -389,7 +389,7 @@ int ast_unregister_verbose(void (*v)(const char *string, int opos, int replacela
 {
        int res = -1;
        struct verb *tmp, *tmpl=NULL;
-       ast_pthread_mutex_lock(&msglist_lock);
+       ast_mutex_lock(&msglist_lock);
        tmp = verboser;
        while(tmp) {
                if (tmp->verboser == v) {
@@ -405,6 +405,6 @@ int ast_unregister_verbose(void (*v)(const char *string, int opos, int replacela
        }
        if (tmp)
                res = 0;
-       ast_pthread_mutex_unlock(&msglist_lock);
+       ast_mutex_unlock(&msglist_lock);
        return res;
 }
index 3cbdb1d7401d4288e109817609d80dd64fadfbe8..1162c18fc11082463bdf8523e0c488c7dd50051b 100755 (executable)
--- a/manager.c
+++ b/manager.c
@@ -42,7 +42,7 @@ static int enabled = 0;
 static int portno = DEFAULT_MANAGER_PORT;
 static int asock = -1;
 static pthread_t t;
-static pthread_mutex_t sessionlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t sessionlock = AST_MUTEX_INITIALIZER;
 
 static struct permalias {
        int num;
@@ -60,19 +60,19 @@ static struct permalias {
 
 static struct mansession *sessions = NULL;
 static struct manager_action *first_action = NULL;
-static pthread_mutex_t actionlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t actionlock = AST_MUTEX_INITIALIZER;
 
 static int handle_showmancmds(int fd, int argc, char *argv[])
 {
        struct manager_action *cur = first_action;
 
-       ast_pthread_mutex_lock(&actionlock);
+       ast_mutex_lock(&actionlock);
        while(cur) { /* Walk the list of actions */
                ast_cli(fd, "\t%s  %s\r\n",cur->action, cur->synopsis);
                cur = cur->next;
        }
 
-       ast_pthread_mutex_unlock(&actionlock);
+       ast_mutex_unlock(&actionlock);
        return RESULT_SUCCESS;
 }
 
@@ -80,7 +80,7 @@ static int handle_showmanconn(int fd, int argc, char *argv[])
 {
        struct mansession *s;
 
-       ast_pthread_mutex_lock(&sessionlock);
+       ast_mutex_lock(&sessionlock);
        s = sessions;
        ast_cli(fd, "  Username\tIP Address\n");
        while(s) {
@@ -88,7 +88,7 @@ static int handle_showmanconn(int fd, int argc, char *argv[])
                s = s->next;
        }
 
-       ast_pthread_mutex_unlock(&sessionlock);
+       ast_mutex_unlock(&sessionlock);
        return RESULT_SUCCESS;
 }
 
@@ -112,7 +112,7 @@ static struct ast_cli_entry show_manconn_cli =
 static void destroy_session(struct mansession *s)
 {
        struct mansession *cur, *prev = NULL;
-       ast_pthread_mutex_lock(&sessionlock);
+       ast_mutex_lock(&sessionlock);
        cur = sessions;
        while(cur) {
                if (cur == s)
@@ -130,7 +130,7 @@ static void destroy_session(struct mansession *s)
                free(s);
        } else
                ast_log(LOG_WARNING, "Trying to delete non-existant session %p?\n", s);
-       ast_pthread_mutex_unlock(&sessionlock);
+       ast_mutex_unlock(&sessionlock);
        
 }
 
@@ -147,21 +147,21 @@ char *astman_get_header(struct message *m, char *var)
 
 void astman_send_error(struct mansession *s, char *error)
 {
-       ast_pthread_mutex_lock(&s->lock);
+       ast_mutex_lock(&s->lock);
        ast_cli(s->fd, "Response: Error\r\n");
        ast_cli(s->fd, "Message: %s\r\n\r\n", error);
-       ast_pthread_mutex_unlock(&s->lock);
+       ast_mutex_unlock(&s->lock);
 }
 
 void astman_send_response(struct mansession *s, char *resp, char *msg)
 {
-       ast_pthread_mutex_lock(&s->lock);
+       ast_mutex_lock(&s->lock);
        ast_cli(s->fd, "Response: %s\r\n", resp);
        if (msg)
                ast_cli(s->fd, "Message: %s\r\n\r\n", msg);
        else
                ast_cli(s->fd, "\r\n");
-       ast_pthread_mutex_unlock(&s->lock);
+       ast_mutex_unlock(&s->lock);
 }
 
 void astman_send_ack(struct mansession *s, char *msg)
@@ -385,15 +385,15 @@ static int action_redirect(struct mansession *s, struct message *m)
 static int action_command(struct mansession *s, struct message *m)
 {
        char *cmd = astman_get_header(m, "Command");
-       ast_pthread_mutex_lock(&s->lock);
+       ast_mutex_lock(&s->lock);
        s->blocking = 1;
-       ast_pthread_mutex_unlock(&s->lock);
+       ast_mutex_unlock(&s->lock);
        ast_cli(s->fd, "Response: Follows\r\n");
        ast_cli_command(s->fd, cmd);
        ast_cli(s->fd, "--END COMMAND--\r\n\r\n");
-       ast_pthread_mutex_lock(&s->lock);
+       ast_mutex_lock(&s->lock);
        s->blocking = 0;
-       ast_pthread_mutex_unlock(&s->lock);
+       ast_mutex_unlock(&s->lock);
        return 0;
 }
 
@@ -549,9 +549,9 @@ static int process_message(struct mansession *s, struct message *m)
                        authtype = astman_get_header(m, "AuthType");
                        if (!strcasecmp(authtype, "MD5")) {
                                if (!s->challenge || !strlen(s->challenge)) {
-                                       ast_pthread_mutex_lock(&s->lock);
+                                       ast_mutex_lock(&s->lock);
                                        snprintf(s->challenge, sizeof(s->challenge), "%d", rand());
-                                       ast_pthread_mutex_unlock(&s->lock);
+                                       ast_mutex_unlock(&s->lock);
                                }
                                ast_cli(s->fd, "Response: Success\r\nChallenge: %s\r\n\r\n", s->challenge);
                                return 0;
@@ -619,9 +619,9 @@ static int get_input(struct mansession *s, char *output)
        if (res < 0) {
                ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
        } else if (res > 0) {
-               ast_pthread_mutex_lock(&s->lock);
+               ast_mutex_lock(&s->lock);
                res = read(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen);
-               ast_pthread_mutex_unlock(&s->lock);
+               ast_mutex_unlock(&s->lock);
                if (res < 1)
                        return -1;
        }
@@ -636,9 +636,9 @@ static void *session_do(void *data)
        struct message m;
        int res;
        
-       ast_pthread_mutex_lock(&s->lock);
+       ast_mutex_lock(&s->lock);
        ast_cli(s->fd, "Asterisk Call Manager/1.0\r\n");
-       ast_pthread_mutex_unlock(&s->lock);
+       ast_mutex_unlock(&s->lock);
        memset(&m, 0, sizeof(&m));
        for (;;) {
                res = get_input(s, m.headers[m.hdrcount]);
@@ -702,12 +702,12 @@ static void *accept_thread(void *ignore)
                } 
                memset(s, 0, sizeof(struct mansession));
                memcpy(&s->sin, &sin, sizeof(sin));
-               ast_pthread_mutex_init(&s->lock);
+               ast_mutex_init(&s->lock);
                s->fd = as;
-               ast_pthread_mutex_lock(&sessionlock);
+               ast_mutex_lock(&sessionlock);
                s->next = sessions;
                sessions = s;
-               ast_pthread_mutex_unlock(&sessionlock);
+               ast_mutex_unlock(&sessionlock);
                if (pthread_create(&t, &attr, session_do, s))
                        destroy_session(s);
        }
@@ -721,11 +721,11 @@ int manager_event(int category, char *event, char *fmt, ...)
        char tmp[4096];
        va_list ap;
 
-       ast_pthread_mutex_lock(&sessionlock);
+       ast_mutex_lock(&sessionlock);
        s = sessions;
        while(s) {
                if ((s->readperm & category) == category) {
-                       ast_pthread_mutex_lock(&s->lock);
+                       ast_mutex_lock(&s->lock);
                        if (!s->blocking) {
                                ast_cli(s->fd, "Event: %s\r\n", event);
                                va_start(ap, fmt);
@@ -734,31 +734,31 @@ int manager_event(int category, char *event, char *fmt, ...)
                                write(s->fd, tmp, strlen(tmp));
                                ast_cli(s->fd, "\r\n");
                        }
-                       ast_pthread_mutex_unlock(&s->lock);
+                       ast_mutex_unlock(&s->lock);
                }
                s = s->next;
        }
-       ast_pthread_mutex_unlock(&sessionlock);
+       ast_mutex_unlock(&sessionlock);
        return 0;
 }
 
 int ast_manager_unregister( char *action ) {
        struct manager_action *cur = first_action, *prev = first_action;
 
-       ast_pthread_mutex_lock(&actionlock);
+       ast_mutex_lock(&actionlock);
        while( cur ) {          
                if (!strcasecmp(action, cur->action)) {
                        prev->next = cur->next;
                        free(cur);
                        if (option_verbose > 1) 
                                ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action);
-                       ast_pthread_mutex_unlock(&actionlock);
+                       ast_mutex_unlock(&actionlock);
                        return 0;
                }
                prev = cur;
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&actionlock);
+       ast_mutex_unlock(&actionlock);
        return 0;
 }
 
@@ -774,7 +774,7 @@ int ast_manager_register( char *action, int auth,
 {
        struct manager_action *cur = first_action, *prev = NULL;
 
-       ast_pthread_mutex_lock(&actionlock);
+       ast_mutex_lock(&actionlock);
        while(cur) { /* Walk the list of actions */
                prev = cur; 
                cur = cur->next;
@@ -782,7 +782,7 @@ int ast_manager_register( char *action, int auth,
        cur = malloc( sizeof(struct manager_action) );
        if( !cur ) {
                ast_log(LOG_WARNING, "Manager: out of memory trying to register action\n");
-               ast_pthread_mutex_unlock(&actionlock);
+               ast_mutex_unlock(&actionlock);
                return -1;
        }
        strncpy( cur->action, action, 255 );
@@ -796,7 +796,7 @@ int ast_manager_register( char *action, int auth,
 
        if (option_verbose > 1) 
                ast_verbose(VERBOSE_PREFIX_2 "Manager registered action %s\n", action);
-       ast_pthread_mutex_unlock(&actionlock);
+       ast_mutex_unlock(&actionlock);
        return 0;
 }
 
diff --git a/pbx.c b/pbx.c
index 7e1c0a1ee46ca4371f578635f72c4b12712e6f75..ff1740afe4eafc6acaa15797329a13d17a649110 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -102,7 +102,7 @@ struct ast_context {
        /* Name of the context */
        char name[AST_MAX_EXTENSION];
        /* A lock to prevent multiple threads from clobbering the context */
-       pthread_mutex_t lock;
+       ast_mutex_t lock;
        /* The root of the list of extensions */
        struct ast_exten *root;
        /* Link them together */
@@ -335,18 +335,18 @@ static struct pbx_builtin {
 };
 
 /* Lock for the application list */
-static pthread_mutex_t applock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t applock = AST_MUTEX_INITIALIZER;
 static struct ast_context *contexts = NULL;
 /* Lock for the ast_context list */
-static pthread_mutex_t conlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t conlock = AST_MUTEX_INITIALIZER;
 static struct ast_app *apps = NULL;
 
 /* Lock for switches */
-static pthread_mutex_t switchlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t switchlock = AST_MUTEX_INITIALIZER;
 struct ast_switch *switches = NULL;
 
 /* Lock for extension state notifys */
-static pthread_mutex_t hintlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t hintlock = AST_MUTEX_INITIALIZER;
 static int stateid = 1;
 struct ast_hint *hints = NULL;
 struct ast_state_cb *statecbs = NULL;
@@ -409,7 +409,7 @@ int pbx_exec(struct ast_channel *c, /* Channel */
 struct ast_app *pbx_findapp(char *app) 
 {
        struct ast_app *tmp;
-       if (ast_pthread_mutex_lock(&applock)) {
+       if (ast_mutex_lock(&applock)) {
                ast_log(LOG_WARNING, "Unable to obtain application lock\n");
                return NULL;
        }
@@ -419,14 +419,14 @@ struct ast_app *pbx_findapp(char *app)
                        break;
                tmp = tmp->next;
        }
-       ast_pthread_mutex_unlock(&applock);
+       ast_mutex_unlock(&applock);
        return tmp;
 }
 
 static struct ast_switch *pbx_findswitch(char *sw)
 {
        struct ast_switch *asw;
-       if (ast_pthread_mutex_lock(&switchlock)) {
+       if (ast_mutex_lock(&switchlock)) {
                ast_log(LOG_WARNING, "Unable to obtain application lock\n");
                return NULL;
        }
@@ -436,7 +436,7 @@ static struct ast_switch *pbx_findswitch(char *sw)
                        break;
                asw = asw->next;
        }
-       ast_pthread_mutex_unlock(&switchlock);
+       ast_mutex_unlock(&switchlock);
        return asw;
 }
 
@@ -589,7 +589,7 @@ static int extension_close(char *pattern, char *data, int needmore)
 struct ast_context *ast_context_find(char *name)
 {
        struct ast_context *tmp;
-       ast_pthread_mutex_lock(&conlock);
+       ast_mutex_lock(&conlock);
        if (name) {
                tmp = contexts;
                while(tmp) {
@@ -599,7 +599,7 @@ struct ast_context *ast_context_find(char *name)
                }
        } else
                tmp = contexts;
-       ast_pthread_mutex_unlock(&conlock);
+       ast_mutex_unlock(&conlock);
        return tmp;
 }
 
@@ -1092,7 +1092,7 @@ static int pbx_extension_helper(struct ast_channel *c, char *context, char *exte
        char tmp[80];
        char tmp2[80];
        char tmp3[256];
-       if (ast_pthread_mutex_lock(&conlock)) {
+       if (ast_mutex_lock(&conlock)) {
                ast_log(LOG_WARNING, "Unable to obtain lock\n");
                if ((action == HELPER_EXISTS) || (action == HELPER_CANMATCH) || (action == HELPER_MATCHMORE))
                        return 0;
@@ -1103,20 +1103,20 @@ static int pbx_extension_helper(struct ast_channel *c, char *context, char *exte
        if (e) {
                switch(action) {
                case HELPER_CANMATCH:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        return -1;
                case HELPER_EXISTS:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        return -1;
                case HELPER_MATCHMORE:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        return -1;
                case HELPER_SPAWN:
                        newstack++;
                        /* Fall through */
                case HELPER_EXEC:
                        app = pbx_findapp(e->app);
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        if (app) {
                                if (c->context != context)
                                        strncpy(c->context, context, sizeof(c->context-1));
@@ -1144,19 +1144,19 @@ static int pbx_extension_helper(struct ast_channel *c, char *context, char *exte
        } else if (sw) {
                switch(action) {
                case HELPER_CANMATCH:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        return -1;
                case HELPER_EXISTS:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        return -1;
                case HELPER_MATCHMORE:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        return -1;
                case HELPER_SPAWN:
                        newstack++;
                        /* Fall through */
                case HELPER_EXEC:
-                       pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        if (sw->exec)
                                res = sw->exec(c, context, exten, priority, callerid, newstack, data);
                        else {
@@ -1169,7 +1169,7 @@ static int pbx_extension_helper(struct ast_channel *c, char *context, char *exte
                        return -1;
                }
        } else {
-               pthread_mutex_unlock(&conlock);
+               ast_mutex_unlock(&conlock);
                switch(status) {
                case STATUS_NO_CONTEXT:
                        if ((action != HELPER_EXISTS) && (action != HELPER_MATCHMORE))
@@ -1203,12 +1203,12 @@ static struct ast_exten *ast_hint_extension(struct ast_channel *c, char *context
        char *incstack[AST_PBX_MAX_STACK];
        int stacklen = 0;
 
-       if (ast_pthread_mutex_lock(&conlock)) {
+       if (ast_mutex_lock(&conlock)) {
                ast_log(LOG_WARNING, "Unable to obtain lock\n");
                return NULL;
        }
        e = pbx_find_extension(c, context, exten, PRIORITY_HINT, "", HELPER_EXISTS, incstack, &stacklen, &status, &sw, &data);
-       ast_pthread_mutex_unlock(&conlock);     
+       ast_mutex_unlock(&conlock);     
        return e;
 }
 
@@ -1300,7 +1300,7 @@ int ast_device_state_changed(const char *fmt, ...)
        *rest = 0;
     }
         
-    pthread_mutex_lock(&hintlock);
+    ast_mutex_lock(&hintlock);
 
     list = hints;
     
@@ -1343,7 +1343,7 @@ int ast_device_state_changed(const char *fmt, ...)
        list = list->next;
     }
 
-    pthread_mutex_unlock(&hintlock);
+    ast_mutex_unlock(&hintlock);
     return 1;
 }
                        
@@ -1356,13 +1356,13 @@ int ast_extension_state_add(char *context, char *exten,
 
     /* No context and extension add callback to statecbs list */
     if (!context && !exten) {
-       pthread_mutex_lock(&hintlock);
+       ast_mutex_lock(&hintlock);
 
        cblist = statecbs;
        while (cblist) {
            if (cblist->callback == callback) {
                cblist->data = data;
-               pthread_mutex_unlock(&hintlock);
+               ast_mutex_unlock(&hintlock);
            }
            
            cblist = cblist->next;
@@ -1371,7 +1371,7 @@ int ast_extension_state_add(char *context, char *exten,
        /* Now inserts the callback */
        cblist = malloc(sizeof(struct ast_state_cb));
        if (!cblist) {
-           pthread_mutex_unlock(&hintlock);
+           ast_mutex_unlock(&hintlock);
            return -1;
        }
        memset(cblist, 0, sizeof(struct ast_state_cb));
@@ -1382,7 +1382,7 @@ int ast_extension_state_add(char *context, char *exten,
         cblist->next = statecbs;
        statecbs = cblist;
 
-       pthread_mutex_unlock(&hintlock);
+       ast_mutex_unlock(&hintlock);
        return 0;
     }
 
@@ -1395,7 +1395,7 @@ int ast_extension_state_add(char *context, char *exten,
         return -1;
     }
     
-    pthread_mutex_lock(&hintlock);
+    ast_mutex_lock(&hintlock);
     list = hints;        
     
     while (list) {
@@ -1405,14 +1405,14 @@ int ast_extension_state_add(char *context, char *exten,
     }
 
     if (!list) {
-       pthread_mutex_unlock(&hintlock);
+       ast_mutex_unlock(&hintlock);
        return -1;
     }
 
     /* Now inserts the callback */
     cblist = malloc(sizeof(struct ast_state_cb));
     if (!cblist) {
-       pthread_mutex_unlock(&hintlock);
+       ast_mutex_unlock(&hintlock);
        return -1;
     }
     memset(cblist, 0, sizeof(struct ast_state_cb));
@@ -1423,7 +1423,7 @@ int ast_extension_state_add(char *context, char *exten,
     cblist->next = list->callbacks;
     list->callbacks = cblist;
 
-    pthread_mutex_unlock(&hintlock);
+    ast_mutex_unlock(&hintlock);
     return cblist->id;
 }
 
@@ -1435,7 +1435,7 @@ int ast_extension_state_del(int id, ast_state_cb_type callback)
     if (!id && !callback)
        return -1;
             
-    pthread_mutex_lock(&hintlock);
+    ast_mutex_lock(&hintlock);
 
     /* id is zero is a callback without extension */
     if (!id) {
@@ -1450,14 +1450,14 @@ int ast_extension_state_del(int id, ast_state_cb_type callback)
 
                free(cblist);
 
-               pthread_mutex_unlock(&hintlock);
+               ast_mutex_unlock(&hintlock);
                return 0;
            }
            cbprev = cblist;
            cblist = cblist->next;
        }
 
-        pthread_mutex_lock(&hintlock);
+        ast_mutex_lock(&hintlock);
        return -1;
     }
 
@@ -1475,7 +1475,7 @@ int ast_extension_state_del(int id, ast_state_cb_type callback)
                
                free(cblist);
                
-               pthread_mutex_unlock(&hintlock);
+               ast_mutex_unlock(&hintlock);
                return 0;               
            }           
            cbprev = cblist;                            
@@ -1484,7 +1484,7 @@ int ast_extension_state_del(int id, ast_state_cb_type callback)
        list = list->next;
     }
     
-    pthread_mutex_unlock(&hintlock);
+    ast_mutex_unlock(&hintlock);
     return -1;
 }
 
@@ -1494,13 +1494,13 @@ static int ast_add_hint(struct ast_exten *e)
 
     if (!e) return -1;
     
-    pthread_mutex_lock(&hintlock);
+    ast_mutex_lock(&hintlock);
     list = hints;        
     
     /* Search if hint exists, do nothing */
     while (list) {
        if (list->exten == e) {
-           pthread_mutex_unlock(&hintlock);
+           ast_mutex_unlock(&hintlock);
            return -1;
        }
        list = list->next;    
@@ -1508,7 +1508,7 @@ static int ast_add_hint(struct ast_exten *e)
 
     list = malloc(sizeof(struct ast_hint));
     if (!list) {
-       pthread_mutex_unlock(&hintlock);
+       ast_mutex_unlock(&hintlock);
        return -1;
     }
     /* Initialize and insert new item */
@@ -1518,7 +1518,7 @@ static int ast_add_hint(struct ast_exten *e)
     list->next = hints;
     hints = list;
 
-    pthread_mutex_unlock(&hintlock);
+    ast_mutex_unlock(&hintlock);
     return 0;
 }
 
@@ -1526,19 +1526,19 @@ static int ast_change_hint(struct ast_exten *oe, struct ast_exten *ne)
 { 
     struct ast_hint *list;
 
-    pthread_mutex_lock(&hintlock);
+    ast_mutex_lock(&hintlock);
     
     list = hints;
     
     while(list) {
        if (list->exten == oe) {
            list->exten = ne;
-           pthread_mutex_unlock(&hintlock);    
+           ast_mutex_unlock(&hintlock);        
            return 0;
        }
        list = list->next;
     }
-    pthread_mutex_unlock(&hintlock);
+    ast_mutex_unlock(&hintlock);
 
     return -1;
 }
@@ -1552,7 +1552,7 @@ static int ast_remove_hint(struct ast_exten *e)
     if (!e) 
        return -1;
 
-    pthread_mutex_lock(&hintlock);
+    ast_mutex_lock(&hintlock);
 
     list = hints;    
     while(list) {
@@ -1575,7 +1575,7 @@ static int ast_remove_hint(struct ast_exten *e)
 
            free(list);
            
-           pthread_mutex_unlock(&hintlock);
+           ast_mutex_unlock(&hintlock);
            return 0;
        } else {
            prev = list;
@@ -1583,7 +1583,7 @@ static int ast_remove_hint(struct ast_exten *e)
        }
     }
 
-    pthread_mutex_unlock(&hintlock);
+    ast_mutex_unlock(&hintlock);
     return -1;
 }
 
@@ -1901,7 +1901,7 @@ int ast_context_remove_include2(struct ast_context *con, char *include, char *re
 {
        struct ast_include *i, *pi = NULL;
 
-       if (ast_pthread_mutex_lock(&con->lock)) return -1;
+       if (ast_mutex_lock(&con->lock)) return -1;
 
        /* walk includes */
        i = con->includes;
@@ -1916,7 +1916,7 @@ int ast_context_remove_include2(struct ast_context *con, char *include, char *re
                                con->includes = i->next;
                        /* free include and return */
                        free(i);
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        return 0;
                }
                pi = i;
@@ -1924,7 +1924,7 @@ int ast_context_remove_include2(struct ast_context *con, char *include, char *re
        }
 
        /* we can't find the right include */
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
        return -1;
 }
 
@@ -1973,7 +1973,7 @@ int ast_context_remove_switch2(struct ast_context *con, char *sw, char *data, ch
 {
        struct ast_sw *i, *pi = NULL;
 
-       if (ast_pthread_mutex_lock(&con->lock)) return -1;
+       if (ast_mutex_lock(&con->lock)) return -1;
 
        /* walk switchs */
        i = con->alts;
@@ -1988,7 +1988,7 @@ int ast_context_remove_switch2(struct ast_context *con, char *sw, char *data, ch
                                con->alts = i->next;
                        /* free switch and return */
                        free(i);
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        return 0;
                }
                pi = i;
@@ -1996,7 +1996,7 @@ int ast_context_remove_switch2(struct ast_context *con, char *sw, char *data, ch
        }
 
        /* we can't find the right switch */
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
        return -1;
 }
 
@@ -2045,7 +2045,7 @@ int ast_context_remove_extension2(struct ast_context *con, char *extension, int
 {
        struct ast_exten *exten, *prev_exten = NULL;
 
-       if (ast_pthread_mutex_lock(&con->lock)) return -1;
+       if (ast_mutex_lock(&con->lock)) return -1;
 
        /* go through all extensions in context and search the right one ... */
        exten = con->root;
@@ -2078,7 +2078,7 @@ int ast_context_remove_extension2(struct ast_context *con, char *extension, int
                                        peer = exten;
                                }
 
-                               ast_pthread_mutex_unlock(&con->lock);
+                               ast_mutex_unlock(&con->lock);
                                return 0;
                        } else {
                                /* remove only extension with exten->priority == priority */
@@ -2121,7 +2121,7 @@ int ast_context_remove_extension2(struct ast_context *con, char *extension, int
                                                peer->datad(peer->data);
                                                free(peer);
 
-                                               ast_pthread_mutex_unlock(&con->lock);
+                                               ast_mutex_unlock(&con->lock);
                                                return 0;
                                        } else {
                                                /* this is not right extension, skip to next peer */
@@ -2130,7 +2130,7 @@ int ast_context_remove_extension2(struct ast_context *con, char *extension, int
                                        }
                                }
 
-                               ast_pthread_mutex_unlock(&con->lock);
+                               ast_mutex_unlock(&con->lock);
                                return -1;
                        }
                }
@@ -2140,7 +2140,7 @@ int ast_context_remove_extension2(struct ast_context *con, char *extension, int
        }
 
        /* we can't find right extension */
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
        return -1;
 }
 
@@ -2149,7 +2149,7 @@ int ast_register_application(char *app, int (*execute)(struct ast_channel *, voi
 {
        struct ast_app *tmp, *prev, *cur;
        char tmps[80];
-       if (ast_pthread_mutex_lock(&applock)) {
+       if (ast_mutex_lock(&applock)) {
                ast_log(LOG_ERROR, "Unable to lock application list\n");
                return -1;
        }
@@ -2157,7 +2157,7 @@ int ast_register_application(char *app, int (*execute)(struct ast_channel *, voi
        while(tmp) {
                if (!strcasecmp(app, tmp->name)) {
                        ast_log(LOG_WARNING, "Already have an application '%s'\n", app);
-                       ast_pthread_mutex_unlock(&applock);
+                       ast_mutex_unlock(&applock);
                        return -1;
                }
                tmp = tmp->next;
@@ -2187,19 +2187,19 @@ int ast_register_application(char *app, int (*execute)(struct ast_channel *, voi
                }
        } else {
                ast_log(LOG_WARNING, "Out of memory\n");
-               ast_pthread_mutex_unlock(&applock);
+               ast_mutex_unlock(&applock);
                return -1;
        }
        if (option_verbose > 1)
                ast_verbose( VERBOSE_PREFIX_2 "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps)));
-       ast_pthread_mutex_unlock(&applock);
+       ast_mutex_unlock(&applock);
        return 0;
 }
 
 int ast_register_switch(struct ast_switch *sw)
 {
        struct ast_switch *tmp, *prev=NULL;
-       if (ast_pthread_mutex_lock(&switchlock)) {
+       if (ast_mutex_lock(&switchlock)) {
                ast_log(LOG_ERROR, "Unable to lock switch lock\n");
                return -1;
        }
@@ -2211,7 +2211,7 @@ int ast_register_switch(struct ast_switch *sw)
                tmp = tmp->next;
        }
        if (tmp) {      
-               ast_pthread_mutex_unlock(&switchlock);
+               ast_mutex_unlock(&switchlock);
                ast_log(LOG_WARNING, "Switch '%s' already found\n", sw->name);
                return -1;
        }
@@ -2220,14 +2220,14 @@ int ast_register_switch(struct ast_switch *sw)
                prev->next = sw;
        else
                switches = sw;
-       ast_pthread_mutex_unlock(&switchlock);
+       ast_mutex_unlock(&switchlock);
        return 0;
 }
 
 void ast_unregister_switch(struct ast_switch *sw)
 {
        struct ast_switch *tmp, *prev=NULL;
-       if (ast_pthread_mutex_lock(&switchlock)) {
+       if (ast_mutex_lock(&switchlock)) {
                ast_log(LOG_ERROR, "Unable to lock switch lock\n");
                return;
        }
@@ -2244,7 +2244,7 @@ void ast_unregister_switch(struct ast_switch *sw)
                prev = tmp;
                tmp = tmp->next;
        }
-       ast_pthread_mutex_unlock(&switchlock);
+       ast_mutex_unlock(&switchlock);
 }
 
 /*
@@ -2287,7 +2287,7 @@ static char *complete_show_application(char *line, char *word,
        int which = 0;
 
        /* try to lock applications list ... */
-       if (ast_pthread_mutex_lock(&applock)) {
+       if (ast_mutex_lock(&applock)) {
                ast_log(LOG_ERROR, "Unable to lock application list\n");
                return NULL;
        }
@@ -2300,7 +2300,7 @@ static char *complete_show_application(char *line, char *word,
                        /* ... if this is right app serve it ... */
                        if (++which > state) {
                                char *ret = strdup(a->name);
-                               ast_pthread_mutex_unlock(&applock);
+                               ast_mutex_unlock(&applock);
                                return ret;
                        }
                }
@@ -2308,7 +2308,7 @@ static char *complete_show_application(char *line, char *word,
        }
 
        /* no application match */
-       ast_pthread_mutex_unlock(&applock);
+       ast_mutex_unlock(&applock);
        return NULL; 
 }
 
@@ -2321,7 +2321,7 @@ static int handle_show_application(int fd, int argc, char *argv[])
        if (argc < 3) return RESULT_SHOWUSAGE;
 
        /* try to lock applications list ... */
-       if (ast_pthread_mutex_lock(&applock)) {
+       if (ast_mutex_lock(&applock)) {
                ast_log(LOG_ERROR, "Unable to lock application list\n");
                return -1;
        }
@@ -2349,7 +2349,7 @@ static int handle_show_application(int fd, int argc, char *argv[])
                a = a->next; 
        }
 
-       ast_pthread_mutex_unlock(&applock);
+       ast_mutex_unlock(&applock);
 
        /* we found at least one app? no? */
        if (no_registered_app) {
@@ -2369,7 +2369,7 @@ static int handle_show_switches(int fd, int argc, char *argv[])
        }
        /* ... we have applications ... */
        ast_cli(fd, "\n    -= Registered Asterisk Alternative Switches =-\n");
-       if (ast_pthread_mutex_lock(&switchlock)) {
+       if (ast_mutex_lock(&switchlock)) {
                ast_log(LOG_ERROR, "Unable to lock switches\n");
                return -1;
        }
@@ -2378,7 +2378,7 @@ static int handle_show_switches(int fd, int argc, char *argv[])
                ast_cli(fd, "%s: %s\n", sw->name, sw->description);
                sw = sw->next;
        }
-       ast_pthread_mutex_unlock(&switchlock);
+       ast_mutex_unlock(&switchlock);
        return RESULT_SUCCESS;
 }
 
@@ -2390,7 +2390,7 @@ static int handle_show_applications(int fd, int argc, char *argv[])
        struct ast_app *a;
 
        /* try to lock applications list ... */
-       if (ast_pthread_mutex_lock(&applock)) {
+       if (ast_mutex_lock(&applock)) {
                ast_log(LOG_ERROR, "Unable to lock application list\n");
                return -1;
        }
@@ -2401,7 +2401,7 @@ static int handle_show_applications(int fd, int argc, char *argv[])
        /* ... have we got at least one application (first)? no? */
        if (!a) {
                ast_cli(fd, "There is no registered applications\n");
-               ast_pthread_mutex_unlock(&applock);
+               ast_mutex_unlock(&applock);
                return -1;
        }
 
@@ -2418,7 +2418,7 @@ static int handle_show_applications(int fd, int argc, char *argv[])
        }
 
        /* ... unlock and return */
-       ast_pthread_mutex_unlock(&applock);
+       ast_mutex_unlock(&applock);
 
        return RESULT_SUCCESS;
 }
@@ -2678,7 +2678,7 @@ static struct ast_cli_entry show_switches_cli =
 
 int ast_unregister_application(char *app) {
        struct ast_app *tmp, *tmpl = NULL;
-       if (ast_pthread_mutex_lock(&applock)) {
+       if (ast_mutex_lock(&applock)) {
                ast_log(LOG_ERROR, "Unable to lock application list\n");
                return -1;
        }
@@ -2691,13 +2691,13 @@ int ast_unregister_application(char *app) {
                                apps = tmp->next;
                        if (option_verbose > 1)
                                ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name);
-                       ast_pthread_mutex_unlock(&applock);
+                       ast_mutex_unlock(&applock);
                        return 0;
                }
                tmpl = tmp;
                tmp = tmp->next;
        }
-       ast_pthread_mutex_unlock(&applock);
+       ast_mutex_unlock(&applock);
        return -1;
 }
 
@@ -2706,17 +2706,17 @@ struct ast_context *ast_context_create(struct ast_context **extcontexts, char *n
        struct ast_context *tmp, **local_contexts;
        if (!extcontexts) {
                local_contexts = &contexts;
-               ast_pthread_mutex_lock(&conlock);
+               ast_mutex_lock(&conlock);
        } else
                local_contexts = extcontexts;
 
        tmp = *local_contexts;
        while(tmp) {
                if (!strcasecmp(tmp->name, name)) {
-                       ast_pthread_mutex_unlock(&conlock);
+                       ast_mutex_unlock(&conlock);
                        ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name);
                        if (!extcontexts)
-                               ast_pthread_mutex_unlock(&conlock);
+                               ast_mutex_unlock(&conlock);
                        return NULL;
                }
                tmp = tmp->next;
@@ -2724,7 +2724,7 @@ struct ast_context *ast_context_create(struct ast_context **extcontexts, char *n
        tmp = malloc(sizeof(struct ast_context));
        if (tmp) {
                memset(tmp, 0, sizeof(struct ast_context));
-               ast_pthread_mutex_init(&tmp->lock);
+               ast_mutex_init(&tmp->lock);
                strncpy(tmp->name, name, sizeof(tmp->name)-1);
                tmp->root = NULL;
                tmp->registrar = registrar;
@@ -2740,7 +2740,7 @@ struct ast_context *ast_context_create(struct ast_context **extcontexts, char *n
                ast_log(LOG_WARNING, "Out of memory\n");
        
        if (!extcontexts)
-               ast_pthread_mutex_unlock(&conlock);
+               ast_mutex_unlock(&conlock);
        return tmp;
 }
 
@@ -2749,7 +2749,7 @@ void __ast_context_destroy(struct ast_context *con, char *registrar, int lock);
 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, char *registrar) {
        struct ast_context *tmp, *lasttmp = NULL;
        tmp = *extcontexts;
-       ast_pthread_mutex_lock(&conlock);
+       ast_mutex_lock(&conlock);
        if (registrar) {
                __ast_context_destroy(NULL,registrar,0);
                while (tmp) {
@@ -2769,7 +2769,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, char *regis
                *extcontexts = NULL;
        } else 
                ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
-       ast_pthread_mutex_unlock(&conlock);
+       ast_mutex_unlock(&conlock);
        return; 
 }
 
@@ -3099,7 +3099,7 @@ int ast_context_add_include2(struct ast_context *con, char *value,
        new_include->registrar = registrar;
 
        /* ... try to lock this context ... */
-       if (ast_pthread_mutex_lock(&con->lock)) {
+       if (ast_mutex_lock(&con->lock)) {
                free(new_include);
                errno = EBUSY;
                return -1;
@@ -3110,7 +3110,7 @@ int ast_context_add_include2(struct ast_context *con, char *value,
        while (i) {
                if (!strcasecmp(i->name, new_include->name)) {
                        free(new_include);
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        errno = EEXIST;
                        return -1;
                }
@@ -3125,7 +3125,7 @@ int ast_context_add_include2(struct ast_context *con, char *value,
                con->includes = new_include;
        if (option_verbose > 2)
                ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con)); 
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
 
        return 0;
 }
@@ -3194,7 +3194,7 @@ int ast_context_add_switch2(struct ast_context *con, char *value,
        new_sw->registrar = registrar;
 
        /* ... try to lock this context ... */
-       if (ast_pthread_mutex_lock(&con->lock)) {
+       if (ast_mutex_lock(&con->lock)) {
                free(new_sw);
                errno = EBUSY;
                return -1;
@@ -3205,7 +3205,7 @@ int ast_context_add_switch2(struct ast_context *con, char *value,
        while (i) {
                if (!strcasecmp(i->name, new_sw->name)) {
                        free(new_sw);
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        errno = EEXIST;
                        return -1;
                }
@@ -3220,7 +3220,7 @@ int ast_context_add_switch2(struct ast_context *con, char *value,
                con->alts = new_sw;
        if (option_verbose > 2)
                ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con)); 
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
 
        return 0;
 }
@@ -3257,7 +3257,7 @@ int ast_context_remove_ignorepat2(struct ast_context *con, char *ignorepat, char
 {
        struct ast_ignorepat *ip, *ipl = NULL;
 
-       if (ast_pthread_mutex_lock(&con->lock)) {
+       if (ast_mutex_lock(&con->lock)) {
                errno = EBUSY;
                return -1;
        }
@@ -3273,13 +3273,13 @@ int ast_context_remove_ignorepat2(struct ast_context *con, char *ignorepat, char
                                con->ignorepats = ip->next;
                                free(ip);
                        }
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        return 0;
                }
                ipl = ip; ip = ip->next;
        }
 
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
        errno = EINVAL;
        return -1;
 }
@@ -3325,13 +3325,13 @@ int ast_context_add_ignorepat2(struct ast_context *con, char *value, char *regis
        strncpy(ignorepat->pattern, value, sizeof(ignorepat->pattern)-1);
        ignorepat->next = NULL;
        ignorepat->registrar = registrar;
-       ast_pthread_mutex_lock(&con->lock);
+       ast_mutex_lock(&con->lock);
        ignorepatc = con->ignorepats;
        while(ignorepatc) {
                ignorepatl = ignorepatc;
                if (!strcasecmp(ignorepatc->pattern, value)) {
                        /* Already there */
-                       pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        errno = EEXIST;
                        return -1;
                }
@@ -3341,7 +3341,7 @@ int ast_context_add_ignorepat2(struct ast_context *con, char *value, char *regis
                ignorepatl->next = ignorepat;
        else
                con->ignorepats = ignorepat;
-       pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
        return 0;
        
 }
@@ -3397,7 +3397,7 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
 {
        int res = 0;
        if (needlock)
-               ast_pthread_mutex_lock(&chan->lock);
+               ast_mutex_lock(&chan->lock);
        if (chan->pbx) {
                /* This channel is currently in the PBX */
                if (context && strlen(context))
@@ -3408,7 +3408,7 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                        chan->priority = priority - 1;
                ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
                if (needlock)
-                       ast_pthread_mutex_unlock(&chan->lock);
+                       ast_mutex_unlock(&chan->lock);
        } else {
                /* In order to do it when the channel doesn't really exist within
                   the PBX, we have to make a new channel, masquerade, and start the PBX
@@ -3436,7 +3436,7 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                        else
                                tmpchan->priority = chan->priority;
                        if (needlock)
-                               ast_pthread_mutex_unlock(&chan->lock);
+                               ast_mutex_unlock(&chan->lock);
                        
                        /* Masquerade into temp channel */
                        ast_channel_masquerade(tmpchan, chan);
@@ -3454,7 +3454,7 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                } else {
                        res = -1;
                        if (needlock)
-                               ast_pthread_mutex_unlock(&chan->lock);
+                               ast_mutex_unlock(&chan->lock);
                }
        }
        return res;
@@ -3552,7 +3552,7 @@ int ast_add_extension2(struct ast_context *con,
                errno = ENOMEM;
                return -1;
        }
-       if (ast_pthread_mutex_lock(&con->lock)) {
+       if (ast_mutex_lock(&con->lock)) {
                free(tmp);
                /* And properly destroy the data */
                datad(data);
@@ -3601,7 +3601,7 @@ int ast_add_extension2(struct ast_context *con,
                                                /* Destroy the old one */
                                                e->datad(e->data);
                                                free(e);
-                                               ast_pthread_mutex_unlock(&con->lock);
+                                               ast_mutex_unlock(&con->lock);
                                                if (tmp->priority == PRIORITY_HINT)
                                                    ast_change_hint(e, tmp);
                                                /* And immediately return success. */
@@ -3611,7 +3611,7 @@ int ast_add_extension2(struct ast_context *con,
                                                ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
                                                tmp->datad(tmp->data);
                                                free(tmp);
-                                               ast_pthread_mutex_unlock(&con->lock);
+                                               ast_mutex_unlock(&con->lock);
                                                errno = EEXIST;
                                                return -1;
                                        }
@@ -3634,7 +3634,7 @@ int ast_add_extension2(struct ast_context *con,
                                                tmp->peer = con->root->peer;
                                                con->root = tmp;
                                        }
-                                       ast_pthread_mutex_unlock(&con->lock);
+                                       ast_mutex_unlock(&con->lock);
                                        /* And immediately return success. */
                                        if (tmp->priority == PRIORITY_HINT)
                                            ast_add_hint(tmp);
@@ -3648,7 +3648,7 @@ int ast_add_extension2(struct ast_context *con,
                        /* If we make it here, then it's time for us to go at the very end.
                           ep *must* be defined or we couldn't have gotten here. */
                        ep->peer = tmp;
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        if (tmp->priority == PRIORITY_HINT)
                            ast_add_hint(tmp);
                        
@@ -3667,7 +3667,7 @@ int ast_add_extension2(struct ast_context *con,
                                /* We're at the top of the list */
                                con->root = tmp;
                        }
-                       ast_pthread_mutex_unlock(&con->lock);
+                       ast_mutex_unlock(&con->lock);
                        if (tmp->priority == PRIORITY_HINT)
                            ast_add_hint(tmp);
 
@@ -3684,7 +3684,7 @@ int ast_add_extension2(struct ast_context *con,
                el->next = tmp;
        else
                con->root = tmp;
-       ast_pthread_mutex_unlock(&con->lock);
+       ast_mutex_unlock(&con->lock);
        if (tmp->priority == PRIORITY_HINT)
            ast_add_hint(tmp);
        LOG;
@@ -3938,14 +3938,14 @@ void __ast_context_destroy(struct ast_context *con, char *registrar, int lock)
        struct ast_sw *sw, *swl= NULL;
        struct ast_exten *e, *el, *en;
        if (lock)
-               ast_pthread_mutex_lock(&conlock);
+               ast_mutex_lock(&conlock);
        tmp = contexts;
        while(tmp) {
                if (((tmp->name && con && con->name && !strcasecmp(tmp->name, con->name)) || !con) &&
                    (!registrar || !strcasecmp(registrar, tmp->registrar))) {
                        /* Okay, let's lock the structure to be sure nobody else
                           is searching through it. */
-                       if (ast_pthread_mutex_lock(&tmp->lock)) {
+                       if (ast_mutex_lock(&tmp->lock)) {
                                ast_log(LOG_WARNING, "Unable to lock context lock\n");
                                return;
                        }
@@ -3955,7 +3955,7 @@ void __ast_context_destroy(struct ast_context *con, char *registrar, int lock)
                                contexts = tmp->next;
                        /* Okay, now we're safe to let it go -- in a sense, we were
                           ready to let it go as soon as we locked it. */
-                       ast_pthread_mutex_unlock(&tmp->lock);
+                       ast_mutex_unlock(&tmp->lock);
                        for (tmpi = tmp->includes; tmpi; ) {
                                /* Free includes */
                                tmpil = tmpi;
@@ -3988,14 +3988,14 @@ void __ast_context_destroy(struct ast_context *con, char *registrar, int lock)
                                continue;
                        }
                        if (lock)
-                               ast_pthread_mutex_unlock(&conlock);
+                               ast_mutex_unlock(&conlock);
                        return;
                }
                tmpl = tmp;
                tmp = tmp->next;
        }
        if (lock)
-               ast_pthread_mutex_unlock(&conlock);
+               ast_mutex_unlock(&conlock);
 }
 
 void ast_context_destroy(struct ast_context *con, char *registrar)
@@ -4435,12 +4435,12 @@ int load_pbx(void)
  */
 int ast_lock_contexts()
 {
-       return ast_pthread_mutex_lock(&conlock);
+       return ast_mutex_lock(&conlock);
 }
 
 int ast_unlock_contexts()
 {
-       return ast_pthread_mutex_unlock(&conlock);
+       return ast_mutex_unlock(&conlock);
 }
 
 /*
@@ -4448,12 +4448,12 @@ int ast_unlock_contexts()
  */
 int ast_lock_context(struct ast_context *con)
 {
-       return ast_pthread_mutex_lock(&con->lock);
+       return ast_mutex_lock(&con->lock);
 }
 
 int ast_unlock_context(struct ast_context *con)
 {
-       return ast_pthread_mutex_unlock(&con->lock);
+       return ast_mutex_unlock(&con->lock);
 }
 
 /*
index 1514503c37cec25db586821232a0d092ca346a33..c6c6190fbff7bf5c1ce79bdade76f3f37bc6676f 100755 (executable)
@@ -42,7 +42,7 @@ static char *registrar = "pbx_config";
 static int static_config = 0;
 static int write_protect_config = 1;
 
-static pthread_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER;
 
 static struct ast_context *local_contexts = NULL;
 
@@ -916,7 +916,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
 
        if (argc != 2 && argc != 3) return RESULT_SHOWUSAGE;
 
-       if (ast_pthread_mutex_lock(&save_dialplan_lock)) {
+       if (ast_mutex_lock(&save_dialplan_lock)) {
                ast_cli(fd,
                        "Failed to lock dialplan saving (another proccess saving?)\n");
                return RESULT_FAILURE;
@@ -945,7 +945,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
        /* try to lock contexts list */
        if (ast_lock_contexts()) {
                ast_cli(fd, "Failed to lock contexts list\n");
-               ast_pthread_mutex_unlock(&save_dialplan_lock);
+               ast_mutex_unlock(&save_dialplan_lock);
                return RESULT_FAILURE;
        }
 
@@ -954,7 +954,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
                ast_cli(fd, "Failed to create file '%s'\n",
                        filename);
                ast_unlock_contexts();
-               ast_pthread_mutex_unlock(&save_dialplan_lock);
+               ast_mutex_unlock(&save_dialplan_lock);
                return RESULT_FAILURE;
        }
 
@@ -1077,7 +1077,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
        }       
 
        ast_unlock_contexts();
-       ast_pthread_mutex_unlock(&save_dialplan_lock);
+       ast_mutex_unlock(&save_dialplan_lock);
        fclose(output);
 
        if (incomplete) {
index 4a6db3c870f48726cc21bb240e85f6f0f876a05f..13e29097bdf9834b467ebc6d2fc5e430f5fdfc6f 100755 (executable)
@@ -41,7 +41,7 @@
 #include "../asterisk.h"
 #include "../astconf.h"
 
-static pthread_mutex_t verb_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t verb_lock = AST_MUTEX_INITIALIZER;
 
 static pthread_t console_thread;
 
@@ -125,10 +125,10 @@ static void __verboser(char *stuff, int opos, int replacelast, int complete)
 
 static void verboser(char *stuff, int opos, int replacelast, int complete) 
 {
-       ast_pthread_mutex_lock(&verb_lock);
+       ast_mutex_lock(&verb_lock);
        /* Lock appropriately if we're really being called in verbose mode */
        __verboser(stuff, opos, replacelast, complete);
-       ast_pthread_mutex_unlock(&verb_lock);
+       ast_mutex_unlock(&verb_lock);
 }
 
 static void cliinput(void *data, int source, GdkInputCondition ic)
index 94263bea9e00a0e62736a947980f31d0cae0f02d..2a2e5cb8b9d75788158194b2271c5b38472f5ed4 100755 (executable)
@@ -59,7 +59,7 @@
 static char base64[64];
 static char b2a[256];
 
-static pthread_mutex_t keylock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t keylock = AST_MUTEX_INITIALIZER;
 
 #define KEY_NEEDS_PASSCODE (1 << 16)
 
@@ -120,7 +120,7 @@ static int pw_cb(char *buf, int size, int rwflag, void *userdata)
 struct ast_key *ast_key_get(char *kname, int ktype)
 {
        struct ast_key *key;
-       ast_pthread_mutex_lock(&keylock);
+       ast_mutex_lock(&keylock);
        key = keys;
        while(key) {
                if (!strcmp(kname, key->name) &&
@@ -128,7 +128,7 @@ struct ast_key *ast_key_get(char *kname, int ktype)
                        break;
                key = key->next;
        }
-       ast_pthread_mutex_unlock(&keylock);
+       ast_mutex_unlock(&keylock);
        return key;
 }
 
@@ -156,7 +156,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
        /* Get actual filename */
        snprintf(ffname, sizeof(ffname), "%s/%s", dir, fname);
 
-       ast_pthread_mutex_lock(&keylock);
+       ast_mutex_lock(&keylock);
        key = keys;
        while(key) {
                /* Look for an existing version already */
@@ -164,7 +164,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
                        break;
                key = key->next;
        }
-       ast_pthread_mutex_unlock(&keylock);
+       ast_mutex_unlock(&keylock);
 
        /* Open file */
        f = fopen(ffname, "r");
@@ -213,7 +213,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
           fill it with what we know */
        /* Gotta lock if this one already exists */
        if (found)
-               ast_pthread_mutex_lock(&keylock);
+               ast_mutex_lock(&keylock);
        /* First the filename */
        strncpy(key->fn, ffname, sizeof(key->fn));
        /* Then the name */
@@ -262,12 +262,12 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
                *not2 = 1;
        }
        if (found)
-               ast_pthread_mutex_unlock(&keylock);
+               ast_mutex_unlock(&keylock);
        if (!found) {
-               ast_pthread_mutex_lock(&keylock);
+               ast_mutex_lock(&keylock);
                key->next = keys;
                keys = key;
-               ast_pthread_mutex_unlock(&keylock);
+               ast_mutex_unlock(&keylock);
        }
        return key;
 }
@@ -456,13 +456,13 @@ static void crypto_load(int ifd, int ofd)
        struct dirent *ent;
        int note = 0;
        /* Mark all keys for deletion */
-       ast_pthread_mutex_lock(&keylock);
+       ast_mutex_lock(&keylock);
        key = keys;
        while(key) {
                key->delme = 1;
                key = key->next;
        }
-       ast_pthread_mutex_unlock(&keylock);
+       ast_mutex_unlock(&keylock);
        /* Load new keys */
        dir = opendir((char *)ast_config_AST_KEY_DIR);
        if (dir) {
@@ -475,7 +475,7 @@ static void crypto_load(int ifd, int ofd)
        if (note) {
                ast_log(LOG_NOTICE, "Please run the command 'init keys' to enter the passcodes for the keys\n");
        }
-       ast_pthread_mutex_lock(&keylock);
+       ast_mutex_lock(&keylock);
        key = keys;
        last = NULL;
        while(key) {
@@ -494,7 +494,7 @@ static void crypto_load(int ifd, int ofd)
                        last = key;
                key = nkey;
        }
-       ast_pthread_mutex_unlock(&keylock);
+       ast_mutex_unlock(&keylock);
 }
 
 static void md52sum(char *sum, unsigned char *md5)
@@ -509,7 +509,7 @@ static int show_keys(int fd, int argc, char *argv[])
        struct ast_key *key;
        char sum[16 * 2 + 1];
 
-       ast_pthread_mutex_lock(&keylock);
+       ast_mutex_lock(&keylock);
        key = keys;
        ast_cli(fd, "%-18s %-8s %-16s %-33s\n", "Key Name", "Type", "Status", "Sum");
        while(key) {
@@ -520,7 +520,7 @@ static int show_keys(int fd, int argc, char *argv[])
                                
                key = key->next;
        }
-       ast_pthread_mutex_unlock(&keylock);
+       ast_mutex_unlock(&keylock);
        return RESULT_SUCCESS;
 }
 
index 5f039f6c7a67e14634a07e2526bc0c8191ce5712..0983efbca426315ccc8eac26b2b81e8933fad0c3 100755 (executable)
@@ -133,7 +133,7 @@ static int handle_show_indications(int fd, int argc, char *argv[])
        char buf[256];
        int found_country = 0;
 
-       if (ast_pthread_mutex_lock(&tzlock)) {
+       if (ast_mutex_lock(&tzlock)) {
                ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
                return 0;
        }
@@ -144,7 +144,7 @@ static int handle_show_indications(int fd, int argc, char *argv[])
                for (tz=tone_zones; tz; tz=tz->next) {
                        ast_cli(fd,"%-7.7s %-7.7s %s\n", tz->country, tz->alias, tz->description);
                }
-               ast_pthread_mutex_unlock(&tzlock);
+               ast_mutex_unlock(&tzlock);
                return 0;
        }
        /* there was a request for specific country(ies), lets humor them */
@@ -174,7 +174,7 @@ static int handle_show_indications(int fd, int argc, char *argv[])
        }
        if (!found_country)
                ast_cli(fd,"No countries matched your criteria.\n");
-       ast_pthread_mutex_unlock(&tzlock);
+       ast_mutex_unlock(&tzlock);
        return -1;
 }
 
index f663561528b68c5793264340e5cd43bbf821a1ec..d7f73dd1fc342f1dad52266f7d5e97c253f84c9f 100755 (executable)
@@ -15,7 +15,7 @@
 
 #define AST_MONITOR_DIR        INSTALL_PREFIX "/var/spool/asterisk/monitor"
 
-static pthread_mutex_t monitorlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monitorlock = AST_MUTEX_INITIALIZER;
 
 static unsigned long seq = 0;
 
@@ -48,7 +48,7 @@ int ast_monitor_start(        struct ast_channel *chan, const char *format_spec,
        int res = 0;
 
        if( need_lock ) {
-               if (ast_pthread_mutex_lock(&chan->lock)) {
+               if (ast_mutex_lock(&chan->lock)) {
                        ast_log(LOG_WARNING, "Unable to lock channel\n");
                        return -1;
                }
@@ -77,13 +77,13 @@ int ast_monitor_start(      struct ast_channel *chan, const char *format_spec,
                                                AST_MONITOR_DIR, fname_base );
                        *monitor->filename_base = 0;
                } else {
-                       ast_pthread_mutex_lock( &monitorlock );
+                       ast_mutex_lock( &monitorlock );
                        snprintf(       monitor->read_filename, FILENAME_MAX, "%s/audio-in-%ld",
                                                AST_MONITOR_DIR, seq );
                        snprintf(       monitor->write_filename, FILENAME_MAX, "%s/audio-out-%ld",
                                                AST_MONITOR_DIR, seq );
                        seq++;
-                       ast_pthread_mutex_unlock( &monitorlock );
+                       ast_mutex_unlock( &monitorlock );
 
                        channel_name = strdup( chan->name );
                        while( ( p = strchr( channel_name, '/' ) ) ) {
@@ -113,7 +113,7 @@ int ast_monitor_start(      struct ast_channel *chan, const char *format_spec,
                        ast_log(        LOG_WARNING, "Could not create file %s\n",
                                                monitor->read_filename );
                        free( monitor );
-                       ast_pthread_mutex_unlock(&chan->lock);
+                       ast_mutex_unlock(&chan->lock);
                        return -1;
                }
                if( ast_fileexists( monitor->write_filename, NULL, NULL ) > 0 ) {
@@ -126,7 +126,7 @@ int ast_monitor_start(      struct ast_channel *chan, const char *format_spec,
                                                monitor->write_filename );
                        ast_closestream( monitor->read_stream );
                        free( monitor );
-                       ast_pthread_mutex_unlock(&chan->lock);
+                       ast_mutex_unlock(&chan->lock);
                        return -1;
                }
                chan->monitor = monitor;
@@ -137,7 +137,7 @@ int ast_monitor_start(      struct ast_channel *chan, const char *format_spec,
        }
 
        if( need_lock ) {
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
        }
        return res;
 }
@@ -146,7 +146,7 @@ int ast_monitor_start(      struct ast_channel *chan, const char *format_spec,
 int ast_monitor_stop( struct ast_channel *chan, int need_lock )
 {
        if(need_lock) {
-               if(ast_pthread_mutex_lock(&chan->lock)) {
+               if(ast_mutex_lock(&chan->lock)) {
                        ast_log(LOG_WARNING, "Unable to lock channel\n");
                        return -1;
                }
@@ -196,7 +196,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
        }
 
        if( need_lock ) {
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
        }
        return 0;
 }
@@ -213,7 +213,7 @@ int ast_monitor_change_fname(       struct ast_channel *chan,
        }
        
        if( need_lock ) {
-               if (ast_pthread_mutex_lock(&chan->lock)) {
+               if (ast_mutex_lock(&chan->lock)) {
                        ast_log(LOG_WARNING, "Unable to lock channel\n");
                        return -1;
                }
@@ -230,7 +230,7 @@ int ast_monitor_change_fname(       struct ast_channel *chan,
        }
 
        if( need_lock ) {
-               ast_pthread_mutex_unlock(&chan->lock);
+               ast_mutex_unlock(&chan->lock);
        }
        return 0;
 }
index e1ae942e763402cfaf4006dbe999d02333a45847..9ef8e55a39828eaa6d28ecad8af1bc96ff0f896f 100755 (executable)
@@ -91,7 +91,7 @@ struct mohdata {
 
 static struct mohclass *mohclasses;
 
-static pthread_mutex_t moh_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t moh_lock = AST_MUTEX_INITIALIZER;
 
 #define MPG_123 "/usr/bin/mpg123"
 #define MAX_MP3S 256
@@ -283,7 +283,7 @@ static void *monmp3thread(void *data)
                                ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, res * 2);
                        continue;
                }
-               ast_pthread_mutex_lock(&moh_lock);
+               ast_mutex_lock(&moh_lock);
                moh = class->members;
                while(moh) {
                        /* Write data */
@@ -292,7 +292,7 @@ static void *monmp3thread(void *data)
                                    ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
                        moh = moh->next;
                }
-               pthread_mutex_unlock(&moh_lock);
+               ast_mutex_unlock(&moh_lock);
        }
        return NULL;
 }
@@ -373,7 +373,7 @@ static void moh_release(struct ast_channel *chan, void *data)
 {
        struct mohdata *moh = data, *prev, *cur;
        int oldwfmt;
-       ast_pthread_mutex_lock(&moh_lock);
+       ast_mutex_lock(&moh_lock);
        /* Unlink */
        prev = NULL;
        cur = moh->parent->members;
@@ -388,7 +388,7 @@ static void moh_release(struct ast_channel *chan, void *data)
                prev = cur;
                cur = cur->next;
        }
-       ast_pthread_mutex_unlock(&moh_lock);
+       ast_mutex_unlock(&moh_lock);
        close(moh->pipe[0]);
        close(moh->pipe[1]);
        oldwfmt = moh->origwfmt;
@@ -405,7 +405,7 @@ static void *moh_alloc(struct ast_channel *chan, void *params)
 {
        struct mohdata *res;
        struct mohclass *class;
-       ast_pthread_mutex_lock(&moh_lock);
+       ast_mutex_lock(&moh_lock);
        class = get_mohbyname(params);
        if (class)
                res = mohalloc(class);
@@ -414,7 +414,7 @@ static void *moh_alloc(struct ast_channel *chan, void *params)
                        ast_log(LOG_WARNING, "No class: %s\n", (char *)params);
                res = NULL;
        }
-       ast_pthread_mutex_unlock(&moh_lock);
+       ast_mutex_unlock(&moh_lock);
        if (res) {
                res->origwfmt = chan->writeformat;
                if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
@@ -478,9 +478,9 @@ static int moh_register(char *classname, char *mode, char *param, char *miscargs
 {
        struct mohclass *moh;
        int x;
-       ast_pthread_mutex_lock(&moh_lock);
+       ast_mutex_lock(&moh_lock);
        moh = get_mohbyname(classname);
-       ast_pthread_mutex_unlock(&moh_lock);
+       ast_mutex_unlock(&moh_lock);
        if (moh) {
                ast_log(LOG_WARNING, "Music on Hold '%s' already exists\n", classname);
                return -1;
@@ -523,10 +523,10 @@ static int moh_register(char *classname, char *mode, char *param, char *miscargs
                free(moh);
                return -1;
        }
-       ast_pthread_mutex_lock(&moh_lock);
+       ast_mutex_lock(&moh_lock);
        moh->next = mohclasses;
        mohclasses = moh;
-       ast_pthread_mutex_unlock(&moh_lock);
+       ast_mutex_unlock(&moh_lock);
        return 0;
 }
 
@@ -575,17 +575,17 @@ static void ast_moh_destroy(void)
 {
        struct mohclass *moh;
        char buff[8192];
-       int bytes, tbytes, stime = 0;
+       int bytes, tbytes=0, stime = 0;
        if (option_verbose > 1)
                ast_verbose(VERBOSE_PREFIX_2 "Destroying any remaining musiconhold processes\n");
-       ast_pthread_mutex_lock(&moh_lock);
+       ast_mutex_lock(&moh_lock);
        moh = mohclasses;
        while(moh) {
                if (moh->pid) {
                        ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
                        stime = time(NULL);
                        kill(moh->pid, SIGABRT);
-                       while (bytes = read(moh->srcfd, buff, 8192) && time(NULL) < stime + 5) {
+                       while ((bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime + 5) {
                                tbytes = tbytes + bytes;
                        }
                        ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", moh->pid, tbytes);
@@ -594,7 +594,7 @@ static void ast_moh_destroy(void)
                        }
                moh = moh->next;
        }
-       ast_pthread_mutex_unlock(&moh_lock);
+       ast_mutex_unlock(&moh_lock);
 }
 
 int load_module(void)
index 821dcee79117c42efb84f9decab5f82b42082b2c..828be881b15a1212d7daeb9e53dc39782aa69fe1 100755 (executable)
@@ -83,7 +83,7 @@ struct parkeduser {
 
 static struct parkeduser *parkinglot;
 
-static pthread_mutex_t parking_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t parking_lock = AST_MUTEX_INITIALIZER;
 
 static pthread_t parking_thread;
 
@@ -109,7 +109,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
        int x;
        pu = malloc(sizeof(struct parkeduser));
        if (pu) {
-               ast_pthread_mutex_lock(&parking_lock);
+               ast_mutex_lock(&parking_lock);
                for (x=parking_start;x<=parking_stop;x++) {
                        cur = parkinglot;
                        while(cur) {
@@ -151,7 +151,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
                                pu->priority = chan->priority;
                        pu->next = parkinglot;
                        parkinglot = pu;
-                       ast_pthread_mutex_unlock(&parking_lock);
+                       ast_mutex_unlock(&parking_lock);
                        /* Wake up the (presumably select()ing) thread */
                        pthread_kill(parking_thread, SIGURG);
                        if (option_verbose > 1) 
@@ -162,7 +162,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
                } else {
                        ast_log(LOG_WARNING, "No more parking spaces\n");
                        free(pu);
-                       ast_pthread_mutex_unlock(&parking_lock);
+                       ast_mutex_unlock(&parking_lock);
                        return -1;
                }
        } else {
@@ -412,7 +412,7 @@ static void *do_parking_thread(void *ignore)
        for (;;) {
                ms = -1;
                max = -1;
-               ast_pthread_mutex_lock(&parking_lock);
+               ast_mutex_lock(&parking_lock);
                pl = NULL;
                pu = parkinglot;
                gettimeofday(&tv, NULL);
@@ -488,7 +488,7 @@ std:                                        for (x=0;x<AST_MAX_FDS;x++) {
                                }
                        }
                }
-               ast_pthread_mutex_unlock(&parking_lock);
+               ast_mutex_unlock(&parking_lock);
                rfds = nrfds;
                efds = nefds;
                tv.tv_sec = ms / 1000;
@@ -514,7 +514,7 @@ static int park_exec(struct ast_channel *chan, void *data)
        }
        LOCAL_USER_ADD(u);
        park = atoi((char *)data);
-       ast_pthread_mutex_lock(&parking_lock);
+       ast_mutex_lock(&parking_lock);
        pu = parkinglot;
        while(pu) {
                if (pu->parkingnum == park) {
@@ -527,7 +527,7 @@ static int park_exec(struct ast_channel *chan, void *data)
                pl = pu;
                pu = pu->next;
        }
-       ast_pthread_mutex_unlock(&parking_lock);
+       ast_mutex_unlock(&parking_lock);
        if (pu) {
                peer = pu->chan;
                free(pu);
@@ -578,7 +578,7 @@ static int handle_parkedcalls(int fd, int argc, char *argv[])
        ast_cli(fd, "%4s %25s (%-15s %-12s %-4s) %-6s \n", "Num", "Channel"
                , "Context", "Extension", "Pri", "Timeout");
 
-       ast_pthread_mutex_lock(&parking_lock);
+       ast_mutex_lock(&parking_lock);
 
        cur=parkinglot;
        while(cur) {
@@ -589,7 +589,7 @@ static int handle_parkedcalls(int fd, int argc, char *argv[])
                cur = cur->next;
        }
 
-       ast_pthread_mutex_unlock(&parking_lock);
+       ast_mutex_unlock(&parking_lock);
 
        return RESULT_SUCCESS;
 }
diff --git a/rtp.c b/rtp.c
index 34b1d48fb25e37f43674978e75c2018b0c989f38..ba40c61bccad0224d47acd4aeb7b6ce95accaf76 100755 (executable)
--- a/rtp.c
+++ b/rtp.c
@@ -1136,20 +1136,20 @@ int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, st
        /* if need DTMF, cant native bridge */
        if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))
                return -2;
-       ast_pthread_mutex_lock(&c0->lock);
-       ast_pthread_mutex_lock(&c1->lock);
+       ast_mutex_lock(&c0->lock);
+       ast_mutex_lock(&c1->lock);
        pr0 = get_proto(c0);
        pr1 = get_proto(c1);
        if (!pr0) {
                ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name);
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                return -1;
        }
        if (!pr1) {
                ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name);
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                return -1;
        }
        pvt0 = c0->pvt->pvt;
@@ -1166,8 +1166,8 @@ int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, st
                vp1 = NULL;
        if (!p0 || !p1) {
                /* Somebody doesn't want to play... */
-               ast_pthread_mutex_unlock(&c0->lock);
-               ast_pthread_mutex_unlock(&c1->lock);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
                return -2;
        }
        if (pr0->set_rtp_peer(c0, p1, vp1)) 
@@ -1186,8 +1186,8 @@ int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, st
                if (vp0)
                        ast_rtp_get_peer(p0, &vac0);
        }
-       ast_pthread_mutex_unlock(&c0->lock);
-       ast_pthread_mutex_unlock(&c1->lock);
+       ast_mutex_unlock(&c0->lock);
+       ast_mutex_unlock(&c1->lock);
        cs[0] = c0;
        cs[1] = c1;
        cs[2] = NULL;
index 366287d3e8b137d0a323787aaa780c514085575c..01c52309be0199853b29708eaa5d56850ee8998c 100755 (executable)
@@ -39,7 +39,7 @@
 /* This could all be done more efficiently *IF* we chained packets together
    by default, but it would also complicate virtually every application. */
    
-static pthread_mutex_t list_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t list_lock = AST_MUTEX_INITIALIZER;
 static struct ast_translator *list = NULL;
 
 struct ast_translator_dir {
@@ -259,7 +259,7 @@ static int show_translation(int fd, int argc, char *argv[])
                return RESULT_SHOWUSAGE;
        ast_cli(fd, "                        Translation times between formats (in milliseconds)\n");
        ast_cli(fd, "                                 Destination Format\n");
-       ast_pthread_mutex_lock(&list_lock);
+       ast_mutex_lock(&list_lock);
        for (x=0;x<SHOW_TRANS; x++) {
                if (x == 1) 
                        strcpy(line, "  Src  ");
@@ -276,7 +276,7 @@ static int show_translation(int fd, int argc, char *argv[])
                snprintf(line + strlen(line), sizeof(line) - strlen(line), "\n");
                ast_cli(fd, line);                      
        }
-       ast_pthread_mutex_unlock(&list_lock);
+       ast_mutex_unlock(&list_lock);
        return RESULT_SUCCESS;
 }
 
@@ -302,7 +302,7 @@ int ast_register_translator(struct ast_translator *t)
        calc_cost(t);
        if (option_verbose > 1)
                ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %d to %d, cost %d\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), t->srcfmt, t->dstfmt, t->cost);
-       ast_pthread_mutex_lock(&list_lock);
+       ast_mutex_lock(&list_lock);
        if (!added_cli) {
                ast_cli_register(&show_trans);
                added_cli++;
@@ -310,14 +310,14 @@ int ast_register_translator(struct ast_translator *t)
        t->next = list;
        list = t;
        rebuild_matrix();
-       ast_pthread_mutex_unlock(&list_lock);
+       ast_mutex_unlock(&list_lock);
        return 0;
 }
 
 int ast_unregister_translator(struct ast_translator *t)
 {
        struct ast_translator *u, *ul = NULL;
-       ast_pthread_mutex_lock(&list_lock);
+       ast_mutex_lock(&list_lock);
        u = list;
        while(u) {
                if (u == t) {
@@ -331,7 +331,7 @@ int ast_unregister_translator(struct ast_translator *t)
                u = u->next;
        }
        rebuild_matrix();
-       ast_pthread_mutex_unlock(&list_lock);
+       ast_mutex_unlock(&list_lock);
        return (u ? 0 : -1);
 }
 
@@ -343,7 +343,7 @@ int ast_translator_best_choice(int *dst, int *srcs)
        int bestdst=0;
        int cur = 1;
        int besttime=999999999;
-       ast_pthread_mutex_lock(&list_lock);
+       ast_mutex_lock(&list_lock);
        for (y=0;y<MAX_FORMAT;y++) {
                if ((cur & *dst) && (cur & *srcs)) {
                        /* This is a common format to both.  Pick it if we don't have one already */
@@ -370,6 +370,6 @@ int ast_translator_best_choice(int *dst, int *srcs)
                *dst = bestdst;
                best = 0;
        }
-       ast_pthread_mutex_unlock(&list_lock);
+       ast_mutex_unlock(&list_lock);
        return best;
 }