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
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;
}
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];
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"
{
unsigned char *data;
int len;
- ast_pthread_mutex_lock(&conflock);
+ ast_mutex_lock(&conflock);
switch(sound) {
case ENTER:
data = enter;
}
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))
cnfout:
if (cnf && make)
cnf->users++;
- ast_pthread_mutex_unlock(&conflock);
+ ast_mutex_unlock(&conflock);
return cnf;
}
outrun:
- ast_pthread_mutex_lock(&conflock);
+ ast_mutex_lock(&conflock);
/* Clean up */
conf->users--;
if (!conf->users) {
close(conf->fd);
free(conf);
}
- pthread_mutex_unlock(&conflock);
+ ast_mutex_unlock(&conflock);
return ret;
}
};
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 */
};
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)
{
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;
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;
}
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) {
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&qlock);
+ ast_mutex_unlock(&qlock);
free_members(q);
free(q);
}
q = qe->parent;
if (!q)
return;
- ast_pthread_mutex_lock(&q->lock);
+ ast_mutex_lock(&q->lock);
prev = NULL;
cur = q->head;
}
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);
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;
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) {
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&q->lock);
+ ast_mutex_unlock(&q->lock);
return 0;
}
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;
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;
{
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);
}
{
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
"Not there\n", interface, queuename);
}
- ast_pthread_mutex_unlock(&q->lock);
+ ast_mutex_unlock(&q->lock);
q = q->next;
}
}
{
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
"Already there\n", interface, queuename);
}
- ast_pthread_mutex_unlock(&q->lock);
+ ast_mutex_unlock(&q->lock);
q = q->next;
}
}
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) {
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;
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;
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;
ql = q;
q = qn;
}
- ast_pthread_mutex_unlock(&qlock);
+ ast_mutex_unlock(&qlock);
}
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
} 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;
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"
"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;
/* 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;
#ifdef USEMYSQLVM
MYSQL *dbhandler=NULL;
-pthread_mutex_t mysqllock;
+ast_mutex_t mysqllock;
char dbuser[80];
char dbpass[80];
char dbname[80];
} 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) {
}
}
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);
} 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)
} 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
{
/* 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)) &&
vmu->next = NULL;
}
}
- ast_pthread_mutex_unlock(&vmlock);
+ ast_mutex_unlock(&vmlock);
return vmu;
}
/* 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)) &&
strncpy(cur->password, newpass, sizeof(cur->password) - 1);
res = 0;
}
- ast_pthread_mutex_unlock(&vmlock);
+ ast_mutex_unlock(&vmlock);
return res;
}
int x;
cfg = ast_load(VOICEMAIL_CONFIG);
- ast_pthread_mutex_lock(&vmlock);
+ ast_mutex_lock(&vmlock);
cur = users;
while(cur) {
l = cur;
}
}
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;
}
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;
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;
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) {
prev = ae;
ae = ae->next;
}
- ast_pthread_mutex_unlock(&atexitslock);
+ ast_mutex_unlock(&atexitslock);
}
static int fdprint(int fd, const char *s)
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)
#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)
{
void *ptr=NULL;
int hash;
reg = malloc(size + sizeof(struct ast_region));
- pthread_mutex_lock(®lock);
+ ast_mutex_lock(®lock);
if (reg) {
strncpy(reg->file, file, sizeof(reg->file) - 1);
reg->file[sizeof(reg->file) - 1] = '\0';
reg->next = regions[hash];
regions[hash] = reg;
}
- pthread_mutex_unlock(®lock);
+ ast_mutex_unlock(®lock);
if (!reg) {
fprintf(stderr, "Out of memory :(\n");
if (mmlog) {
struct ast_region *reg;
size_t len = 0;
- pthread_mutex_lock(®lock);
+ ast_mutex_lock(®lock);
reg = regions[hash];
while(reg) {
if (reg->data == ptr) {
}
reg = reg->next;
}
- pthread_mutex_unlock(®lock);
+ ast_mutex_unlock(®lock);
return len;
}
{
int hash = HASH(ptr);
struct ast_region *reg, *prev = NULL;
- pthread_mutex_lock(®lock);
+ ast_mutex_lock(®lock);
reg = regions[hash];
while(reg) {
if (reg->data == ptr) {
prev = reg;
reg = reg->next;
}
- pthread_mutex_unlock(®lock);
+ ast_mutex_unlock(®lock);
if (reg) {
free(reg);
} else {
fn = argv[3];
/* try to lock applications list ... */
- pthread_mutex_lock(®lock);
+ ast_mutex_lock(®lock);
for (x=0;x<SOME_PRIME;x++) {
reg = regions[x];
}
}
ast_cli(fd, "%d bytes allocated %d units total\n", len, count);
- pthread_mutex_unlock(®lock);
+ ast_mutex_unlock(®lock);
return RESULT_SUCCESS;
}
fn = argv[3];
/* try to lock applications list ... */
- pthread_mutex_lock(®lock);
+ ast_mutex_lock(®lock);
for (x=0;x<SOME_PRIME;x++) {
reg = regions[x];
reg = reg->next;
}
}
- pthread_mutex_unlock(®lock);
+ ast_mutex_unlock(®lock);
/* Dump the whole list */
while(list) {
#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;
struct ast_frame *f;
for(;;) {
x = 0;
- ast_pthread_mutex_lock(&autolock);
+ ast_mutex_lock(&autolock);
as = aslist;
while(as) {
if (!as->chan->_softhangup) {
}
as = as->next;
}
- ast_pthread_mutex_unlock(&autolock);
+ ast_mutex_unlock(&autolock);
/* if (!aslist)
break; */
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) {
}
}
}
- ast_pthread_mutex_unlock(&autolock);
+ ast_mutex_unlock(&autolock);
return res;
}
{
int res = -1;
struct asent *as, *prev;
- ast_pthread_mutex_lock(&autolock);
+ ast_mutex_lock(&autolock);
as = aslist;
prev = NULL;
while(as) {
}
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);
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];
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;
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)) {
}
i = i->next;
}
- ast_pthread_mutex_unlock(&cdrlock);
+ ast_mutex_unlock(&cdrlock);
if (i)
free(i);
}
} 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);
}
}
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;
char sqlcmd[2048], timestr[128];
time_t t;
- ast_pthread_mutex_lock(&mysql_lock);
+ ast_mutex_lock(&mysql_lock);
memset(sqlcmd,0,2048);
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;
}
/* 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];
/* 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)
{
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;
}
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);
}
}
{
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;
}
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;
}
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;
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);
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;
}
/* 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));
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);
}
} else
ast_log(LOG_WARNING, "Out of memory\n");
- PTHREAD_MUTEX_UNLOCK(&chlock);
+ ast_mutex_unlock(&chlock);
return tmp;
}
return -1;
}
if (lock)
- ast_pthread_mutex_lock(&chan->lock);
+ ast_mutex_lock(&chan->lock);
prev = NULL;
cur = chan->pvt->readq;
while(cur) {
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;
}
}
pthread_kill(chan->blocker, SIGURG);
}
if (lock)
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
return 0;
}
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) {
ret = l->next;
l = l->next;
}
- PTHREAD_MUTEX_UNLOCK(&chlock);
+ ast_mutex_unlock(&chlock);
return ret;
}
headp=&chan->varshead;
- PTHREAD_MUTEX_LOCK(&chlock);
+ ast_mutex_lock(&chlock);
cur = channels;
while(cur) {
if (cur == 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);
free(chan->pvt);
chan->pvt = NULL;
free(chan);
- PTHREAD_MUTEX_UNLOCK(&chlock);
+ ast_mutex_unlock(&chlock);
ast_device_state_changed(name);
}
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;
}
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");
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;
}
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",
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;
}
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)
/* 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;
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;
}
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;
}
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;
}
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");
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;
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) {
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;
}
}
chan->fout++;
chan->fout++;
}
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
return res;
}
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;
}
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) {
}
if (!chan)
ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
- PTHREAD_MUTEX_UNLOCK(&chlock);
+ ast_mutex_unlock(&chlock);
return c;
}
*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 {
}
chanls = chanls->next;
}
- PTHREAD_MUTEX_UNLOCK(&chlock);
+ ast_mutex_unlock(&chlock);
return AST_DEVICE_INVALID;
}
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;
}
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);
} else
res = 0;
}
- pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
return res;
}
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);
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;
}
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);
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 */
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 */
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;
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)
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);
f = NULL;
}
CLEANUP(ast,p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 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;
}
{
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;
}
{
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;
}
{
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");
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);
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);
ast_setstate(ast, AST_STATE_UP);
}
CLEANUP(ast,p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
{
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;
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
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;
}
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);
(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 );
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)
* 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 )
{
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;
}
}
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;
pl = p;
p = pn;
}
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
ast_destroy(cfg);
return 0;
}
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);
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");
}
/* 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 */
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 */
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;
}
}
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;
}
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));
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;
}
}
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);
#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) {
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))
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 +
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",
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);
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) {
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;
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;
}
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";
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) {
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)) {
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;
}
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;
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 */
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)
/* 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);
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)) {
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);
/* 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
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;
}
{
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) {
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;
}
struct ast_channel *owner;
retry:
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
iaxs[callno] = NULL;
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;
}
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]);
}
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 */) {
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
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;
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) {
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;
}
/* 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;
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;
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)) {
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
hp = gethostbyname(peer);
if (hp) {
{
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;
}
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 */
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);
{
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) &&
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
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)) {
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
}
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];
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
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));
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
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)",
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;
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) {
}
user = user->next;
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return res;
}
/* 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))
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
if (strlen(requeststr))
requeststr[strlen(requeststr)-1] = '\0';
}
var = strsep(&stringp, ";");
}
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
prev = NULL;
dp = pvt->dpentries;
while(dp) {
prev = dp;
dp = dp->peer;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
return 0;
}
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
if (callno == cur->callno)
cur->retries = -1;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
return 0;
}
{
/* 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;
}
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 */
}
f = f->next;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
}
static int iax_poke_peer_s(void *data)
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"
);
}
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) &&
/* 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 {
/* 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);
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);
}
}
}
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)) {
}
}
}
- 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)
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;
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)) {
}
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 */
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 {
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)
}
/* 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 */
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;
}
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)
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;
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;
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)) {
} 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;
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);
free(userlast);
}
userl.users=NULL;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
for (reg = registrations;reg;) {
regl = reg;
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)
peerlast = peer;
peer=peernext;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
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);
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 */
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;");
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;
}
/* 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);
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]);
#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");
}
#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");
}
#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");
}
#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) {
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);
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();
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);
}
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;
}
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;
}
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;
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 */
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)
{
/* 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];
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) &&
peer = peer->next;
}
if (lockpeer)
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
}
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;
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");
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) {
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)
/* 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
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;
}
{
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) {
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;
}
struct ast_channel *owner;
retry:
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
gettimeofday(&lastused[callno], NULL);
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;
}
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)
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 */) {
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
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);
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) {
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;
}
/* 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;
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;
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)) {
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
hp = gethostbyname(peer);
if (hp) {
{
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;
}
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 */
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);
{
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) &&
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
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)) {
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
} 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];
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
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));
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
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)",
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;
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) {
}
user = user->next;
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
iaxs[callno]->trunk = iax2_getpeertrunk(*sin);
return res;
}
/* 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))
}
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);
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) {
prev = dp;
dp = dp->peer;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
return 0;
}
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
if (callno == cur->callno)
cur->retries = -1;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
return 0;
}
/* 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;
}
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 */
}
f = f->next;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
}
static int iax2_poke_peer_s(void *data)
/* 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);
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 */
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) {
}
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;
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;
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 */
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;
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"
);
}
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)
/* 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 {
/* 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);
/* 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)) {
}
}
}
- 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
((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;
}
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;
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]) {
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;
}
}
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);
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)) {
}
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 */
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 */
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);
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)
}
/* 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 */
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;
}
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)
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)
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;
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;
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)) {
} 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;
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);
free(userlast);
}
userl.users=NULL;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
for (reg = registrations;reg;) {
regl = reg;
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)
peerlast = peer;
peer=peernext;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
static void set_timing(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, config_file);
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));
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;
#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;
}
/* 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);
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]);
#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");
}
#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");
}
#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");
}
#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) {
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);
#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();
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);
}
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;
}
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;
}
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 */
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;
}
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;
}
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;
}
}
/* 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;
}
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;
}
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;
}
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) {
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);
}
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
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) {
prev = cur;
cur = cur->next;
}
- ast_pthread_mutex_unlock(&locallock);
+ ast_mutex_unlock(&locallock);
/* And destroy */
if (!glaredetect)
free(p);
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;
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) {
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);
}
}
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);
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;
}
/* 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) {
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;
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;
}
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) */
/* 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. */
#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;
#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];
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;
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)) {
transmit_notify_request(sub, "vmwi(-)");
}
}
- ast_pthread_mutex_unlock(&sub->lock);
+ ast_mutex_unlock(&sub->lock);
return 0;
}
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;
}
g = g->next;
}
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
return RESULT_SUCCESS;
}
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)) {
if (!found) {
ast_cli(fd, " << Could not find endpoint >> ");
}
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
return RESULT_SUCCESS;
}
{
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;
}
}
}
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;
}
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;
{
/* 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);
}
}
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
*at = '\0';
at++;
}
- ast_pthread_mutex_lock(&gatelock);
+ ast_mutex_lock(&gatelock);
if (at && (at[0] == '[')) {
at++;
c = strrchr(at, ']');
}
g = g->next;
}
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
if (!sub) {
if (name) {
if (g)
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)
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)
/* 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 */
#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;
/* 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;
}
} 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;
}
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);
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);
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 */
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) {
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) {
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;
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;
}
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. */
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);
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)) {
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
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
}
/* 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;
}
}
i=i->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
/* Never reached */
return NULL;
/* 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;
}
}
/* 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;
}
}
/* 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;
}
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;
}
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;
} 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;
}
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;
}
}
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);
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) {
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) {
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;
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;
}
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 */
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();
}
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;
}
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 */
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();
}
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;
}
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 */
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();
}
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;
}
/* 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";
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)) {
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;
}
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";
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 */
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)) {
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;
}
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. */
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);
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) {
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)) {