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)) {
/* Check the default, too... */
phone_new(i, AST_STATE_RING, "default");
if (i->owner) {
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
}
/* XXX This should probably be justified better XXX */
if (i->mode == MODE_IMMEDIATE) {
phone_new(i, AST_STATE_RING, i->context);
} else if (i->mode == MODE_DIALTONE) {
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt++;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
/* Reset the extension */
i->ext[0] = '\0';
}
} else {
if (i->dialtone) {
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
}
memset(i->ext, 0, sizeof(i->ext));
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);
/* Wait indefinitely for something to happen */
if (dotone) {
/* If we're ready to recycle the time, set it to 30 ms */
continue;
/* Alright, lock the interface list again, and let's look and see what has
happened */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_WARNING, "Unable to lock the interface list\n");
continue;
}
}
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;
}
return NULL;
}
/* Search for an unowned channel */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return NULL;
}
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
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;
}
}
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our Adtranphone channel type */
if (ast_channel_register(type, tdesc,
AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, phone_request)) {
struct phone_pvt *p, *pl;
/* First, take us out of the channel loop */
ast_channel_unregister(type);
- if (!ast_pthread_mutex_lock(&iflock)) {
+ if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
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()
{
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 pedanticsipchecking = 0;
static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of sip_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static pthread_mutex_t netlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
};
static struct sip_pvt {
- pthread_mutex_t lock; /* Channel private lock */
+ ast_mutex_t lock; /* Channel private lock */
char callid[80]; /* Global CallID */
char randdata[80]; /* Random data */
unsigned int ocseq; /* Current outgoing seqno */
static struct ast_user_list {
struct sip_user *users;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} userl = { NULL, AST_MUTEX_INITIALIZER };
static struct ast_peer_list {
struct sip_peer *peers;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} peerl = { NULL, AST_MUTEX_INITIALIZER };
#define REG_STATE_NOAUTH 6
struct sip_registry {
- pthread_mutex_t lock; /* Channel private lock */
+ ast_mutex_t lock; /* Channel private lock */
struct sockaddr_in addr; /* Who we connect to for registration purposes */
char username[80]; /* Who we are registering as */
char authuser[80]; /* Who we *authenticate* as */
{
struct sip_pkt *pkt=data;
int res = 0;
- ast_pthread_mutex_lock(&pkt->owner->lock);
+ ast_mutex_lock(&pkt->owner->lock);
if (1 /* !p->owner->needdestroy */) {
if (pkt->retrans < MAX_RETRANS) {
pkt->retrans++;
ast_queue_hangup(pkt->owner->owner, 1);
} else {
/* If no owner, destroy now */
- ast_pthread_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
sip_destroy(pkt->owner);
pkt = NULL;
}
ast_queue_hangup(pkt->owner->owner, 1);
} else {
/* If no owner, destroy now */
- ast_pthread_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
sip_destroy(pkt->owner);
pkt=NULL;
}
}
if (pkt)
- ast_pthread_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
return res;
}
char host[256], *hostn;
r->sa.sin_family = AF_INET;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
p = peerl.peers;
while(p) {
if (!strcasecmp(p->name, peer)) {
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
if ((port=strchr(peer, ':'))) {
*port='\0';
static int auto_congest(void *nothing)
{
struct sip_pvt *p = nothing;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
p->initid = -1;
if (p->owner) {
- if (!pthread_mutex_trylock(&p->owner->lock)) {
+ if (!ast_mutex_trylock(&p->owner->lock)) {
ast_log(LOG_NOTICE, "Auto-congesting %s\n", p->owner->name);
ast_queue_control(p->owner, AST_CONTROL_CONGESTION, 0);
- ast_pthread_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->owner->lock);
}
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
/* Unlink us from the owner if we have one */
if (p->owner) {
if (lockowner)
- ast_pthread_mutex_lock(&p->owner->lock);
+ ast_mutex_lock(&p->owner->lock);
ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
p->owner->pvt->pvt = NULL;
if (lockowner)
- ast_pthread_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->owner->lock);
}
cur = iflist;
while(cur) {
char name[256] = "";
struct sip_user *u;
strncpy(name, fup->username, sizeof(name) - 1);
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
u = userl.users;
while(u) {
if (!strcasecmp(u->name, name)) {
}
if (!u) {
ast_log(LOG_DEBUG, "%s is not a local user\n", name);
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return 0;
}
if(event == 0) {
if (u->incominglimit > 0 ) {
if (u->inUse >= u->incominglimit) {
ast_log(LOG_ERROR, "Call from user '%s' rejected due to usage limit of %d\n", u->name, u->incominglimit);
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return -1;
}
}
u->inUse++;
ast_log(LOG_DEBUG, "Call from user '%s' is %d out of %d\n", u->name, u->inUse, u->incominglimit);
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return 0;
}
static void sip_destroy(struct sip_pvt *p)
{
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
__sip_destroy(p, 1);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
static int transmit_response_reliable(struct sip_pvt *p, char *msg, struct sip_request *req);
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
ast_log(LOG_DEBUG, "find_user(%s)\n", p->username);
find_user(p, 0);
/* Determine how to disconnect */
if (p->owner != ast) {
ast_log(LOG_WARNING, "Huh? We aren't the owner?\n");
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
if (!ast || (ast->_state != AST_STATE_UP))
}
}
p->needdestroy = needdestroy;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
return -1;
}
if (p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->rtp) {
if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) {
transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0);
}
res = ast_rtp_write(p->rtp, frame);
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
}
} else if (frame->frametype == AST_FRAME_VIDEO) {
if (p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->vrtp) {
if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) {
transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0);
}
res = ast_rtp_write(p->vrtp, frame);
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
}
} else if (frame->frametype == AST_FRAME_IMAGE) {
return 0;
static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
struct sip_pvt *p = newchan->pvt->pvt;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->owner != oldchan) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return -1;
}
p->owner = newchan;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
if (strlen(i->language))
strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
i->owner = tmp;
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt++;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
{
struct ast_frame *fr;
struct sip_pvt *p = ast->pvt->pvt;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
fr = sip_rtp_read(ast, p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return fr;
}
if (p->vrtp)
ast_rtp_setnat(p->vrtp, p->nat);
}
- ast_pthread_mutex_init(&p->lock);
+ ast_mutex_init(&p->lock);
if (sin) {
memcpy(&p->sa, sin, sizeof(p->sa));
strncpy(p->context, context, sizeof(p->context) - 1);
strncpy(p->fromdomain, fromdomain, sizeof(p->fromdomain) - 1);
/* Add to list */
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
p->next = iflist;
iflist = p;
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (option_debug)
ast_log(LOG_DEBUG, "Allocating new SIP call for %s\n", callid);
return p;
ast_log(LOG_WARNING, "Call missing call ID from '%s'\n", inet_ntoa(sin->sin_addr));
return NULL;
}
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
p = iflist;
while(p) {
if (!strcmp(p->callid, callid) &&
(!pedanticsipchecking || !strlen(p->theirtag) || !strcmp(p->theirtag, tag))) {
/* Found the call */
- ast_pthread_mutex_lock(&p->lock);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_lock(&p->lock);
+ ast_mutex_unlock(&iflock);
return p;
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
p = sip_alloc(callid, sin, 1);
if (p)
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
return p;
}
tmp = __get_header(orig, field, &start);
if (strlen(tmp)) {
if (!copied && p->nat) {
+#ifdef THE_SIP_AUTHORS_CAN_SUCK_MY_GONADS
/* SLD: FIXME: Nice try, but the received= should not have a port */
/* SLD: FIXME: See RFC2543 BNF in Section 6.40.5 */
+ /* MAS: Yup, RFC says you can't do it. No way to indicate PAT...
+ good job fellas. */
if (ntohs(p->recv.sin_port) != DEFAULT_SIP_PORT)
snprintf(new, sizeof(new), "%s;received=%s:%d", tmp, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
else
+#endif
snprintf(new, sizeof(new), "%s;received=%s", tmp, inet_ntoa(p->recv.sin_addr));
add_header(req, field, new);
} else {
static int sip_do_register(struct sip_registry *r)
{
int res;
- ast_pthread_mutex_lock(&r->lock);
+ ast_mutex_lock(&r->lock);
res=transmit_register(r, "REGISTER", NULL);
- ast_pthread_mutex_unlock(&r->lock);
+ ast_mutex_unlock(&r->lock);
return res;
}
struct sip_registry *r=data;
struct sip_pvt *p;
int res;
- ast_pthread_mutex_lock(&r->lock);
+ ast_mutex_lock(&r->lock);
ast_log(LOG_NOTICE, "Registration for '%s@%s' timed out, trying again\n", r->username, inet_ntoa(r->addr.sin_addr));
if (r->call) {
/* Unlink us, destroy old call. Locking is not relevent here because all this happens
r->regstate=REG_STATE_UNREGISTERED;
r->timeout = -1;
res=transmit_register(r, "REGISTER", NULL);
- ast_pthread_mutex_unlock(&r->lock);
+ ast_mutex_unlock(&r->lock);
return 0;
}
*c = '\0';
strncpy(p->exten, name, sizeof(p->exten) - 1);
build_contact(p);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!strcasecmp(peer->name, name) && peer->dynamic) {
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!res) {
ast_device_state_changed("SIP/%s", peer->name);
}
strncpy(p->refer_contact, "", sizeof(p->refer_contact) - 1);
strncpy(p->remote_party_id, "", sizeof(p->remote_party_id) - 1);
p->refer_call = NULL;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
/* Search interfaces and find the match */
p2 = iflist;
while(p2) {
if (!strcmp(p2->callid, tmp5)) {
/* Go ahead and lock it before returning */
- ast_pthread_mutex_lock(&p2->lock);
+ ast_mutex_lock(&p2->lock);
p->refer_call = p2;
break;
}
p2 = p2->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (p->refer_call)
return 0;
else
strncpy(p->callerid, of, sizeof(p->callerid) - 1);
if (!strlen(of))
return 0;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user = userl.users;
while(user) {
if (!strcasecmp(user->name, of)) {
}
user = user->next;
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
if (!user) {
/* If we didn't find a user match, check for peers */
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!inaddrcmp(&peer->addr, &p->recv) ||
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
return res;
}
char used[80];
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user = userl.users;
ast_cli(fd, FORMAT, "Username", "inUse", "Limit");
for(user=userl.users;user;user=user->next) {
snprintf(used, sizeof(used), "%d", user->inUse);
ast_cli(fd, FORMAT2, user->name, used, limits);
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
struct sip_user *user;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
ast_cli(fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C");
for(user=userl.users;user;user=user->next) {
ast_cli(fd, FORMAT, user->name, user->secret, user->methods,
user->context,user->ha ? "Yes" : "No");
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return RESULT_SUCCESS;
#undef FORMAT
}
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 host[80];
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Host", "Username", "Refresh", "State");
for (reg = registrations;reg;reg = reg->next) {
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
ast_cli(fd, FORMAT, host,
reg->username, reg->refresh, regstate2str(reg->regstate));
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
int numchans = 0;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
cur = iflist;
ast_cli(fd, FORMAT2, "Peer", "User/ANR", "Call ID", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
while (cur) {
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
ast_cli(fd, "%d active SIP channel(s)\n", numchans);
return RESULT_SUCCESS;
#undef FORMAT
int which=0;
struct sip_pvt *cur;
char *c = NULL;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
cur = iflist;
while(cur) {
if (!strncasecmp(word, cur->callid, strlen(word))) {
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return c;
}
char tmp[256];
if (argc != 4)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
cur = iflist;
while(cur) {
if (!strcasecmp(cur->callid, argv[3])) {
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (!cur)
ast_cli(fd, "No such SIP Call ID '%s'\n", argv[3]);
return RESULT_SUCCESS;
build_route(p, req, 0);
if (c) {
/* Pre-lock the call */
- ast_pthread_mutex_lock(&c->lock);
+ ast_mutex_lock(&c->lock);
}
}
if (ast_pbx_start(c)) {
ast_log(LOG_WARNING, "Failed to start PBX :(\n");
/* Unlock locks so ast_hangup can do its magic */
- ast_pthread_mutex_unlock(&c->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&c->lock);
+ ast_mutex_unlock(&p->lock);
ast_hangup(c);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
transmit_response_reliable(p, "503 Unavailable", req);
c = NULL;
}
transmit_response_reliable(p, "503 Unavailable", req);
p->alreadygone = 1;
/* Unlock locks so ast_hangup can do its magic */
- ast_pthread_mutex_unlock(&c->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&c->lock);
+ ast_mutex_unlock(&p->lock);
ast_hangup(c);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
c = NULL;
} else {
- ast_pthread_mutex_unlock(&c->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&c->lock);
+ ast_mutex_unlock(&p->lock);
ast_hangup(c);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
c = NULL;
}
break;
if (p->refer_call) {
ast_log(LOG_DEBUG,"202 Accepted (supervised)\n");
attempt_transfer(p, p->refer_call);
- ast_pthread_mutex_unlock(&p->refer_call->lock);
+ ast_mutex_unlock(&p->refer_call->lock);
p->refer_call = NULL;
} else {
ast_log(LOG_DEBUG,"202 Accepted (blind)\n");
return 1;
}
/* Process request, with netlock held */
- ast_pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
p = find_call(&req, &sin);
if (p) {
retrylock:
/* Go ahead and lock the owner if it has one -- we may need it */
- if (p->owner && pthread_mutex_trylock(&p->owner->lock)) {
+ if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
ast_log(LOG_DEBUG, "Failed to grab lock, trying again...\n");
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Sleep infintismly short amount of time */
usleep(1);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
goto retrylock;
}
memcpy(&p->recv, &sin, sizeof(p->recv));
handle_request(p, &req, &sin);
if (p->owner)
- ast_pthread_mutex_unlock(&p->owner->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->lock);
}
- ast_pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
return 1;
}
/* Return now if it's the same thing we told them last time */
if (((newmsgs << 8) | (oldmsgs)) == peer->lastmsgssent) {
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return 0;
}
p = sip_alloc(NULL, NULL, 0);
if (!p) {
ast_log(LOG_WARNING, "Unable to build sip pvt data for MWI\n");
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return -1;
}
strncpy(name, peer->name, sizeof(name) - 1);
peer->lastmsgssent = ((newmsgs << 8) | (oldmsgs));
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (create_addr(p, name)) {
/* Maybe they're not registered, etc. */
sip_destroy(p);
/* From here on out, we die whenever asked */
for(;;) {
/* Check for interfaces needing to be killed */
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
restartsearch:
sip = iflist;
while(sip) {
- ast_pthread_mutex_lock(&sip->lock);
+ ast_mutex_lock(&sip->lock);
if (sip->needdestroy && !sip->packets) {
- ast_pthread_mutex_unlock(&sip->lock);
+ ast_mutex_unlock(&sip->lock);
__sip_destroy(sip, 1);
goto restartsearch;
}
- ast_pthread_mutex_unlock(&sip->lock);
+ ast_mutex_unlock(&sip->lock);
sip = sip->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Don't let anybody kill us right away. Nobody should lock the interface list
and wait for the monitor list, but the other way around is okay. */
- ast_pthread_mutex_lock(&monlock);
+ ast_mutex_lock(&monlock);
/* Lock the network interface */
- ast_pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
/* Okay, now that we know what to do, release the network lock */
- ast_pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
/* And from now on, we're okay to be killed, so release the monitor lock as well */
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
pthread_testcancel();
/* Wait for sched or io */
res = ast_sched_wait(sched);
if (fastrestart)
res = 1;
res = ast_io_wait(io, res);
- ast_pthread_mutex_lock(&monlock);
+ ast_mutex_lock(&monlock);
if (res >= 0)
ast_sched_runq(sched);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
time(&t);
fastrestart = 0;
if (!peer) {
/* Reset where we come from */
lastpeernum = -1;
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
}
/* Never reached */
return NULL;
/* 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;
}
ext = NULL;
}
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
p = peerl.peers;
while (p) {
if (!strcasecmp(p->name, host)) {
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
hp = gethostbyname(host);
if (hp)
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 sip_peer));
memset(peer, 0, sizeof(struct sip_peer));
peer->expire = -1;
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
user = build_user(cat, ast_variable_browse(cfg, cat));
if (user) {
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user->next = userl.users;
userl.users = user;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
}
}
if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
peer = build_peer(cat, ast_variable_browse(cfg, cat));
if (peer) {
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer->next = peerl.peers;
peerl.peers = peer;
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
} else if (strcasecmp(utype, "user")) {
ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, "sip.conf");
if (!ntohs(bindaddr.sin_port))
bindaddr.sin_port = ntohs(DEFAULT_SIP_PORT);
bindaddr.sin_family = AF_INET;
- pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
if ((sipsock > -1) && (ntohs(bindaddr.sin_port) != oldport)) {
close(sipsock);
sipsock = -1;
}
}
}
- pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
ast_destroy(cfg);
return 0;
ast_log(LOG_WARNING, "Unable to create I/O context\n");
}
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
sip_poke_peer(peer);
for (reg = registrations; reg; reg = reg->next)
sip_do_register(reg);
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
/* And start the monitor for the first time */
restart_monitor();
struct sip_registry *reg, *regl;
/* Delete all users */
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
for (user=userl.users;user;) {
ast_free_ha(user->ha);
userlast = user;
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 sip_peer *peer, *peerlast, *peernext;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peerlast = NULL;
for (peer=peerl.peers;peer;) {
peernext = peer->next;
peerlast = peer;
peer=peernext;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
int reload(void)
restart_monitor();
for (reg = registrations; reg; reg = reg->next)
sip_do_register(reg);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
sip_poke_peer(peer);
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return 0;
}
/* 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) {
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 char language[MAX_LANGUAGE] = "";
static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of vofr_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
ast->state = AST_STATE_DOWN;
((struct vofr_pvt *)(ast->pvt->pvt))->owner = NULL;
((struct vofr_pvt *)(ast->pvt->pvt))->ringgothangup = 0;
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
if (usecnt < 0)
ast_log(LOG_WARNING, "Usecnt < 0???\n");
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
if (strlen(i->language))
strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
i->owner = tmp;
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt++;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
if (state != AST_STATE_DOWN) {
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);
pthread_testcancel();
/* Wait indefinitely for something to happen */
res = ast_select(n + 1, &rfds, NULL, NULL, NULL);
}
/* 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;
}
} 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;
}
return NULL;
}
/* Search for an unowned channel */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return NULL;
}
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
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;
}
}
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our AdtranVoFR channel type */
if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
struct vofr_pvt *p, *pl;
/* First, take us out of the channel loop */
ast_channel_unregister(type);
- if (!ast_pthread_mutex_lock(&iflock)) {
+ if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
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 const int prefformat = AST_FORMAT_ALAW | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ADPCM;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of vpb_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
struct ast_frame **fo;
int flags;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
pthread_cond_t cond;
} bridges[VPB_MAX_BRIDGES]; /* Bridges...*/
-static pthread_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
static struct vpb_pvt {
int lastgrunt;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
int stopreads; /* Stop reading...*/
pthread_t readthread; /* For monitoring read channel. One per owned channel. */
/* Bridge channels, check if we can. I believe we always can, so find a slot.*/
- ast_pthread_mutex_lock(&bridge_lock); {
+ ast_mutex_lock(&bridge_lock); {
for (i = 0; i < len; i++)
if (!bridges[i].inuse)
break;
pthread_mutex_init(&bridges[i].lock, NULL);
pthread_cond_init(&bridges[i].cond, NULL);
}
- } ast_pthread_mutex_unlock(&bridge_lock);
+ } ast_mutex_unlock(&bridge_lock);
if (i == len) {
ast_log(LOG_WARNING, "Failed to bridge %s and %s!\n", c0->name, c1->name);
} else {
/* Set bridge pointers. You don't want to take these locks while holding bridge lock.*/
- ast_pthread_mutex_lock(&p0->lock); {
+ ast_mutex_lock(&p0->lock); {
p0->bridge = &bridges[i];
- } ast_pthread_mutex_unlock(&p0->lock);
+ } ast_mutex_unlock(&p0->lock);
- ast_pthread_mutex_lock(&p1->lock); {
+ ast_mutex_lock(&p1->lock); {
p1->bridge = &bridges[i];
- } ast_pthread_mutex_unlock(&p1->lock);
+ } ast_mutex_unlock(&p1->lock);
if (option_verbose > 4)
ast_verbose(VERBOSE_PREFIX_3
vpb_bridge(p0->handle, p1->handle, VPB_BRIDGE_OFF, 0);
- ast_pthread_mutex_lock(&bridge_lock); {
+ ast_mutex_lock(&bridge_lock); {
bridges[i].inuse = 0;
pthread_mutex_destroy(&bridges[i].lock);
pthread_cond_destroy(&bridges[i].cond);
- } ast_pthread_mutex_unlock(&bridge_lock);
+ } ast_mutex_unlock(&bridge_lock);
- ast_pthread_mutex_lock(&p0->lock); {
+ ast_mutex_lock(&p0->lock); {
p0->bridge = NULL;
- } ast_pthread_mutex_unlock(&p0->lock);
+ } ast_mutex_unlock(&p0->lock);
- ast_pthread_mutex_lock(&p1->lock); {
+ ast_mutex_lock(&p1->lock); {
p1->bridge = NULL;
- } ast_pthread_mutex_unlock(&p1->lock);
+ } ast_mutex_unlock(&p1->lock);
if (option_verbose > 4)
ast_verbose(VERBOSE_PREFIX_3 " handle_owned: putting frame: [%d=>%d], bridge=%p\n",
f.frametype, f.subclass, (void *)p->bridge);
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
if (p->bridge) { /* Check what happened, see if we need to report it. */
switch (f.frametype) {
case AST_FRAME_DTMF:
if (p->bridge->rc)
*p->bridge->rc = p->owner;
- ast_pthread_mutex_lock(&p->bridge->lock); {
+ ast_mutex_lock(&p->bridge->lock); {
pthread_cond_signal(&p->bridge->cond);
- } ast_pthread_mutex_unlock(&p->bridge->lock);
+ } ast_mutex_unlock(&p->bridge->lock);
}
}
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
if (endbridge) return 0;
goto end_loop;
str[0] = 0;
- ast_pthread_mutex_lock(&monlock),
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&monlock),
+ ast_mutex_lock(&iflock); {
struct vpb_pvt *p = iflist; /* Find the pvt structure */
vpb_translate_event(&e, str);
monitor_handle_notowned(p, &e);
done: (void)0;
- } ast_pthread_mutex_unlock(&iflock);
- ast_pthread_mutex_unlock(&monlock);
+ } ast_mutex_unlock(&iflock);
+ ast_mutex_unlock(&monlock);
end_loop:
tcounter += VPB_WAIT_TIMEOUT; /* Ok, not quite but will suffice. */
/* If we're supposed to be stopped -- stay stopped */
if (mthreadactive == -2)
return 0;
- ast_pthread_mutex_lock(&monlock); {
+ ast_mutex_lock(&monlock); {
if (monitor_thread == pthread_self()) {
ast_log(LOG_WARNING, "Cannot kill myself\n");
error = -1;
#endif
}
done: (void)0;
- } ast_pthread_mutex_unlock(&monlock);
+ } ast_mutex_unlock(&monlock);
return error;
}
ast_setstate(ast,AST_STATE_DOWN);
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
p->lastinput = p->lastoutput = -1;
p->ext[0] = 0;
p->owner = NULL;
p->dialtone = 0;
p->calling = 0;
ast->pvt->pvt = NULL;
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
- ast_pthread_mutex_lock(&usecnt_lock); {
+ ast_mutex_lock(&usecnt_lock); {
usecnt--;
- } ast_pthread_mutex_unlock(&usecnt_lock);
+ } ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
/* Stop thread doing reads. */
p->lastinput = fmt;
}
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
if (p->bridge)
if (p->bridge->c0 == p->owner &&
(p->bridge->flags & AST_BRIDGE_REC_CHANNEL_0))
bridgerec = 0;
else
bridgerec = 1;
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
if (state == AST_STATE_UP && bridgerec) {
/* Read only if up and not bridged, or a bridge for which we can read. */
fr->datalen = readlen;
fr->offset = AST_FRIENDLY_OFFSET;
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
if (p->owner) ast_queue_frame(p->owner, fr, 0);
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
} else
p->stopreads = 1;
i->lastinput = i->lastoutput = -1;
i->lastgrunt = tcounter; /* Assume at least one grunt tone seen now. */
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt++;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
if (state != AST_STATE_DOWN)
if (ast_pbx_start(tmp)) {
if (!s)
s = "";
/* Search for an unowned channel */
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
p = iflist;
while(p) {
if (strncmp(s, p->dev + 4, sizeof p->dev) == 0)
}
p = p->next;
}
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
if (option_verbose > 2)
vpb_seterrormode(VPB_DEVELOPMENT);
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
v = ast_variable_browse(cfg, "interfaces");
while(v) {
/* Create the interface list */
gruntdetect_timeout = 1000;
done: (void)0;
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
ast_destroy(cfg);
/* First, take us out of the channel loop */
ast_channel_unregister(type);
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
p = p->next;
}
iflist = NULL;
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
- ast_pthread_mutex_lock(&monlock); {
+ ast_mutex_lock(&monlock); {
if (mthreadactive > -1) {
pthread_cancel(monitor_thread);
pthread_join(monitor_thread, NULL);
}
mthreadactive = -2;
- } ast_pthread_mutex_unlock(&monlock);
+ } ast_mutex_unlock(&monlock);
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
/* Destroy all the interfaces and free their memory */
while(iflist) {
free(p);
}
iflist = NULL;
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
- ast_pthread_mutex_lock(&bridge_lock); {
+ ast_mutex_lock(&bridge_lock); {
memset(bridges, 0, sizeof bridges);
- } ast_pthread_mutex_unlock(&bridge_lock);
+ } ast_mutex_unlock(&bridge_lock);
pthread_mutex_destroy(&bridge_lock);
tcounter = 0;
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 matchdigittimeout = 3000;
static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of zt_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
#ifdef ZAPATA_PRI
struct zt_pri {
pthread_t master; /* Thread of master */
- pthread_mutex_t lock; /* Mutex */
+ ast_mutex_t lock; /* Mutex */
char idleext[AST_MAX_EXTENSION]; /* Where to idle extra calls */
char idlecontext[AST_MAX_EXTENSION]; /* What context to use for idle */
char idledial[AST_MAX_EXTENSION]; /* What to dial before dumping */
static inline void pri_rel(struct zt_pri *pri)
{
- ast_pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
static int switchtype = PRI_SWITCH_NI2;
#define MAX_SLAVES 4
static struct zt_pvt {
- pthread_mutex_t lock;
+ ast_mutex_t lock;
struct ast_channel *owner; /* Our current active owner (if applicable) */
/* Up to three channels can be associated with this call */
int res;
/* Grab the lock first */
do {
- res = pthread_mutex_trylock(&pri->lock);
+ res = ast_mutex_trylock(&pri->lock);
if (res) {
- ast_pthread_mutex_unlock(&pvt->lock);
+ ast_mutex_unlock(&pvt->lock);
/* Release the lock and try again */
usleep(1);
- ast_pthread_mutex_lock(&pvt->lock);
+ ast_mutex_lock(&pvt->lock);
}
} while(res);
/* Then break the select */
return 0;
}
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 1);
p->callwaitingrepeat = 0;
p->cidcwexpire = 0;
ast->pvt->pvt = NULL;
- ast_pthread_mutex_unlock(&p->lock);
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_unlock(&p->lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
if (usecnt < 0)
ast_log(LOG_WARNING, "Usecnt < 0???\n");
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
prev = NULL;
if (p->destroy) {
}
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return 0;
}
int index;
int oldstate = ast->_state;
ast_setstate(ast, AST_STATE_UP);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
if (index < 0)
index = SUB_REAL;
/* nothing to do if a radio channel */
if (p->radio) {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
switch(p->sig) {
break;
#endif
case 0:
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
default:
ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
res = -1;
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
/* cant do pseudo-channels here */
if ((!p0->sig) || (!p1->sig)) return -2;
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
op0 = p0 = c0->pvt->pvt;
op1 = p1 = c1->pvt->pvt;
ofd1 = c0->fds[0];
- ast_pthread_mutex_lock(&p0->lock);
- if (pthread_mutex_trylock(&p1->lock)) {
+ ast_mutex_lock(&p0->lock);
+ if (ast_mutex_trylock(&p1->lock)) {
/* Don't block, due to potential for deadlock */
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
return -3;
}
t1 = p0->subs[SUB_REAL].inthreeway;
t2 = p1->subs[SUB_REAL].inthreeway;
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&p1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&p1->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
/* Native bridge failed */
if ((!master || !slave) && !nothingok) {
for (;;) {
/* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
p0 = c0->pvt->pvt;
p1 = c1->pvt->pvt;
if (op0 == p0)
i1 = zt_get_index(c0, p0, 1);
if (op1 == p1)
i2 = zt_get_index(c1, p1, 1);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
if ((op0 != p0) || (op1 != p1) ||
(ofd1 != c0->fds[0]) ||
(ofd2 != c1->fds[0]) ||
int index;
struct ast_frame *f;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 1);
ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", event2str(res));
}
f = &p->subs[index].f;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
if (!p->radio) ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
f = &p->subs[index].f;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
f = zt_handle_event(ast);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
struct ast_frame *f;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
/* Hang up if we don't really exist */
if (index < 0) {
ast_log(LOG_WARNING, "We dont exist?\n");
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
{
p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
if (p->ringt == 1) {
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
else if (p->ringt > 0)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RINGING;
ast_setstate(ast, AST_STATE_RINGING);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
}
} else {
ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
if (res == -1) {
if (errno == EAGAIN) {
/* Return "NULL" frame if there is nobody there */
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
} else
ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
f = zt_handle_event(ast);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
if (p->tdd) { /* if in TDD mode, see if we receive that */
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
p->subs[index].f.datalen = 1;
*((char *) p->subs[index].f.data) = c;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
}
f = &p->subs[index].f;
}
#endif
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
}
i->subs[index].owner = tmp;
ast_setstate(tmp, state);
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt++;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
/* Copy call forward info */
#endif
for(;;) {
/* Lock the interface list */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_ERROR, "Unable to grab interface lock\n");
return NULL;
}
i = i->next;
}
/* Okay, now that we know what to do, release the interface lock */
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
pthread_testcancel();
/* Wait at least a second for something to happen */
}
/* 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;
}
} else {
/* Start a new monitor */
if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
return -1;
}
#if 0
printf("Created thread %ld detached in restart monitor\n", monitor_thread);
#endif
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
return 0;
}
tmp->propconfno = -1;
}
tmp->transfer = transfer;
- ast_pthread_mutex_init(&tmp->lock);
+ ast_mutex_init(&tmp->lock);
strncpy(tmp->language, language, sizeof(tmp->language)-1);
strncpy(tmp->musicclass, musicclass, sizeof(tmp->musicclass)-1);
strncpy(tmp->context, context, sizeof(tmp->context)-1);
channelmatch = x;
}
/* Search for an unowned channel */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return NULL;
}
else
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
return tmp;
}
FD_SET(pri->fd, &rfds);
FD_SET(pri->fd, &efds);
time(&t);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (pri->resetting && pri->up) {
if (!pri->resetchannel)
pri_check_restart(pri);
tv.tv_sec = 60;
tv.tv_usec = 0;
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
e = NULL;
res = ast_select(pri->fd + 1, &rfds, NULL, &efds, &tv);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (!res) {
/* Just a timeout, run the scheduler */
e = pri_schedule_run(pri->pri);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "B-channel %d restarted on span %d\n",
chan, pri->span);
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
/* Force soft hangup if appropriate */
if (pri->pvt[chan]->owner)
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
}
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_2 "Restart on requested on entire span %d\n", pri->span);
for (x=1;x <= pri->channels;x++)
if ((x != pri->dchannel) && pri->pvt[x]) {
- ast_pthread_mutex_lock(&pri->pvt[x]->lock);
+ ast_mutex_lock(&pri->pvt[x]->lock);
if (pri->pvt[x]->owner)
pri->pvt[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
- ast_pthread_mutex_unlock(&pri->pvt[x]->lock);
+ ast_mutex_unlock(&pri->pvt[x]->lock);
}
}
break;
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
if (!pri->pvt[chan]->alreadyhungup) {
/* we're calling here zt_hangup so once we get there we need to clear p->call after calling pri_hangup */
pri->pvt[chan]->alreadyhungup = 1;
pri_reset(pri->pri, chan);
pri->pvt[chan]->resetting = 1;
}
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
} else {
ast_log(LOG_WARNING, "Hangup on bad channel %d\n", e->hangup.channel);
}
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
if (pri->pvt[chan]->owner) {
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (option_verbose > 2)
pri_reset(pri->pri, chan);
pri->pvt[chan]->resetting = 1;
}
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
} else {
ast_log(LOG_WARNING, "Hangup REQ on bad channel %d\n", e->hangup.channel);
}
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
pri->pvt[chan]->call = NULL;
pri->pvt[chan]->resetting = 0;
if (pri->pvt[chan]->owner) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup ACK\n", chan, pri->span);
}
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
}
}
break;
for (x=1;x<=pri->channels;x++) {
if (pri->pvt[x] && pri->pvt[x]->resetting) {
chan = x;
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d span %d\n", chan, pri->span);
if (pri->pvt[chan]->owner) {
ast_log(LOG_WARNING, "Got restart ack on channel %d with owner\n", chan);
pri->pvt[chan]->resetting = 0;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span);
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
if (pri->resetting)
pri_check_restart(pri);
break;
}
if ((chan >= 1) && (chan <= pri->channels)) {
if (pri->pvt[chan]) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
if (pri->pvt[chan]->owner) {
ast_log(LOG_WARNING, "Got restart ack on channel %d with owner\n", chan);
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
pri->pvt[chan]->resetting = 0;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span);
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
if (pri->resetting)
pri_check_restart(pri);
}
if (option_debug)
ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
/* Never reached */
return NULL;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
ast_cli(fd, FORMAT2, "Chan. Num.", "Extension", "Context", "Language", "MusicOnHold");
tmp = iflist;
ast_cli(fd, FORMAT, tmp->channel, tmp->exten, tmp->context, tmp->language, tmp->musicclass);
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
return RESULT_SHOWUSAGE;
channel = atoi(argv[3]);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
while (tmp) {
if (tmp->channel == channel) {
ast_cli(fd, "Actual Confmute: %s\n", x ? "Yes" : "No");
}
#endif
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
}
tmp = tmp->next;
}
ast_cli(fd, "Unable to find given channel %d\n", channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_FAILURE;
}
}
- 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;
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
} 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;
}
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
ast_log(LOG_WARNING, "Ignoring %s\n", v->name);
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our Zap channel type */
if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_channel);
ast_cli_unregister(&cli_destroy_channel);
- if (!ast_pthread_mutex_lock(&iflock)) {
+ if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
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;
}
- 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;
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
stringp=v->value;
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
if (finish < start) {
} else {
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
}
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
} else if (!strcasecmp(v->name, "minunused")) {
if (tmp->destroy) {
if (destroy_channel(prev, tmp, 0)) {
ast_log(LOG_ERROR, "Unable to destroy chan_zap channel %d\n", tmp->channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
tmp = tmp->next;
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
ast_destroy(cfg);
#if 0
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 matchdigittimeout = 3000;
static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of zt_pvt's) */
-static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t iflock = AST_MUTEX_INITIALIZER;
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
-static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
/* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
#ifdef ZAPATA_PRI
struct zt_pri {
pthread_t master; /* Thread of master */
- pthread_mutex_t lock; /* Mutex */
+ ast_mutex_t lock; /* Mutex */
char idleext[AST_MAX_EXTENSION]; /* Where to idle extra calls */
char idlecontext[AST_MAX_EXTENSION]; /* What context to use for idle */
char idledial[AST_MAX_EXTENSION]; /* What to dial before dumping */
{
int res;
/* Grab the lock first */
- res = ast_pthread_mutex_lock(&pri->lock);
+ res = ast_mutex_lock(&pri->lock);
if (res)
return res;
/* Then break the select */
static inline void pri_rel(struct zt_pri *pri)
{
- ast_pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
static int switchtype = PRI_SWITCH_NI2;
#define MAX_SLAVES 4
static struct zt_pvt {
- pthread_mutex_t lock;
+ ast_mutex_t lock;
struct ast_channel *owner; /* Our current active owner (if applicable) */
/* Up to three channels can be associated with this call */
p->callwaitingrepeat = 0;
ast->pvt->pvt = NULL;
ast_setstate(ast, AST_STATE_DOWN);
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
if (usecnt < 0)
ast_log(LOG_WARNING, "Usecnt < 0???\n");
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
prev = NULL;
if (p->destroy) {
}
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return 0;
}
/* cant do pseudo-channels here */
if ((!p0->sig) || (!p1->sig)) return -2;
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
op0 = p0 = c0->pvt->pvt;
op1 = p1 = c1->pvt->pvt;
ofd1 = c0->fds[0];
- ast_pthread_mutex_lock(&p0->lock);
- if (pthread_mutex_trylock(&p1->lock)) {
+ ast_mutex_lock(&p0->lock);
+ if (ast_mutex_trylock(&p1->lock)) {
/* Don't block, due to potential for deadlock */
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
return -3;
}
t1 = p0->subs[SUB_REAL].inthreeway;
t2 = p1->subs[SUB_REAL].inthreeway;
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&p1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&p1->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
/* Native bridge failed */
if ((!master || !slave) && !nothingok)
for (;;) {
/* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
p0 = c0->pvt->pvt;
p1 = c1->pvt->pvt;
if (op0 == p0)
i1 = zt_get_index(c0, p0, 1);
if (op1 == p1)
i2 = zt_get_index(c1, p1, 1);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
if ((op0 != p0) || (op1 != p1) ||
(ofd1 != c0->fds[0]) ||
(ofd2 != c1->fds[0]) ||
struct ast_frame *f;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
/* Hang up if we don't really exist */
if (index < 0) {
ast_log(LOG_WARNING, "We dont exist?\n");
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
{
p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
if (p->ringt == 1) {
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
else if (p->ringt > 0)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RINGING;
ast_setstate(ast, AST_STATE_RINGING);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
}
} else {
ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
if (res < 0) {
if (res == -1)
ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
if (res != READ_SIZE) {
}
p->callwaitcas = 0;
/* Return NULL */
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
} else {
strncpy(p->subs[index].dtmfq + strlen(p->subs[index].dtmfq), zap_dtmfbuf(p->subs[index].z), sizeof(p->subs[index].dtmfq) - strlen(p->subs[index].dtmfq)-1);
}
}
} else {
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return zt_handle_event(ast);
}
if (strlen(p->subs[index].dtmfq)) {
ast_log(LOG_DEBUG, "Fax already handled\n");
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
p->subs[index].f.frametype = AST_FRAME_DTMF;
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
if (p->tdd) { /* if in TDD mode, see if we receive that */
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
p->subs[index].f.datalen = 1;
*((char *) p->subs[index].f.data) = c;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
}
}
} else
f = &p->subs[index].f;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
}
i->subs[index].owner = tmp;
ast_setstate(tmp, state);
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt++;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
/* Copy call forward info */
#endif
for(;;) {
/* Lock the interface list */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_ERROR, "Unable to grab interface lock\n");
return NULL;
}
i = i->next;
}
/* Okay, now that we know what to do, release the interface lock */
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
pthread_testcancel();
/* Wait at least a second for something to happen */
}
/* 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;
}
} else {
/* Start a new monitor */
if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
return -1;
}
#if 0
printf("Created thread %ld detached in restart monitor\n", monitor_thread);
#endif
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
return 0;
}
channelmatch = x;
}
/* Search for an unowned channel */
- if (ast_pthread_mutex_lock(&iflock)) {
+ if (ast_mutex_lock(&iflock)) {
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return NULL;
}
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
return tmp;
}
FD_SET(pri->fd, &rfds);
FD_SET(pri->fd, &efds);
time(&t);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (pri->resetting && pri->up) {
/* Look for a resetable channel and go */
if ((t - pri->lastreset) > 0) {
tv.tv_sec = 60;
tv.tv_usec = 0;
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
e = NULL;
res = ast_select(pri->fd + 1, &rfds, NULL, &efds, &tv);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (!res) {
/* Just a timeout, run the scheduler */
e = pri_schedule_run(pri->pri);
if (option_debug)
ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
/* Never reached */
return NULL;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
ast_cli(fd, FORMAT2, "Chan. Num.", "Extension", "Context", "Language", "MusicOnHold");
tmp = iflist;
ast_cli(fd, FORMAT, tmp->channel, tmp->exten, tmp->context, tmp->language, tmp->musicclass);
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
return RESULT_SHOWUSAGE;
channel = atoi(argv[3]);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
while (tmp) {
if (tmp->channel == channel) {
ast_cli(fd, "\n");
}
#endif
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
}
tmp = tmp->next;
}
ast_cli(fd, "Unable to find given channel %d\n", channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_FAILURE;
}
}
- 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;
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
} 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;
}
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
ast_log(LOG_DEBUG, "Ignoring %s\n", v->name);
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our Zap channel type */
if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_channel);
ast_cli_unregister(&cli_destroy_channel);
- if (!ast_pthread_mutex_lock(&iflock)) {
+ if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
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;
}
- 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;
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
stringp=v->value;
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
if (finish < start) {
} else {
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
}
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
} else if (!strcasecmp(v->name, "minunused")) {
if (tmp->destroy) {
if (destroy_channel(prev, tmp, 0)) {
ast_log(LOG_ERROR, "Unable to destroy chan_zap channel %d\n", tmp->channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
tmp = tmp->next;
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
ast_destroy(cfg);
#if 0
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;
}
write(fd, stuff, strlen(stuff));
}
-pthread_mutex_t clilock = AST_MUTEX_INITIALIZER;
+ast_mutex_t clilock = AST_MUTEX_INITIALIZER;
struct ast_cli_entry *helpers = NULL;
#define MODLIST_FORMAT "%-20s %-40.40s %-10d\n"
#define MODLIST_FORMAT2 "%-20s %-40.40s %-10s\n"
-static pthread_mutex_t climodentrylock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t climodentrylock = AST_MUTEX_INITIALIZER;
static int climodentryfd = -1;
static int modlist_modentry(char *module, char *description, int usecnt)
{
if (argc != 2)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&climodentrylock);
+ ast_mutex_lock(&climodentrylock);
climodentryfd = fd;
ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
ast_update_module_list(modlist_modentry);
climodentryfd = -1;
- ast_pthread_mutex_unlock(&climodentrylock);
+ ast_mutex_unlock(&climodentrylock);
return RESULT_SUCCESS;
}
int ast_cli_unregister(struct ast_cli_entry *e)
{
struct ast_cli_entry *cur, *l=NULL;
- ast_pthread_mutex_lock(&clilock);
+ ast_mutex_lock(&clilock);
cur = helpers;
while(cur) {
if (e == cur) {
l = cur;
cur = cur->next;
}
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
return 0;
}
struct ast_cli_entry *cur, *l=NULL;
char fulle[80] ="", fulltst[80] ="";
static int len;
- ast_pthread_mutex_lock(&clilock);
+ ast_mutex_lock(&clilock);
join2(fulle, sizeof(fulle), e->cmda);
if (find_cli(e->cmda, -1)) {
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", fulle);
return -1;
}
helpers = e;
e->next = NULL;
}
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
return 0;
}
if ((dup = parse_args(text, &x, argv))) {
join(matchstr, sizeof(matchstr), argv);
if (lock)
- ast_pthread_mutex_lock(&clilock);
+ ast_mutex_lock(&clilock);
e1 = builtins;
e2 = helpers;
while(e1->cmda[0] || e2) {
}
if (res) {
if (lock)
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
free(dup);
return res ? strdup(res) : NULL;
}
command can have this occur */
fullcmd = e->generator(text, word, (strlen(word) ? (x - 1) : (x)), state);
if (lock)
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
return fullcmd;
}
}
if (lock)
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
free(dup);
}
return NULL;
if ((dup = parse_args(s, &x, argv))) {
/* We need at least one entry, or ignore */
if (x > 0) {
- ast_pthread_mutex_lock(&clilock);
+ ast_mutex_lock(&clilock);
e = find_cli(argv, 0);
if (e)
e->inuse++;
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
if (e) {
switch(e->handler(fd, x, argv)) {
case RESULT_SHOWUSAGE:
} else
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
if (e) {
- ast_pthread_mutex_lock(&clilock);
+ ast_mutex_lock(&clilock);
e->inuse--;
- ast_pthread_mutex_unlock(&clilock);
+ ast_mutex_unlock(&clilock);
}
}
free(dup);
#define BUFFER_SIZE 8096 /* size for the translation buffers */
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt = 0;
static char *tdesc = "A-law and Mulaw direct Coder/Decoder";
unload_module (void)
{
int res;
- ast_pthread_mutex_lock (&localuser_lock);
+ ast_mutex_lock (&localuser_lock);
res = ast_unregister_translator (&ulawtoalaw);
if (!res)
res = ast_unregister_translator (&alawtoulaw);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock (&localuser_lock);
+ ast_mutex_unlock (&localuser_lock);
return res;
}
#define BUFFER_SIZE 8096 /* size for the translation buffers */
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt = 0;
static char *tdesc = "Adaptive Differential PCM Coder/Decoder";
unload_module (void)
{
int res;
- ast_pthread_mutex_lock (&localuser_lock);
+ ast_mutex_lock (&localuser_lock);
res = ast_unregister_translator (&lintoadpcm);
if (!res)
res = ast_unregister_translator (&adpcmtolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock (&localuser_lock);
+ ast_mutex_unlock (&localuser_lock);
return res;
}
#define BUFFER_SIZE 8096 /* size for the translation buffers */
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt = 0;
static char *tdesc = "A-law Coder/Decoder";
unload_module (void)
{
int res;
- ast_pthread_mutex_lock (&localuser_lock);
+ ast_mutex_lock (&localuser_lock);
res = ast_unregister_translator (&lintoalaw);
if (!res)
res = ast_unregister_translator (&alawtolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock (&localuser_lock);
+ ast_mutex_unlock (&localuser_lock);
return res;
}
#include "slin_g723_ex.h"
#include "g723_slin_ex.h"
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt=0;
#ifdef ANNEX_B
int unload_module(void)
{
int res;
- ast_pthread_mutex_lock(&localuser_lock);
+ ast_mutex_lock(&localuser_lock);
res = ast_unregister_translator(&lintog723);
if (!res)
res = ast_unregister_translator(&g723tolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock(&localuser_lock);
+ ast_mutex_unlock(&localuser_lock);
return res;
}
#include "slin_gsm_ex.h"
#include "gsm_slin_ex.h"
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt=0;
static char *tdesc = "GSM/PCM16 (signed linear) Codec Translator";
int unload_module(void)
{
int res;
- ast_pthread_mutex_lock(&localuser_lock);
+ ast_mutex_lock(&localuser_lock);
res = ast_unregister_translator(&lintogsm);
if (!res)
res = ast_unregister_translator(&gsmtolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock(&localuser_lock);
+ ast_mutex_unlock(&localuser_lock);
return res;
}
#define USE_ILBC_ENHANCER 0
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt=0;
static char *tdesc = "iLBC/PCM16 (signed linear) Codec Translator";
int unload_module(void)
{
int res;
- ast_pthread_mutex_lock(&localuser_lock);
+ ast_mutex_lock(&localuser_lock);
res = ast_unregister_translator(&lintoilbc);
if (!res)
res = ast_unregister_translator(&ilbctolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock(&localuser_lock);
+ ast_mutex_unlock(&localuser_lock);
return res;
}
#define LPC10_BYTES_IN_COMPRESSED_FRAME (LPC10_BITS_IN_COMPRESSED_FRAME + 7)/8
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt=0;
static char *tdesc = "LPC10 2.4kbps (signed linear) Voice Coder";
int unload_module(void)
{
int res;
- ast_pthread_mutex_lock(&localuser_lock);
+ ast_mutex_lock(&localuser_lock);
res = ast_unregister_translator(&lintolpc10);
if (!res)
res = ast_unregister_translator(&lpc10tolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock(&localuser_lock);
+ ast_mutex_unlock(&localuser_lock);
return res;
}
#define MAX_FRAME_SIZE 1441
#define MAX_OUTPUT_LEN 2304
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt=0;
static char *tdesc = "MP3/PCM16 (signed linear) Translator (Decoder only)";
int unload_module(void)
{
int res;
- ast_pthread_mutex_lock(&localuser_lock);
+ ast_mutex_lock(&localuser_lock);
res = ast_unregister_translator(&mp3tolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock(&localuser_lock);
+ ast_mutex_unlock(&localuser_lock);
return res;
}
#include "slin_speex_ex.h"
#include "speex_slin_ex.h"
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt=0;
static char *tdesc = "Speex/PCM16 (signed linear) Codec Translator";
int unload_module(void)
{
int res;
- ast_pthread_mutex_lock(&localuser_lock);
+ ast_mutex_lock(&localuser_lock);
res = ast_unregister_translator(&lintospeex);
if (!res)
res = ast_unregister_translator(&speextolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock(&localuser_lock);
+ ast_mutex_unlock(&localuser_lock);
return res;
}
#define BUFFER_SIZE 8096 /* size for the translation buffers */
-static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt = 0;
static char *tdesc = "Mu-law Coder/Decoder";
unload_module (void)
{
int res;
- ast_pthread_mutex_lock (&localuser_lock);
+ ast_mutex_lock (&localuser_lock);
res = ast_unregister_translator (&lintoulaw);
if (!res)
res = ast_unregister_translator (&ulawtolin);
if (localusecnt)
res = -1;
- ast_pthread_mutex_unlock (&localuser_lock);
+ ast_mutex_unlock (&localuser_lock);
return res;
}
#include "astconf.h"
static DB *astdb;
-static pthread_mutex_t dblock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t dblock = AST_MUTEX_INITIALIZER;
static int dbinit(void)
{
else
strcpy(prefix, "");
- ast_pthread_mutex_lock(&dblock);
+ ast_mutex_lock(&dblock);
if (dbinit())
return -1;
}
}
astdb->sync(astdb, 0);
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
return 0;
}
DBT key, data;
int res;
- ast_pthread_mutex_lock(&dblock);
+ ast_mutex_lock(&dblock);
if (dbinit()) {
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
return -1;
}
data.size = strlen(value) + 1;
res = astdb->put(astdb, &key, &data, 0);
astdb->sync(astdb, 0);
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
if (res)
ast_log(LOG_WARNING, "Unable to put value '%s' for key '%s' in family '%s'\n", value, keys, family);
return res;
DBT key, data;
int res;
- ast_pthread_mutex_lock(&dblock);
+ ast_mutex_lock(&dblock);
if (dbinit()) {
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
return -1;
}
res = astdb->get(astdb, &key, &data, 0);
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
/* Be sure to NULL terminate our data either way */
if (res) {
DBT key;
int res;
- ast_pthread_mutex_lock(&dblock);
+ ast_mutex_lock(&dblock);
if (dbinit()) {
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
return -1;
}
res = astdb->del(astdb, &key, 0);
astdb->sync(astdb, 0);
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
if (res)
ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
strcpy(prefix, "");
} else
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&dblock);
+ ast_mutex_lock(&dblock);
if (dbinit()) {
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
ast_cli(fd, "Database unavailable\n");
return RESULT_SUCCESS;
}
ast_cli(fd, "%-50s: %-25s\n", keys, values);
}
}
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
return RESULT_SUCCESS;
}
snprintf(prefix, sizeof(prefix), "/%s", family);
} else
strcpy(prefix, "");
- ast_pthread_mutex_lock(&dblock);
+ ast_mutex_lock(&dblock);
if (dbinit()) {
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
ast_log(LOG_WARNING, "Database unavailable\n");
return NULL;
}
}
}
}
- ast_pthread_mutex_unlock(&dblock);
+ ast_mutex_unlock(&dblock);
return ret;
}
static int enumver = 0;
-static pthread_mutex_t enumlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t enumlock = AST_MUTEX_INITIALIZER;
static int skip_name(unsigned char *s, int len)
{
#endif
for(;;) {
- ast_pthread_mutex_lock(&enumlock);
+ ast_mutex_lock(&enumlock);
if (version != enumver) {
/* Ooh, a reload... */
s = toplevs;
if (s) {
strcpy(tmp + newpos, s->toplev);
}
- ast_pthread_mutex_unlock(&enumlock);
+ ast_mutex_unlock(&enumlock);
if (!s)
break;
res = res_nsearch(&enumstate, tmp, C_IN, T_NAPTR, answer, sizeof(answer));
struct ast_variable *v;
/* Destroy existing list */
- ast_pthread_mutex_lock(&enumlock);
+ ast_mutex_lock(&enumlock);
s = toplevs;
while(s) {
sl = s;
toplevs = enum_newtoplev(TOPLEV);
}
enumver++;
- ast_pthread_mutex_unlock(&enumlock);
+ ast_mutex_unlock(&enumlock);
return 0;
}
struct ast_channel *owner;
};
-static pthread_mutex_t formatlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t formatlock = AST_MUTEX_INITIALIZER;
static struct ast_format *formats = NULL;
char * (*getcomment)(struct ast_filestream *))
{
struct ast_format *tmp;
- if (ast_pthread_mutex_lock(&formatlock)) {
+ if (ast_mutex_lock(&formatlock)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return -1;
}
tmp = formats;
while(tmp) {
if (!strcasecmp(name, tmp->name)) {
- ast_pthread_mutex_unlock(&formatlock);
+ ast_mutex_unlock(&formatlock);
ast_log(LOG_WARNING, "Tried to register '%s' format, already registered\n", name);
return -1;
}
tmp = malloc(sizeof(struct ast_format));
if (!tmp) {
ast_log(LOG_WARNING, "Out of memory\n");
- ast_pthread_mutex_unlock(&formatlock);
+ ast_mutex_unlock(&formatlock);
return -1;
}
strncpy(tmp->name, name, sizeof(tmp->name)-1);
tmp->getcomment = getcomment;
tmp->next = formats;
formats = tmp;
- ast_pthread_mutex_unlock(&formatlock);
+ ast_mutex_unlock(&formatlock);
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s\n", name, exts);
return 0;
int ast_format_unregister(char *name)
{
struct ast_format *tmp, *tmpl = NULL;
- if (ast_pthread_mutex_lock(&formatlock)) {
+ if (ast_mutex_lock(&formatlock)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return -1;
}
else
formats = tmp->next;
free(tmp);
- ast_pthread_mutex_unlock(&formatlock);
+ ast_mutex_unlock(&formatlock);
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name);
return 0;
if (action == ACTION_OPEN)
ret = -1;
/* Check for a specific format */
- if (ast_pthread_mutex_lock(&formatlock)) {
+ if (ast_mutex_lock(&formatlock)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
if (action == ACTION_EXISTS)
return 0;
}
f = f->next;
}
- ast_pthread_mutex_unlock(&formatlock);
+ ast_mutex_unlock(&formatlock);
if ((action == ACTION_EXISTS) || (action == ACTION_OPEN))
res = ret ? ret : -1;
return res;
struct ast_filestream *fs=NULL;
char *fn;
char *ext;
- if (ast_pthread_mutex_lock(&formatlock)) {
+ if (ast_mutex_lock(&formatlock)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return NULL;
}
}
f = f->next;
}
- ast_pthread_mutex_unlock(&formatlock);
+ ast_mutex_unlock(&formatlock);
if (!f)
ast_log(LOG_WARNING, "No such format '%s'\n", type);
return fs;
};
-static pthread_mutex_t g723_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t g723_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "g723sf";
and be sure it's a valid file. */
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
- if (ast_pthread_mutex_lock(&g723_lock)) {
+ if (ast_mutex_lock(&g723_lock)) {
ast_log(LOG_WARNING, "Unable to lock g723 list\n");
free(tmp);
return NULL;
tmp->orig.tv_usec = 0;
tmp->orig.tv_sec = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&g723_lock);
+ ast_mutex_unlock(&g723_lock);
ast_update_use_count();
}
return tmp;
and be sure it's a valid file. */
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
- if (ast_pthread_mutex_lock(&g723_lock)) {
+ if (ast_mutex_lock(&g723_lock)) {
ast_log(LOG_WARNING, "Unable to lock g723 list\n");
free(tmp);
return NULL;
tmp->orig.tv_usec = 0;
tmp->orig.tv_sec = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&g723_lock);
+ ast_mutex_unlock(&g723_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void g723_close(struct ast_filestream *s)
{
struct ast_filestream *tmp, *tmpl = NULL;
- if (ast_pthread_mutex_lock(&g723_lock)) {
+ if (ast_mutex_lock(&g723_lock)) {
ast_log(LOG_WARNING, "Unable to lock g723 list\n");
return;
}
ast_sched_del(s->owner->sched, s->owner->streamid);
s->owner->streamid = -1;
}
- ast_pthread_mutex_unlock(&g723_lock);
+ ast_mutex_unlock(&g723_lock);
ast_update_use_count();
if (!tmp)
ast_log(LOG_WARNING, "Freeing a filestream we don't seem to own\n");
int unload_module()
{
struct ast_filestream *tmp, *tmpl;
- if (ast_pthread_mutex_lock(&g723_lock)) {
+ if (ast_mutex_lock(&g723_lock)) {
ast_log(LOG_WARNING, "Unable to lock g723 list\n");
return -1;
}
tmp = tmp->next;
free(tmpl);
}
- ast_pthread_mutex_unlock(&g723_lock);
+ ast_mutex_unlock(&g723_lock);
return ast_format_unregister(name);
}
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&g723_lock)) {
+ if (ast_mutex_lock(&g723_lock)) {
ast_log(LOG_WARNING, "Unable to lock g723 list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&g723_lock);
+ ast_mutex_unlock(&g723_lock);
return res;
}
};
-static pthread_mutex_t g729_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t g729_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "g729";
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&g729_lock)) {
+ if (ast_mutex_lock(&g729_lock)) {
ast_log(LOG_WARNING, "Unable to lock g729 list\n");
free(tmp);
return NULL;
tmp->fr.src = name;
tmp->fr.mallocd = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&g729_lock);
+ ast_mutex_unlock(&g729_lock);
ast_update_use_count();
}
return tmp;
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&g729_lock)) {
+ if (ast_mutex_lock(&g729_lock)) {
ast_log(LOG_WARNING, "Unable to lock g729 list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&g729_lock);
+ ast_mutex_unlock(&g729_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void g729_close(struct ast_filestream *s)
{
- if (ast_pthread_mutex_lock(&g729_lock)) {
+ if (ast_mutex_lock(&g729_lock)) {
ast_log(LOG_WARNING, "Unable to lock g729 list\n");
return;
}
glistcnt--;
- ast_pthread_mutex_unlock(&g729_lock);
+ ast_mutex_unlock(&g729_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&g729_lock)) {
+ if (ast_mutex_lock(&g729_lock)) {
ast_log(LOG_WARNING, "Unable to lock g729 list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&g729_lock);
+ ast_mutex_unlock(&g729_lock);
return res;
}
};
-static pthread_mutex_t gsm_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t gsm_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "gsm";
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&gsm_lock)) {
+ if (ast_mutex_lock(&gsm_lock)) {
ast_log(LOG_WARNING, "Unable to lock gsm list\n");
free(tmp);
return NULL;
tmp->fr.src = name;
tmp->fr.mallocd = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&gsm_lock);
+ ast_mutex_unlock(&gsm_lock);
ast_update_use_count();
}
return tmp;
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&gsm_lock)) {
+ if (ast_mutex_lock(&gsm_lock)) {
ast_log(LOG_WARNING, "Unable to lock gsm list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&gsm_lock);
+ ast_mutex_unlock(&gsm_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void gsm_close(struct ast_filestream *s)
{
- if (ast_pthread_mutex_lock(&gsm_lock)) {
+ if (ast_mutex_lock(&gsm_lock)) {
ast_log(LOG_WARNING, "Unable to lock gsm list\n");
return;
}
glistcnt--;
- ast_pthread_mutex_unlock(&gsm_lock);
+ ast_mutex_unlock(&gsm_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&gsm_lock)) {
+ if (ast_mutex_lock(&gsm_lock)) {
ast_log(LOG_WARNING, "Unable to lock gsm list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&gsm_lock);
+ ast_mutex_unlock(&gsm_lock);
return res;
}
};
-static pthread_mutex_t h263_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t h263_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "h263";
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&h263_lock)) {
+ if (ast_mutex_lock(&h263_lock)) {
ast_log(LOG_WARNING, "Unable to lock h263 list\n");
free(tmp);
return NULL;
tmp->fr.src = name;
tmp->fr.mallocd = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&h263_lock);
+ ast_mutex_unlock(&h263_lock);
ast_update_use_count();
}
return tmp;
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&h263_lock)) {
+ if (ast_mutex_lock(&h263_lock)) {
ast_log(LOG_WARNING, "Unable to lock h263 list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&h263_lock);
+ ast_mutex_unlock(&h263_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void h263_close(struct ast_filestream *s)
{
- if (ast_pthread_mutex_lock(&h263_lock)) {
+ if (ast_mutex_lock(&h263_lock)) {
ast_log(LOG_WARNING, "Unable to lock h263 list\n");
return;
}
glistcnt--;
- ast_pthread_mutex_unlock(&h263_lock);
+ ast_mutex_unlock(&h263_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&h263_lock)) {
+ if (ast_mutex_lock(&h263_lock)) {
ast_log(LOG_WARNING, "Unable to lock h263 list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&h263_lock);
+ ast_mutex_unlock(&h263_lock);
return res;
}
static struct ast_filestream *glist = NULL;
-static pthread_mutex_t mp3_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t mp3_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "mp3";
and be sure it's a valid file. */
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
- if (ast_pthread_mutex_lock(&mp3_lock)) {
+ if (ast_mutex_lock(&mp3_lock)) {
ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
free(tmp);
return NULL;
tmp->last.tv_usec = 0;
tmp->last.tv_sec = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&mp3_lock);
+ ast_mutex_unlock(&mp3_lock);
ast_update_use_count();
}
return tmp;
and be sure it's a valid file. */
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
- if (ast_pthread_mutex_lock(&mp3_lock)) {
+ if (ast_mutex_lock(&mp3_lock)) {
ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&mp3_lock);
+ ast_mutex_unlock(&mp3_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void mp3_close(struct ast_filestream *s)
{
- if (ast_pthread_mutex_lock(&mp3_lock)) {
+ if (ast_mutex_lock(&mp3_lock)) {
ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
return;
}
glistcnt--;
- ast_pthread_mutex_unlock(&mp3_lock);
+ ast_mutex_unlock(&mp3_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&mp3_lock)) {
+ if (ast_mutex_lock(&mp3_lock)) {
ast_log(LOG_WARNING, "Unable to lock mp3 list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&mp3_lock);
+ ast_mutex_unlock(&mp3_lock);
return res;
}
};
-static pthread_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "pcm";
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
tmp->fr.src = name;
tmp->fr.mallocd = 0;
glistcnt++;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
}
return tmp;
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void pcm_close(struct ast_filestream *s)
{
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
return;
}
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
return -1;
}
res = glistcnt;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
return res;
}
};
-static pthread_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "alaw";
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
tmp->start_time = get_time();
#endif
glistcnt++;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
}
return tmp;
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
tmp->start_time = get_time();
#endif
glistcnt++;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void pcm_close(struct ast_filestream *s)
{
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
return;
}
glistcnt--;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (pthread_mutex_lock(&pcm_lock)) {
+ if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
return -1;
}
res = glistcnt;
- pthread_mutex_unlock(&pcm_lock);
+ ast_mutex_unlock(&pcm_lock);
return res;
}
};
-static pthread_mutex_t vox_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t vox_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "vox";
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&vox_lock)) {
+ if (ast_mutex_lock(&vox_lock)) {
ast_log(LOG_WARNING, "Unable to lock vox list\n");
free(tmp);
return NULL;
tmp->fr.mallocd = 0;
tmp->lasttimeout = -1;
glistcnt++;
- ast_pthread_mutex_unlock(&vox_lock);
+ ast_mutex_unlock(&vox_lock);
ast_update_use_count();
}
return tmp;
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
- if (ast_pthread_mutex_lock(&vox_lock)) {
+ if (ast_mutex_lock(&vox_lock)) {
ast_log(LOG_WARNING, "Unable to lock vox list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&vox_lock);
+ ast_mutex_unlock(&vox_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void vox_close(struct ast_filestream *s)
{
- if (ast_pthread_mutex_lock(&vox_lock)) {
+ if (ast_mutex_lock(&vox_lock)) {
ast_log(LOG_WARNING, "Unable to lock vox list\n");
return;
}
glistcnt--;
- ast_pthread_mutex_unlock(&vox_lock);
+ ast_mutex_unlock(&vox_lock);
ast_update_use_count();
close(s->fd);
free(s);
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&vox_lock)) {
+ if (ast_mutex_lock(&vox_lock)) {
ast_log(LOG_WARNING, "Unable to lock vox list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&vox_lock);
+ ast_mutex_unlock(&vox_lock);
return res;
}
};
-static pthread_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "wav";
free(tmp);
return NULL;
}
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
free(tmp);
return NULL;
tmp->fr.mallocd = 0;
tmp->bytes = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
ast_update_use_count();
}
return tmp;
free(tmp);
return NULL;
}
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void wav_close(struct ast_filestream *s)
{
char zero = 0;
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
return;
}
glistcnt--;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
ast_update_use_count();
/* Pad to even length */
if (s->bytes & 0x1)
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
return res;
}
};
-static pthread_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t wav_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "wav49";
free(tmp);
return NULL;
}
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
free(tmp);
return NULL;
tmp->fr.mallocd = 0;
tmp->secondhalf = 0;
glistcnt++;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
ast_update_use_count();
}
return tmp;
free(tmp);
return NULL;
}
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
static void wav_close(struct ast_filestream *s)
{
char zero = 0;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
ast_update_use_count();
/* Pad to even length */
if (s->bytes & 0x1)
int usecount()
{
int res;
- if (ast_pthread_mutex_lock(&wav_lock)) {
+ if (ast_mutex_lock(&wav_lock)) {
ast_log(LOG_WARNING, "Unable to lock wav list\n");
return -1;
}
res = glistcnt;
- ast_pthread_mutex_unlock(&wav_lock);
+ ast_mutex_unlock(&wav_lock);
return res;
}
#ifdef TRACE_FRAMES
static int headers = 0;
static struct ast_frame *headerlist = NULL;
-static pthread_mutex_t framelock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t framelock = AST_MUTEX_INITIALIZER;
#endif
#define SMOOTHER_SIZE 8000
if (f) {
headers++;
f->prev = NULL;
- ast_pthread_mutex_lock(&framelock);
+ ast_mutex_lock(&framelock);
f->next = headerlist;
if (headerlist)
headerlist->prev = f;
headerlist = f;
- pthread_mutex_unlock(&framelock);
+ ast_mutex_unlock(&framelock);
}
#endif
return f;
if (fr->mallocd & AST_MALLOCD_HDR) {
#ifdef TRACE_FRAMES
headers--;
- ast_pthread_mutex_lock(&framelock);
+ ast_mutex_lock(&framelock);
if (fr->next)
fr->next->prev = fr->prev;
if (fr->prev)
fr->prev->next = fr->next;
else
headerlist = fr->next;
- pthread_mutex_unlock(&framelock);
+ ast_mutex_unlock(&framelock);
#endif
free(fr);
}
ast_cli(fd, "---------------------------\n");
ast_cli(fd, "Total allocated headers: %d\n", headers);
ast_cli(fd, "Queue Dump:\n");
- ast_pthread_mutex_lock(&framelock);
+ ast_mutex_lock(&framelock);
for (f=headerlist; f; f = f->next) {
ast_cli(fd, "%d. Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
}
- pthread_mutex_unlock(&framelock);
+ ast_mutex_unlock(&framelock);
return RESULT_SUCCESS;
}
#include "astconf.h"
static struct ast_imager *list;
-static pthread_mutex_t listlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t listlock = AST_MUTEX_INITIALIZER;
int ast_image_register(struct ast_imager *img)
{
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc);
- ast_pthread_mutex_lock(&listlock);
+ ast_mutex_lock(&listlock);
img->next = list;
list = img;
- ast_pthread_mutex_unlock(&listlock);
+ ast_mutex_unlock(&listlock);
return 0;
}
void ast_image_unregister(struct ast_imager *img)
{
struct ast_imager *i, *prev = NULL;
- ast_pthread_mutex_lock(&listlock);
+ ast_mutex_lock(&listlock);
i = list;
while(i) {
if (i == img) {
prev = i;
i = i->next;
}
- ast_pthread_mutex_unlock(&listlock);
+ ast_mutex_unlock(&listlock);
if (i && (option_verbose > 1))
ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc);
}
int len=0;
struct ast_frame *f = NULL;
#if 0 /* We need to have some sort of read-only lock */
- ast_pthread_mutex_lock(&listlock);
+ ast_mutex_lock(&listlock);
#endif
i = list;
while(!found && i) {
} else
ast_log(LOG_WARNING, "Image file '%s' not found\n", filename);
#if 0
- ast_pthread_mutex_unlock(&listlock);
+ ast_mutex_unlock(&listlock);
#endif
return f;
}
/*! If anyone is blocking, this is them */
pthread_t blocker;
/*! Lock, can be used to lock a channel for some operations */
- pthread_mutex_t lock;
+ ast_mutex_t lock;
/*! Procedure causing blocking */
char *blockproc;
#ifndef _ASTERISK_INDICATIONS_H
#define _ASTERISK_INDICATIONS_H
+#include <asterisk/lock.h>
+
/* forward reference */
struct ast_channel;
void ast_playtones_stop(struct ast_channel *chan);
extern struct tone_zone *tone_zones;
-extern pthread_mutex_t tzlock;
+extern ast_mutex_t tzlock;
#endif
#define ASTERISK_LINKEDLISTS_H
#include <pthread.h>
+#include <asterisk/lock.h>
#define AST_LIST_LOCK(head) \
- ast_pthread_mutex_lock(&head->lock)
+ ast_mutex_lock(&head->lock)
#define AST_LIST_UNLOCK(head) \
- ast_pthread_mutex_unlock(&head->lock)
+ ast_mutex_unlock(&head->lock)
#define AST_LIST_HEAD(name, type) \
struct name { \
struct type *first; \
- pthread_mutex_t lock; \
+ ast_mutex_t lock; \
}
#define AST_LIST_HEAD_INITIALIZER(head) \
- { NULL, PTHREAD_MUTEX_INITIALIZER }
+ { NULL, AST_MUTEX_INITIALIZER }
#define AST_LIST_HEAD_SET(head,entry) do { \
(head)->first=(entry); \
- pthread_mutex_init(&(head)->lock,NULL); \
+ ast_pthread_mutex_init(&(head)->lock,NULL); \
} while (0)
#define AST_LIST_ENTRY(type) \
#define AST_LIST_HEAD_INIT(head) { \
(head)->first = NULL; \
- pthread_mutex_init(&(head)->lock,NULL); \
+ ast_pthread_mutex_init(&(head)->lock,NULL); \
}
#define AST_LIST_INSERT_AFTER(listelm, elm, field) do { \
// #define AST_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
// #define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-#define AST_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
+#define AST_MUTEX_INITIALIZER { PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, NULL, 0, NULL, 0 }
#else
#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-#define AST_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#define AST_MUTEX_INITIALIZER { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, NULL, 0, NULL, 0 }
#else
-#define AST_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+#define AST_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, NULL, 0, NULL, 0 }
#endif
#endif
#ifdef PTHREAD_MUTEX_ERRORCHECK_NP
#define AST_MUTEX_KIND PTHREAD_MUTEX_ERRORCHECK
#endif
-struct mutex_info {
- pthread_mutex_t *mutex;
+struct ast_mutex_info {
+ pthread_mutex_t mutex;
char *file;
int lineno;
char *func;
- struct mutex_info *next;
+ pthread_t thread;
};
-static inline int ast_pthread_mutex_init(pthread_mutex_t *t) {
+typedef struct ast_mutex_info ast_mutex_t;
+
+static inline int ast_mutex_init(ast_mutex_t *t) {
static pthread_mutexattr_t attr;
static int init = 1;
+ int res;
extern int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int);
if (init) {
pthread_mutexattr_setkind_np(&attr, AST_MUTEX_KIND);
init = 0;
}
- return pthread_mutex_init(t, &attr);
+ res = pthread_mutex_init(&t->mutex, &attr);
+ t->file = NULL;
+ t->lineno = 0;
+ t->func = 0;
+ t->thread = 0;
+ return res;
}
-static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *func, pthread_mutex_t *t) {
+static inline int ast_pthread_mutex_init(ast_mutex_t *t, pthread_mutexattr_t *attr)
+{
int res;
- int tries = TRIES;
- do {
- res = pthread_mutex_trylock(t);
- /* If we can't run, yield */
- if (res) {
- sched_yield();
- usleep(1);
- }
- } while(res && tries--);
- if (res) {
- fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n",
- filename, lineno, func, strerror(res));
- if ((res = pthread_mutex_lock(t)))
- fprintf(stderr, "%s line %d (%s): Error waiting for mutex: %s\n",
- filename, lineno, func, strerror(res));
- else
- fprintf(stderr, "%s line %d (%s): Got it eventually...\n",
- filename, lineno, func);
+ res = pthread_mutex_init(&t->mutex, attr);
+ t->file = NULL;
+ t->lineno = 0;
+ t->func = 0;
+ t->thread = 0;
+ return res;
+}
+
+static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *func, ast_mutex_t *t) {
+ int res;
+ res = pthread_mutex_lock(&t->mutex);
+ if (!res) {
+ t->file = filename;
+ t->lineno = lineno;
+ t->func = func;
+ t->thread = pthread_self();
+ } else {
+ fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n",
+ filename, lineno, func, strerror(errno));
}
return res;
}
-#define ast_pthread_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+#define ast_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
-static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *func, pthread_mutex_t *t) {
+static inline int __ast_pthread_mutex_trylock(char *filename, int lineno, char *func, ast_mutex_t *t) {
int res;
- res = pthread_mutex_unlock(t);
+ res = pthread_mutex_trylock(&t->mutex);
+ if (!res) {
+ t->file = filename;
+ t->lineno = lineno;
+ t->func = func;
+ t->thread = pthread_self();
+ }
+ return res;
+}
+
+#define ast_mutex_trylock(a) __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+
+static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *func, ast_mutex_t *t) {
+ int res;
+ /* Assumes lock is actually held */
+ t->file = NULL;
+ t->lineno = 0;
+ t->func = NULL;
+ t->thread = 0;
+ res = pthread_mutex_unlock(&t->mutex);
if (res)
fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n",
filename, lineno, func, strerror(res));
return res;
}
-#define ast_pthread_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+#define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
+
+static inline int __ast_pthread_mutex_destroy(char *filename, int lineno, char *func, ast_mutex_t *t)
+{
+ int res;
+ t->file = NULL;
+ t->lineno = 0;
+ t->func = NULL;
+ t->thread = 0;
+ res = pthread_mutex_destroy(&t->mutex);
+ if (res)
+ fprintf(stderr, "%s line %d (%s): Error destroying mutex: %s\n",
+ filename, lineno, func, strerror(res));
+ return res;
+}
+
+#define ast_mutex_destroy(a) __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, a)
#else
#define AST_MUTEX_KIND PTHREAD_NORMAL
#endif
-#define ast_pthread_mutex_init(mutex) pthread_mutex_init(mutex, NULL)
-#define ast_pthread_mutex_lock pthread_mutex_lock
-#define ast_pthread_mutex_unlock pthread_mutex_unlock
+typedef pthread_mutex_t ast_mutex_t;
+
+static inline int ast_mutex_lock(ast_mutex_t *t)
+{
+ return pthread_mutex_lock(t);
+}
+
+static inline int ast_mutex_unlock(ast_mutex_t *t)
+{
+ return pthread_mutex_unlock(t);
+}
+
+static inline int ast_mutex_trylock(ast_mutex_t *t)
+{
+ return pthread_mutex_trylock(t);
+}
+
+static inline int ast_pthread_mutex_init(ast_mutex_t *t, const pthread_mutexattr_t *mutexattr)
+{
+ return pthread_mutex_init(t, mutexattr);
+}
+
+static inline int ast_mutex_init(ast_mutex_t *t)
+{
+ return pthread_mutex_init(t, NULL);
+}
+static inline int ast_mutex_destroy(ast_mutex_t *t)
+{
+ return pthread_mutex_destroy(t);
+}
#endif
+#define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t
+#define pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock
+#define pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock
+#define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock
+#define pthread_mutex_init use_ast_pthread_mutex_init_instead_of_pthread_mutex_init
+#define pthread_mutex_destroy use_ast_pthread_mutex_destroy_instead_of_pthread_mutex_destroy
+
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <asterisk/lock.h>
+
/*
* Call management packages are text fields of the form a: b. There is
* always exactly one space after the colon.
struct mansession {
pthread_t t;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
struct sockaddr_in sin;
int fd;
int blocking;
struct localuser *next; \
}
-#define LOCAL_USER_DECL static pthread_mutex_t localuser_lock = AST_MUTEX_INITIALIZER; \
+#define LOCAL_USER_DECL static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER; \
static struct localuser *localusers = NULL; \
static int localusecnt = 0;
ast_log(LOG_WARNING, "Out of memory\n"); \
return -1; \
} \
- pthread_mutex_lock(&localuser_lock); \
+ ast_mutex_lock(&localuser_lock); \
u->chan = chan; \
u->next = localusers; \
localusers = u; \
localusecnt++; \
- pthread_mutex_unlock(&localuser_lock); \
+ ast_mutex_unlock(&localuser_lock); \
ast_update_use_count(); \
}
#define LOCAL_USER_REMOVE(u) { \
struct localuser *uc, *ul = NULL; \
- pthread_mutex_lock(&localuser_lock); \
+ ast_mutex_lock(&localuser_lock); \
uc = localusers; \
while (uc) { \
if (uc == u) { \
}\
free(u); \
localusecnt--; \
- pthread_mutex_unlock(&localuser_lock); \
+ ast_mutex_unlock(&localuser_lock); \
ast_update_use_count(); \
}
#define STANDARD_HANGUP_LOCALUSERS { \
struct localuser *u, *ul; \
- pthread_mutex_lock(&localuser_lock); \
+ ast_mutex_lock(&localuser_lock); \
u = localusers; \
while(u) { \
ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD); \
u = u->next; \
free(ul); \
} \
- pthread_mutex_unlock(&localuser_lock); \
+ ast_mutex_unlock(&localuser_lock); \
localusecnt=0; \
}
#define STANDARD_USECOUNT(res) { \
- pthread_mutex_lock(&localuser_lock); \
+ ast_mutex_lock(&localuser_lock); \
res = localusecnt; \
- pthread_mutex_unlock(&localuser_lock); \
+ ast_mutex_unlock(&localuser_lock); \
}
#include <asterisk/channel.h>
#include <asterisk/logger.h>
-#define PTHREAD_MUTEX_LOCK(a) ast_pthread_mutex_lock(a)
-#define PTHREAD_MUTEX_UNLOCK(a) ast_pthread_mutex_unlock(a)
-
struct playtones_item {
int freq1;
int freq2;
/* Protect the tone_zones list (highly unlikely that two things would change
* it at the same time, but still! */
-pthread_mutex_t tzlock = AST_MUTEX_INITIALIZER;
+ast_mutex_t tzlock = AST_MUTEX_INITIALIZER;
/* Set global indication country */
int ast_set_indication_country(const char *country)
if (country == NULL)
return 0; /* not a single country insight */
- if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return 0;
}
country = tz->alias;
break;
}
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return tz;
}
}
} while (++alias_loop<20 && tz);
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
if (alias_loop==20)
ast_log(LOG_NOTICE,"Alias loop for '%s' forcefull broken\n",country);
/* nothing found, sorry */
if (zone == NULL)
return 0; /* not a single country insight */
- if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return 0;
}
for (ts=zone->tones; ts; ts=ts->next) {
if (strcasecmp(indication,ts->name)==0) {
/* found indication! */
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return ts;
}
}
/* nothing found, sorry */
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return 0;
}
{
struct tone_zone *tz,*pz;
- if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return -1;
}
current_tonezone = zone;
/* now free the previous zone */
free_zone(tz);
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return 0;
}
}
pz->next = zone;
else
tone_zones = zone;
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
ast_verbose(VERBOSE_PREFIX_3 "Registered indication country '%s'\n",zone->country);
return 0;
struct tone_zone *tz, *pz = NULL, *tmp;
int res = -1;
- if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return -1;
}
tz = tz->next;
}
}
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return res;
}
if (zone->alias[0])
return -1;
- if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return -2;
}
ts = malloc(sizeof(struct tone_zone_sound));
if (!ts) {
ast_log(LOG_WARNING, "Out of memory\n");
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return -2;
}
ts->next = NULL;
ts->data = strdup(tonelist);
if (ts->name==NULL || ts->data==NULL) {
ast_log(LOG_WARNING, "Out of memory\n");
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return -2;
}
if (ps)
ps->next = ts;
else
zone->tones = ts;
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return 0;
}
if (zone->alias[0])
return -1;
- if (PTHREAD_MUTEX_LOCK(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return -1;
}
}
}
/* indication not found, goodbye */
- PTHREAD_MUTEX_UNLOCK(&tzlock);
+ ast_mutex_unlock(&tzlock);
return res;
}
struct loadupdate *next;
} *updaters = NULL;
-static pthread_mutex_t modlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t modlock = AST_MUTEX_INITIALIZER;
static struct module *module_list=NULL;
{
struct module *m, *ml = NULL;
int res = -1;
- if (ast_pthread_mutex_lock(&modlock))
+ if (ast_mutex_lock(&modlock))
ast_log(LOG_WARNING, "Failed to lock\n");
m = module_list;
while(m) {
ast_log(LOG_WARNING, "Warning: Forcing removal of module %s with use count %d\n", resource_name, res);
else {
ast_log(LOG_WARNING, "Soft unload failed, '%s' has use count %d\n", resource_name, res);
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return -1;
}
}
if (res) {
ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name);
if (force <= AST_FORCE_FIRM) {
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return -1;
} else
ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n");
ml = m;
m = m->next;
}
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
ast_update_use_count();
return res;
}
ast_rtp_reload();
time(&ast_lastreloadtime);
- ast_pthread_mutex_lock(&modlock);
+ ast_mutex_lock(&modlock);
m = module_list;
while(m) {
if (m->reload) {
}
m = m->next;
}
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
}
int ast_load_resource(char *resource_name)
#endif
}
- if (ast_pthread_mutex_lock(&modlock))
+ if (ast_mutex_lock(&modlock))
ast_log(LOG_WARNING, "Failed to lock\n");
m = module_list;
while(m) {
if (!strcasecmp(m->resource, resource_name)) {
ast_log(LOG_WARNING, "Module '%s' already exists\n", resource_name);
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return -1;
}
m = m->next;
m = malloc(sizeof(struct module));
if (!m) {
ast_log(LOG_WARNING, "Out of memory\n");
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return -1;
}
strncpy(m->resource, resource_name, sizeof(m->resource)-1);
if (!m->lib) {
ast_log(LOG_WARNING, "%s\n", dlerror());
free(m);
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return -1;
}
m->load_module = dlsym(m->lib, "load_module");
ast_log(LOG_WARNING, "%d error(s) loading module %s, aborted\n", errors, fn);
dlclose(m->lib);
free(m);
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return -1;
}
if (!fully_booted) {
m->next = module_list;
module_list = m;
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
if ((res = m->load_module())) {
ast_log(LOG_WARNING, "%s: load_module failed, returning %d\n", m->resource, res);
ast_unload_resource(resource_name, 0);
static int ast_resource_exists(char *resource)
{
struct module *m;
- if (ast_pthread_mutex_lock(&modlock))
+ if (ast_mutex_lock(&modlock))
ast_log(LOG_WARNING, "Failed to lock\n");
m = module_list;
while(m) {
break;
m = m->next;
}
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
if (m)
return -1;
else
/* Notify any module monitors that the use count for a
resource has changed */
struct loadupdate *m;
- if (ast_pthread_mutex_lock(&modlock))
+ if (ast_mutex_lock(&modlock))
ast_log(LOG_WARNING, "Failed to lock\n");
m = updaters;
while(m) {
m->updater();
m = m->next;
}
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
}
{
struct module *m;
int unlock = -1;
- if (pthread_mutex_trylock(&modlock))
+ if (ast_mutex_trylock(&modlock))
unlock = 0;
m = module_list;
while(m) {
m = m->next;
}
if (unlock)
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return 0;
}
/* XXX Should be more flexible here, taking > 1 verboser XXX */
if ((tmp = malloc(sizeof (struct loadupdate)))) {
tmp->updater = v;
- if (ast_pthread_mutex_lock(&modlock))
+ if (ast_mutex_lock(&modlock))
ast_log(LOG_WARNING, "Failed to lock\n");
tmp->next = updaters;
updaters = tmp;
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return 0;
}
return -1;
{
int res = -1;
struct loadupdate *tmp, *tmpl=NULL;
- if (ast_pthread_mutex_lock(&modlock))
+ if (ast_mutex_lock(&modlock))
ast_log(LOG_WARNING, "Failed to lock\n");
tmp = updaters;
while(tmp) {
}
if (tmp)
res = 0;
- ast_pthread_mutex_unlock(&modlock);
+ ast_mutex_unlock(&modlock);
return res;
}
#define MAX_MSG_QUEUE 200
-static pthread_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
-static pthread_mutex_t loglock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t loglock = AST_MUTEX_INITIALIZER;
static struct msglist {
char *msg;
struct ast_config *cfg;
struct ast_variable *var;
- ast_pthread_mutex_lock(&loglock);
+ ast_mutex_lock(&loglock);
/* Free anything that is here */
f = logfiles;
logfiles = NULL;
- ast_pthread_mutex_unlock(&loglock);
+ ast_mutex_unlock(&loglock);
cfg = ast_load("logger.conf");
- ast_pthread_mutex_lock(&loglock);
+ ast_mutex_lock(&loglock);
/* If no config file, we're fine */
if (!cfg) {
- ast_pthread_mutex_unlock(&loglock);
+ ast_mutex_unlock(&loglock);
return;
}
var = ast_variable_browse(cfg, "logfiles");
logfiles = make_logfile("ignore", "", -1);
}
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&loglock);
+ ast_mutex_unlock(&loglock);
}
int reload_logger(void)
{
char tmp[AST_CONFIG_MAX_PATH];
- ast_pthread_mutex_lock(&loglock);
+ ast_mutex_lock(&loglock);
if (eventlog)
fclose(eventlog);
mkdir((char *)ast_config_AST_LOG_DIR, 0755);
snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
eventlog = fopen((char *)tmp, "a");
- ast_pthread_mutex_unlock(&loglock);
+ ast_mutex_unlock(&loglock);
if (eventlog) {
init_logger_chain();
if (!option_verbose && !option_debug && (!level)) {
return;
}
- ast_pthread_mutex_lock(&loglock);
+ ast_mutex_lock(&loglock);
if (level == 1 /* Event */) {
time(&t);
localtime_r(&t,&tm);
fflush(stdout);
}
}
- ast_pthread_mutex_unlock(&loglock);
+ ast_mutex_unlock(&loglock);
}
extern void ast_verbose(const char *fmt, ...)
struct verb *v;
va_list ap;
va_start(ap, fmt);
- ast_pthread_mutex_lock(&msglist_lock);
+ ast_mutex_lock(&msglist_lock);
vsnprintf(stuff + pos, sizeof(stuff) - pos, fmt, ap);
opos = pos;
pos = strlen(stuff);
else
replacelast = pos = 0;
va_end(ap);
- ast_pthread_mutex_unlock(&msglist_lock);
+ ast_mutex_unlock(&msglist_lock);
}
int ast_verbose_dmesg(void (*v)(const char *string, int opos, int replacelast, int complete))
{
struct msglist *m;
m = list;
- ast_pthread_mutex_lock(&msglist_lock);
+ ast_mutex_lock(&msglist_lock);
while(m) {
/* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
v(m->msg, 0, 0, 1);
m = m->next;
}
- ast_pthread_mutex_unlock(&msglist_lock);
+ ast_mutex_unlock(&msglist_lock);
return 0;
}
/* XXX Should be more flexible here, taking > 1 verboser XXX */
if ((tmp = malloc(sizeof (struct verb)))) {
tmp->verboser = v;
- ast_pthread_mutex_lock(&msglist_lock);
+ ast_mutex_lock(&msglist_lock);
tmp->next = verboser;
verboser = tmp;
m = list;
v(m->msg, 0, 0, 1);
m = m->next;
}
- ast_pthread_mutex_unlock(&msglist_lock);
+ ast_mutex_unlock(&msglist_lock);
return 0;
}
return -1;
{
int res = -1;
struct verb *tmp, *tmpl=NULL;
- ast_pthread_mutex_lock(&msglist_lock);
+ ast_mutex_lock(&msglist_lock);
tmp = verboser;
while(tmp) {
if (tmp->verboser == v) {
}
if (tmp)
res = 0;
- ast_pthread_mutex_unlock(&msglist_lock);
+ ast_mutex_unlock(&msglist_lock);
return res;
}
static int portno = DEFAULT_MANAGER_PORT;
static int asock = -1;
static pthread_t t;
-static pthread_mutex_t sessionlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t sessionlock = AST_MUTEX_INITIALIZER;
static struct permalias {
int num;
static struct mansession *sessions = NULL;
static struct manager_action *first_action = NULL;
-static pthread_mutex_t actionlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t actionlock = AST_MUTEX_INITIALIZER;
static int handle_showmancmds(int fd, int argc, char *argv[])
{
struct manager_action *cur = first_action;
- ast_pthread_mutex_lock(&actionlock);
+ ast_mutex_lock(&actionlock);
while(cur) { /* Walk the list of actions */
ast_cli(fd, "\t%s %s\r\n",cur->action, cur->synopsis);
cur = cur->next;
}
- ast_pthread_mutex_unlock(&actionlock);
+ ast_mutex_unlock(&actionlock);
return RESULT_SUCCESS;
}
{
struct mansession *s;
- ast_pthread_mutex_lock(&sessionlock);
+ ast_mutex_lock(&sessionlock);
s = sessions;
ast_cli(fd, " Username\tIP Address\n");
while(s) {
s = s->next;
}
- ast_pthread_mutex_unlock(&sessionlock);
+ ast_mutex_unlock(&sessionlock);
return RESULT_SUCCESS;
}
static void destroy_session(struct mansession *s)
{
struct mansession *cur, *prev = NULL;
- ast_pthread_mutex_lock(&sessionlock);
+ ast_mutex_lock(&sessionlock);
cur = sessions;
while(cur) {
if (cur == s)
free(s);
} else
ast_log(LOG_WARNING, "Trying to delete non-existant session %p?\n", s);
- ast_pthread_mutex_unlock(&sessionlock);
+ ast_mutex_unlock(&sessionlock);
}
void astman_send_error(struct mansession *s, char *error)
{
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
ast_cli(s->fd, "Response: Error\r\n");
ast_cli(s->fd, "Message: %s\r\n\r\n", error);
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
}
void astman_send_response(struct mansession *s, char *resp, char *msg)
{
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
ast_cli(s->fd, "Response: %s\r\n", resp);
if (msg)
ast_cli(s->fd, "Message: %s\r\n\r\n", msg);
else
ast_cli(s->fd, "\r\n");
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
}
void astman_send_ack(struct mansession *s, char *msg)
static int action_command(struct mansession *s, struct message *m)
{
char *cmd = astman_get_header(m, "Command");
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
s->blocking = 1;
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
ast_cli(s->fd, "Response: Follows\r\n");
ast_cli_command(s->fd, cmd);
ast_cli(s->fd, "--END COMMAND--\r\n\r\n");
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
s->blocking = 0;
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
return 0;
}
authtype = astman_get_header(m, "AuthType");
if (!strcasecmp(authtype, "MD5")) {
if (!s->challenge || !strlen(s->challenge)) {
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
snprintf(s->challenge, sizeof(s->challenge), "%d", rand());
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
}
ast_cli(s->fd, "Response: Success\r\nChallenge: %s\r\n\r\n", s->challenge);
return 0;
if (res < 0) {
ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
} else if (res > 0) {
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
res = read(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen);
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
if (res < 1)
return -1;
}
struct message m;
int res;
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
ast_cli(s->fd, "Asterisk Call Manager/1.0\r\n");
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
memset(&m, 0, sizeof(&m));
for (;;) {
res = get_input(s, m.headers[m.hdrcount]);
}
memset(s, 0, sizeof(struct mansession));
memcpy(&s->sin, &sin, sizeof(sin));
- ast_pthread_mutex_init(&s->lock);
+ ast_mutex_init(&s->lock);
s->fd = as;
- ast_pthread_mutex_lock(&sessionlock);
+ ast_mutex_lock(&sessionlock);
s->next = sessions;
sessions = s;
- ast_pthread_mutex_unlock(&sessionlock);
+ ast_mutex_unlock(&sessionlock);
if (pthread_create(&t, &attr, session_do, s))
destroy_session(s);
}
char tmp[4096];
va_list ap;
- ast_pthread_mutex_lock(&sessionlock);
+ ast_mutex_lock(&sessionlock);
s = sessions;
while(s) {
if ((s->readperm & category) == category) {
- ast_pthread_mutex_lock(&s->lock);
+ ast_mutex_lock(&s->lock);
if (!s->blocking) {
ast_cli(s->fd, "Event: %s\r\n", event);
va_start(ap, fmt);
write(s->fd, tmp, strlen(tmp));
ast_cli(s->fd, "\r\n");
}
- ast_pthread_mutex_unlock(&s->lock);
+ ast_mutex_unlock(&s->lock);
}
s = s->next;
}
- ast_pthread_mutex_unlock(&sessionlock);
+ ast_mutex_unlock(&sessionlock);
return 0;
}
int ast_manager_unregister( char *action ) {
struct manager_action *cur = first_action, *prev = first_action;
- ast_pthread_mutex_lock(&actionlock);
+ ast_mutex_lock(&actionlock);
while( cur ) {
if (!strcasecmp(action, cur->action)) {
prev->next = cur->next;
free(cur);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action);
- ast_pthread_mutex_unlock(&actionlock);
+ ast_mutex_unlock(&actionlock);
return 0;
}
prev = cur;
cur = cur->next;
}
- ast_pthread_mutex_unlock(&actionlock);
+ ast_mutex_unlock(&actionlock);
return 0;
}
{
struct manager_action *cur = first_action, *prev = NULL;
- ast_pthread_mutex_lock(&actionlock);
+ ast_mutex_lock(&actionlock);
while(cur) { /* Walk the list of actions */
prev = cur;
cur = cur->next;
cur = malloc( sizeof(struct manager_action) );
if( !cur ) {
ast_log(LOG_WARNING, "Manager: out of memory trying to register action\n");
- ast_pthread_mutex_unlock(&actionlock);
+ ast_mutex_unlock(&actionlock);
return -1;
}
strncpy( cur->action, action, 255 );
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Manager registered action %s\n", action);
- ast_pthread_mutex_unlock(&actionlock);
+ ast_mutex_unlock(&actionlock);
return 0;
}
/* Name of the context */
char name[AST_MAX_EXTENSION];
/* A lock to prevent multiple threads from clobbering the context */
- pthread_mutex_t lock;
+ ast_mutex_t lock;
/* The root of the list of extensions */
struct ast_exten *root;
/* Link them together */
};
/* Lock for the application list */
-static pthread_mutex_t applock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t applock = AST_MUTEX_INITIALIZER;
static struct ast_context *contexts = NULL;
/* Lock for the ast_context list */
-static pthread_mutex_t conlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t conlock = AST_MUTEX_INITIALIZER;
static struct ast_app *apps = NULL;
/* Lock for switches */
-static pthread_mutex_t switchlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t switchlock = AST_MUTEX_INITIALIZER;
struct ast_switch *switches = NULL;
/* Lock for extension state notifys */
-static pthread_mutex_t hintlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t hintlock = AST_MUTEX_INITIALIZER;
static int stateid = 1;
struct ast_hint *hints = NULL;
struct ast_state_cb *statecbs = NULL;
struct ast_app *pbx_findapp(char *app)
{
struct ast_app *tmp;
- if (ast_pthread_mutex_lock(&applock)) {
+ if (ast_mutex_lock(&applock)) {
ast_log(LOG_WARNING, "Unable to obtain application lock\n");
return NULL;
}
break;
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return tmp;
}
static struct ast_switch *pbx_findswitch(char *sw)
{
struct ast_switch *asw;
- if (ast_pthread_mutex_lock(&switchlock)) {
+ if (ast_mutex_lock(&switchlock)) {
ast_log(LOG_WARNING, "Unable to obtain application lock\n");
return NULL;
}
break;
asw = asw->next;
}
- ast_pthread_mutex_unlock(&switchlock);
+ ast_mutex_unlock(&switchlock);
return asw;
}
struct ast_context *ast_context_find(char *name)
{
struct ast_context *tmp;
- ast_pthread_mutex_lock(&conlock);
+ ast_mutex_lock(&conlock);
if (name) {
tmp = contexts;
while(tmp) {
}
} else
tmp = contexts;
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return tmp;
}
char tmp[80];
char tmp2[80];
char tmp3[256];
- if (ast_pthread_mutex_lock(&conlock)) {
+ if (ast_mutex_lock(&conlock)) {
ast_log(LOG_WARNING, "Unable to obtain lock\n");
if ((action == HELPER_EXISTS) || (action == HELPER_CANMATCH) || (action == HELPER_MATCHMORE))
return 0;
if (e) {
switch(action) {
case HELPER_CANMATCH:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return -1;
case HELPER_EXISTS:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return -1;
case HELPER_MATCHMORE:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return -1;
case HELPER_SPAWN:
newstack++;
/* Fall through */
case HELPER_EXEC:
app = pbx_findapp(e->app);
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
if (app) {
if (c->context != context)
strncpy(c->context, context, sizeof(c->context-1));
} else if (sw) {
switch(action) {
case HELPER_CANMATCH:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return -1;
case HELPER_EXISTS:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return -1;
case HELPER_MATCHMORE:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return -1;
case HELPER_SPAWN:
newstack++;
/* Fall through */
case HELPER_EXEC:
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
if (sw->exec)
res = sw->exec(c, context, exten, priority, callerid, newstack, data);
else {
return -1;
}
} else {
- pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
switch(status) {
case STATUS_NO_CONTEXT:
if ((action != HELPER_EXISTS) && (action != HELPER_MATCHMORE))
char *incstack[AST_PBX_MAX_STACK];
int stacklen = 0;
- if (ast_pthread_mutex_lock(&conlock)) {
+ if (ast_mutex_lock(&conlock)) {
ast_log(LOG_WARNING, "Unable to obtain lock\n");
return NULL;
}
e = pbx_find_extension(c, context, exten, PRIORITY_HINT, "", HELPER_EXISTS, incstack, &stacklen, &status, &sw, &data);
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return e;
}
*rest = 0;
}
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
list = hints;
list = list->next;
}
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 1;
}
/* No context and extension add callback to statecbs list */
if (!context && !exten) {
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
cblist = statecbs;
while (cblist) {
if (cblist->callback == callback) {
cblist->data = data;
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
}
cblist = cblist->next;
/* Now inserts the callback */
cblist = malloc(sizeof(struct ast_state_cb));
if (!cblist) {
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
memset(cblist, 0, sizeof(struct ast_state_cb));
cblist->next = statecbs;
statecbs = cblist;
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 0;
}
return -1;
}
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
list = hints;
while (list) {
}
if (!list) {
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
/* Now inserts the callback */
cblist = malloc(sizeof(struct ast_state_cb));
if (!cblist) {
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
memset(cblist, 0, sizeof(struct ast_state_cb));
cblist->next = list->callbacks;
list->callbacks = cblist;
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return cblist->id;
}
if (!id && !callback)
return -1;
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
/* id is zero is a callback without extension */
if (!id) {
free(cblist);
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 0;
}
cbprev = cblist;
cblist = cblist->next;
}
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
return -1;
}
free(cblist);
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 0;
}
cbprev = cblist;
list = list->next;
}
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
if (!e) return -1;
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
list = hints;
/* Search if hint exists, do nothing */
while (list) {
if (list->exten == e) {
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
list = list->next;
list = malloc(sizeof(struct ast_hint));
if (!list) {
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
/* Initialize and insert new item */
list->next = hints;
hints = list;
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 0;
}
{
struct ast_hint *list;
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
list = hints;
while(list) {
if (list->exten == oe) {
list->exten = ne;
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 0;
}
list = list->next;
}
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
if (!e)
return -1;
- pthread_mutex_lock(&hintlock);
+ ast_mutex_lock(&hintlock);
list = hints;
while(list) {
free(list);
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return 0;
} else {
prev = list;
}
}
- pthread_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&hintlock);
return -1;
}
{
struct ast_include *i, *pi = NULL;
- if (ast_pthread_mutex_lock(&con->lock)) return -1;
+ if (ast_mutex_lock(&con->lock)) return -1;
/* walk includes */
i = con->includes;
con->includes = i->next;
/* free include and return */
free(i);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
}
pi = i;
}
/* we can't find the right include */
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return -1;
}
{
struct ast_sw *i, *pi = NULL;
- if (ast_pthread_mutex_lock(&con->lock)) return -1;
+ if (ast_mutex_lock(&con->lock)) return -1;
/* walk switchs */
i = con->alts;
con->alts = i->next;
/* free switch and return */
free(i);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
}
pi = i;
}
/* we can't find the right switch */
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return -1;
}
{
struct ast_exten *exten, *prev_exten = NULL;
- if (ast_pthread_mutex_lock(&con->lock)) return -1;
+ if (ast_mutex_lock(&con->lock)) return -1;
/* go through all extensions in context and search the right one ... */
exten = con->root;
peer = exten;
}
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
} else {
/* remove only extension with exten->priority == priority */
peer->datad(peer->data);
free(peer);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
} else {
/* this is not right extension, skip to next peer */
}
}
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return -1;
}
}
}
/* we can't find right extension */
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return -1;
}
{
struct ast_app *tmp, *prev, *cur;
char tmps[80];
- if (ast_pthread_mutex_lock(&applock)) {
+ if (ast_mutex_lock(&applock)) {
ast_log(LOG_ERROR, "Unable to lock application list\n");
return -1;
}
while(tmp) {
if (!strcasecmp(app, tmp->name)) {
ast_log(LOG_WARNING, "Already have an application '%s'\n", app);
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return -1;
}
tmp = tmp->next;
}
} else {
ast_log(LOG_WARNING, "Out of memory\n");
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return -1;
}
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps)));
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return 0;
}
int ast_register_switch(struct ast_switch *sw)
{
struct ast_switch *tmp, *prev=NULL;
- if (ast_pthread_mutex_lock(&switchlock)) {
+ if (ast_mutex_lock(&switchlock)) {
ast_log(LOG_ERROR, "Unable to lock switch lock\n");
return -1;
}
tmp = tmp->next;
}
if (tmp) {
- ast_pthread_mutex_unlock(&switchlock);
+ ast_mutex_unlock(&switchlock);
ast_log(LOG_WARNING, "Switch '%s' already found\n", sw->name);
return -1;
}
prev->next = sw;
else
switches = sw;
- ast_pthread_mutex_unlock(&switchlock);
+ ast_mutex_unlock(&switchlock);
return 0;
}
void ast_unregister_switch(struct ast_switch *sw)
{
struct ast_switch *tmp, *prev=NULL;
- if (ast_pthread_mutex_lock(&switchlock)) {
+ if (ast_mutex_lock(&switchlock)) {
ast_log(LOG_ERROR, "Unable to lock switch lock\n");
return;
}
prev = tmp;
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&switchlock);
+ ast_mutex_unlock(&switchlock);
}
/*
int which = 0;
/* try to lock applications list ... */
- if (ast_pthread_mutex_lock(&applock)) {
+ if (ast_mutex_lock(&applock)) {
ast_log(LOG_ERROR, "Unable to lock application list\n");
return NULL;
}
/* ... if this is right app serve it ... */
if (++which > state) {
char *ret = strdup(a->name);
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return ret;
}
}
}
/* no application match */
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return NULL;
}
if (argc < 3) return RESULT_SHOWUSAGE;
/* try to lock applications list ... */
- if (ast_pthread_mutex_lock(&applock)) {
+ if (ast_mutex_lock(&applock)) {
ast_log(LOG_ERROR, "Unable to lock application list\n");
return -1;
}
a = a->next;
}
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
/* we found at least one app? no? */
if (no_registered_app) {
}
/* ... we have applications ... */
ast_cli(fd, "\n -= Registered Asterisk Alternative Switches =-\n");
- if (ast_pthread_mutex_lock(&switchlock)) {
+ if (ast_mutex_lock(&switchlock)) {
ast_log(LOG_ERROR, "Unable to lock switches\n");
return -1;
}
ast_cli(fd, "%s: %s\n", sw->name, sw->description);
sw = sw->next;
}
- ast_pthread_mutex_unlock(&switchlock);
+ ast_mutex_unlock(&switchlock);
return RESULT_SUCCESS;
}
struct ast_app *a;
/* try to lock applications list ... */
- if (ast_pthread_mutex_lock(&applock)) {
+ if (ast_mutex_lock(&applock)) {
ast_log(LOG_ERROR, "Unable to lock application list\n");
return -1;
}
/* ... have we got at least one application (first)? no? */
if (!a) {
ast_cli(fd, "There is no registered applications\n");
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return -1;
}
}
/* ... unlock and return */
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return RESULT_SUCCESS;
}
int ast_unregister_application(char *app) {
struct ast_app *tmp, *tmpl = NULL;
- if (ast_pthread_mutex_lock(&applock)) {
+ if (ast_mutex_lock(&applock)) {
ast_log(LOG_ERROR, "Unable to lock application list\n");
return -1;
}
apps = tmp->next;
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name);
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return 0;
}
tmpl = tmp;
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&applock);
+ ast_mutex_unlock(&applock);
return -1;
}
struct ast_context *tmp, **local_contexts;
if (!extcontexts) {
local_contexts = &contexts;
- ast_pthread_mutex_lock(&conlock);
+ ast_mutex_lock(&conlock);
} else
local_contexts = extcontexts;
tmp = *local_contexts;
while(tmp) {
if (!strcasecmp(tmp->name, name)) {
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name);
if (!extcontexts)
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return NULL;
}
tmp = tmp->next;
tmp = malloc(sizeof(struct ast_context));
if (tmp) {
memset(tmp, 0, sizeof(struct ast_context));
- ast_pthread_mutex_init(&tmp->lock);
+ ast_mutex_init(&tmp->lock);
strncpy(tmp->name, name, sizeof(tmp->name)-1);
tmp->root = NULL;
tmp->registrar = registrar;
ast_log(LOG_WARNING, "Out of memory\n");
if (!extcontexts)
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return tmp;
}
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, char *registrar) {
struct ast_context *tmp, *lasttmp = NULL;
tmp = *extcontexts;
- ast_pthread_mutex_lock(&conlock);
+ ast_mutex_lock(&conlock);
if (registrar) {
__ast_context_destroy(NULL,registrar,0);
while (tmp) {
*extcontexts = NULL;
} else
ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return;
}
new_include->registrar = registrar;
/* ... try to lock this context ... */
- if (ast_pthread_mutex_lock(&con->lock)) {
+ if (ast_mutex_lock(&con->lock)) {
free(new_include);
errno = EBUSY;
return -1;
while (i) {
if (!strcasecmp(i->name, new_include->name)) {
free(new_include);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
errno = EEXIST;
return -1;
}
con->includes = new_include;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con));
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
}
new_sw->registrar = registrar;
/* ... try to lock this context ... */
- if (ast_pthread_mutex_lock(&con->lock)) {
+ if (ast_mutex_lock(&con->lock)) {
free(new_sw);
errno = EBUSY;
return -1;
while (i) {
if (!strcasecmp(i->name, new_sw->name)) {
free(new_sw);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
errno = EEXIST;
return -1;
}
con->alts = new_sw;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con));
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
}
{
struct ast_ignorepat *ip, *ipl = NULL;
- if (ast_pthread_mutex_lock(&con->lock)) {
+ if (ast_mutex_lock(&con->lock)) {
errno = EBUSY;
return -1;
}
con->ignorepats = ip->next;
free(ip);
}
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
}
ipl = ip; ip = ip->next;
}
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
errno = EINVAL;
return -1;
}
strncpy(ignorepat->pattern, value, sizeof(ignorepat->pattern)-1);
ignorepat->next = NULL;
ignorepat->registrar = registrar;
- ast_pthread_mutex_lock(&con->lock);
+ ast_mutex_lock(&con->lock);
ignorepatc = con->ignorepats;
while(ignorepatc) {
ignorepatl = ignorepatc;
if (!strcasecmp(ignorepatc->pattern, value)) {
/* Already there */
- pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
errno = EEXIST;
return -1;
}
ignorepatl->next = ignorepat;
else
con->ignorepats = ignorepat;
- pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
return 0;
}
{
int res = 0;
if (needlock)
- ast_pthread_mutex_lock(&chan->lock);
+ ast_mutex_lock(&chan->lock);
if (chan->pbx) {
/* This channel is currently in the PBX */
if (context && strlen(context))
chan->priority = priority - 1;
ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
if (needlock)
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
} else {
/* In order to do it when the channel doesn't really exist within
the PBX, we have to make a new channel, masquerade, and start the PBX
else
tmpchan->priority = chan->priority;
if (needlock)
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
/* Masquerade into temp channel */
ast_channel_masquerade(tmpchan, chan);
} else {
res = -1;
if (needlock)
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
}
}
return res;
errno = ENOMEM;
return -1;
}
- if (ast_pthread_mutex_lock(&con->lock)) {
+ if (ast_mutex_lock(&con->lock)) {
free(tmp);
/* And properly destroy the data */
datad(data);
/* Destroy the old one */
e->datad(e->data);
free(e);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
if (tmp->priority == PRIORITY_HINT)
ast_change_hint(e, tmp);
/* And immediately return success. */
ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
tmp->datad(tmp->data);
free(tmp);
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
errno = EEXIST;
return -1;
}
tmp->peer = con->root->peer;
con->root = tmp;
}
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
/* And immediately return success. */
if (tmp->priority == PRIORITY_HINT)
ast_add_hint(tmp);
/* If we make it here, then it's time for us to go at the very end.
ep *must* be defined or we couldn't have gotten here. */
ep->peer = tmp;
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
if (tmp->priority == PRIORITY_HINT)
ast_add_hint(tmp);
/* We're at the top of the list */
con->root = tmp;
}
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
if (tmp->priority == PRIORITY_HINT)
ast_add_hint(tmp);
el->next = tmp;
else
con->root = tmp;
- ast_pthread_mutex_unlock(&con->lock);
+ ast_mutex_unlock(&con->lock);
if (tmp->priority == PRIORITY_HINT)
ast_add_hint(tmp);
LOG;
struct ast_sw *sw, *swl= NULL;
struct ast_exten *e, *el, *en;
if (lock)
- ast_pthread_mutex_lock(&conlock);
+ ast_mutex_lock(&conlock);
tmp = contexts;
while(tmp) {
if (((tmp->name && con && con->name && !strcasecmp(tmp->name, con->name)) || !con) &&
(!registrar || !strcasecmp(registrar, tmp->registrar))) {
/* Okay, let's lock the structure to be sure nobody else
is searching through it. */
- if (ast_pthread_mutex_lock(&tmp->lock)) {
+ if (ast_mutex_lock(&tmp->lock)) {
ast_log(LOG_WARNING, "Unable to lock context lock\n");
return;
}
contexts = tmp->next;
/* Okay, now we're safe to let it go -- in a sense, we were
ready to let it go as soon as we locked it. */
- ast_pthread_mutex_unlock(&tmp->lock);
+ ast_mutex_unlock(&tmp->lock);
for (tmpi = tmp->includes; tmpi; ) {
/* Free includes */
tmpil = tmpi;
continue;
}
if (lock)
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
return;
}
tmpl = tmp;
tmp = tmp->next;
}
if (lock)
- ast_pthread_mutex_unlock(&conlock);
+ ast_mutex_unlock(&conlock);
}
void ast_context_destroy(struct ast_context *con, char *registrar)
*/
int ast_lock_contexts()
{
- return ast_pthread_mutex_lock(&conlock);
+ return ast_mutex_lock(&conlock);
}
int ast_unlock_contexts()
{
- return ast_pthread_mutex_unlock(&conlock);
+ return ast_mutex_unlock(&conlock);
}
/*
*/
int ast_lock_context(struct ast_context *con)
{
- return ast_pthread_mutex_lock(&con->lock);
+ return ast_mutex_lock(&con->lock);
}
int ast_unlock_context(struct ast_context *con)
{
- return ast_pthread_mutex_unlock(&con->lock);
+ return ast_mutex_unlock(&con->lock);
}
/*
static int static_config = 0;
static int write_protect_config = 1;
-static pthread_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER;
static struct ast_context *local_contexts = NULL;
if (argc != 2 && argc != 3) return RESULT_SHOWUSAGE;
- if (ast_pthread_mutex_lock(&save_dialplan_lock)) {
+ if (ast_mutex_lock(&save_dialplan_lock)) {
ast_cli(fd,
"Failed to lock dialplan saving (another proccess saving?)\n");
return RESULT_FAILURE;
/* try to lock contexts list */
if (ast_lock_contexts()) {
ast_cli(fd, "Failed to lock contexts list\n");
- ast_pthread_mutex_unlock(&save_dialplan_lock);
+ ast_mutex_unlock(&save_dialplan_lock);
return RESULT_FAILURE;
}
ast_cli(fd, "Failed to create file '%s'\n",
filename);
ast_unlock_contexts();
- ast_pthread_mutex_unlock(&save_dialplan_lock);
+ ast_mutex_unlock(&save_dialplan_lock);
return RESULT_FAILURE;
}
}
ast_unlock_contexts();
- ast_pthread_mutex_unlock(&save_dialplan_lock);
+ ast_mutex_unlock(&save_dialplan_lock);
fclose(output);
if (incomplete) {
#include "../asterisk.h"
#include "../astconf.h"
-static pthread_mutex_t verb_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t verb_lock = AST_MUTEX_INITIALIZER;
static pthread_t console_thread;
static void verboser(char *stuff, int opos, int replacelast, int complete)
{
- ast_pthread_mutex_lock(&verb_lock);
+ ast_mutex_lock(&verb_lock);
/* Lock appropriately if we're really being called in verbose mode */
__verboser(stuff, opos, replacelast, complete);
- ast_pthread_mutex_unlock(&verb_lock);
+ ast_mutex_unlock(&verb_lock);
}
static void cliinput(void *data, int source, GdkInputCondition ic)
static char base64[64];
static char b2a[256];
-static pthread_mutex_t keylock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t keylock = AST_MUTEX_INITIALIZER;
#define KEY_NEEDS_PASSCODE (1 << 16)
struct ast_key *ast_key_get(char *kname, int ktype)
{
struct ast_key *key;
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
key = keys;
while(key) {
if (!strcmp(kname, key->name) &&
break;
key = key->next;
}
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
return key;
}
/* Get actual filename */
snprintf(ffname, sizeof(ffname), "%s/%s", dir, fname);
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
key = keys;
while(key) {
/* Look for an existing version already */
break;
key = key->next;
}
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
/* Open file */
f = fopen(ffname, "r");
fill it with what we know */
/* Gotta lock if this one already exists */
if (found)
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
/* First the filename */
strncpy(key->fn, ffname, sizeof(key->fn));
/* Then the name */
*not2 = 1;
}
if (found)
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
if (!found) {
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
key->next = keys;
keys = key;
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
}
return key;
}
struct dirent *ent;
int note = 0;
/* Mark all keys for deletion */
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
key = keys;
while(key) {
key->delme = 1;
key = key->next;
}
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
/* Load new keys */
dir = opendir((char *)ast_config_AST_KEY_DIR);
if (dir) {
if (note) {
ast_log(LOG_NOTICE, "Please run the command 'init keys' to enter the passcodes for the keys\n");
}
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
key = keys;
last = NULL;
while(key) {
last = key;
key = nkey;
}
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
}
static void md52sum(char *sum, unsigned char *md5)
struct ast_key *key;
char sum[16 * 2 + 1];
- ast_pthread_mutex_lock(&keylock);
+ ast_mutex_lock(&keylock);
key = keys;
ast_cli(fd, "%-18s %-8s %-16s %-33s\n", "Key Name", "Type", "Status", "Sum");
while(key) {
key = key->next;
}
- ast_pthread_mutex_unlock(&keylock);
+ ast_mutex_unlock(&keylock);
return RESULT_SUCCESS;
}
char buf[256];
int found_country = 0;
- if (ast_pthread_mutex_lock(&tzlock)) {
+ if (ast_mutex_lock(&tzlock)) {
ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return 0;
}
for (tz=tone_zones; tz; tz=tz->next) {
ast_cli(fd,"%-7.7s %-7.7s %s\n", tz->country, tz->alias, tz->description);
}
- ast_pthread_mutex_unlock(&tzlock);
+ ast_mutex_unlock(&tzlock);
return 0;
}
/* there was a request for specific country(ies), lets humor them */
}
if (!found_country)
ast_cli(fd,"No countries matched your criteria.\n");
- ast_pthread_mutex_unlock(&tzlock);
+ ast_mutex_unlock(&tzlock);
return -1;
}
#define AST_MONITOR_DIR INSTALL_PREFIX "/var/spool/asterisk/monitor"
-static pthread_mutex_t monitorlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t monitorlock = AST_MUTEX_INITIALIZER;
static unsigned long seq = 0;
int res = 0;
if( need_lock ) {
- if (ast_pthread_mutex_lock(&chan->lock)) {
+ if (ast_mutex_lock(&chan->lock)) {
ast_log(LOG_WARNING, "Unable to lock channel\n");
return -1;
}
AST_MONITOR_DIR, fname_base );
*monitor->filename_base = 0;
} else {
- ast_pthread_mutex_lock( &monitorlock );
+ ast_mutex_lock( &monitorlock );
snprintf( monitor->read_filename, FILENAME_MAX, "%s/audio-in-%ld",
AST_MONITOR_DIR, seq );
snprintf( monitor->write_filename, FILENAME_MAX, "%s/audio-out-%ld",
AST_MONITOR_DIR, seq );
seq++;
- ast_pthread_mutex_unlock( &monitorlock );
+ ast_mutex_unlock( &monitorlock );
channel_name = strdup( chan->name );
while( ( p = strchr( channel_name, '/' ) ) ) {
ast_log( LOG_WARNING, "Could not create file %s\n",
monitor->read_filename );
free( monitor );
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
return -1;
}
if( ast_fileexists( monitor->write_filename, NULL, NULL ) > 0 ) {
monitor->write_filename );
ast_closestream( monitor->read_stream );
free( monitor );
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
return -1;
}
chan->monitor = monitor;
}
if( need_lock ) {
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
}
return res;
}
int ast_monitor_stop( struct ast_channel *chan, int need_lock )
{
if(need_lock) {
- if(ast_pthread_mutex_lock(&chan->lock)) {
+ if(ast_mutex_lock(&chan->lock)) {
ast_log(LOG_WARNING, "Unable to lock channel\n");
return -1;
}
}
if( need_lock ) {
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
}
return 0;
}
}
if( need_lock ) {
- if (ast_pthread_mutex_lock(&chan->lock)) {
+ if (ast_mutex_lock(&chan->lock)) {
ast_log(LOG_WARNING, "Unable to lock channel\n");
return -1;
}
}
if( need_lock ) {
- ast_pthread_mutex_unlock(&chan->lock);
+ ast_mutex_unlock(&chan->lock);
}
return 0;
}
static struct mohclass *mohclasses;
-static pthread_mutex_t moh_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t moh_lock = AST_MUTEX_INITIALIZER;
#define MPG_123 "/usr/bin/mpg123"
#define MAX_MP3S 256
ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, res * 2);
continue;
}
- ast_pthread_mutex_lock(&moh_lock);
+ ast_mutex_lock(&moh_lock);
moh = class->members;
while(moh) {
/* Write data */
ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
moh = moh->next;
}
- pthread_mutex_unlock(&moh_lock);
+ ast_mutex_unlock(&moh_lock);
}
return NULL;
}
{
struct mohdata *moh = data, *prev, *cur;
int oldwfmt;
- ast_pthread_mutex_lock(&moh_lock);
+ ast_mutex_lock(&moh_lock);
/* Unlink */
prev = NULL;
cur = moh->parent->members;
prev = cur;
cur = cur->next;
}
- ast_pthread_mutex_unlock(&moh_lock);
+ ast_mutex_unlock(&moh_lock);
close(moh->pipe[0]);
close(moh->pipe[1]);
oldwfmt = moh->origwfmt;
{
struct mohdata *res;
struct mohclass *class;
- ast_pthread_mutex_lock(&moh_lock);
+ ast_mutex_lock(&moh_lock);
class = get_mohbyname(params);
if (class)
res = mohalloc(class);
ast_log(LOG_WARNING, "No class: %s\n", (char *)params);
res = NULL;
}
- ast_pthread_mutex_unlock(&moh_lock);
+ ast_mutex_unlock(&moh_lock);
if (res) {
res->origwfmt = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
{
struct mohclass *moh;
int x;
- ast_pthread_mutex_lock(&moh_lock);
+ ast_mutex_lock(&moh_lock);
moh = get_mohbyname(classname);
- ast_pthread_mutex_unlock(&moh_lock);
+ ast_mutex_unlock(&moh_lock);
if (moh) {
ast_log(LOG_WARNING, "Music on Hold '%s' already exists\n", classname);
return -1;
free(moh);
return -1;
}
- ast_pthread_mutex_lock(&moh_lock);
+ ast_mutex_lock(&moh_lock);
moh->next = mohclasses;
mohclasses = moh;
- ast_pthread_mutex_unlock(&moh_lock);
+ ast_mutex_unlock(&moh_lock);
return 0;
}
{
struct mohclass *moh;
char buff[8192];
- int bytes, tbytes, stime = 0;
+ int bytes, tbytes=0, stime = 0;
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Destroying any remaining musiconhold processes\n");
- ast_pthread_mutex_lock(&moh_lock);
+ ast_mutex_lock(&moh_lock);
moh = mohclasses;
while(moh) {
if (moh->pid) {
ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
stime = time(NULL);
kill(moh->pid, SIGABRT);
- while (bytes = read(moh->srcfd, buff, 8192) && time(NULL) < stime + 5) {
+ while ((bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime + 5) {
tbytes = tbytes + bytes;
}
ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", moh->pid, tbytes);
}
moh = moh->next;
}
- ast_pthread_mutex_unlock(&moh_lock);
+ ast_mutex_unlock(&moh_lock);
}
int load_module(void)
static struct parkeduser *parkinglot;
-static pthread_mutex_t parking_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t parking_lock = AST_MUTEX_INITIALIZER;
static pthread_t parking_thread;
int x;
pu = malloc(sizeof(struct parkeduser));
if (pu) {
- ast_pthread_mutex_lock(&parking_lock);
+ ast_mutex_lock(&parking_lock);
for (x=parking_start;x<=parking_stop;x++) {
cur = parkinglot;
while(cur) {
pu->priority = chan->priority;
pu->next = parkinglot;
parkinglot = pu;
- ast_pthread_mutex_unlock(&parking_lock);
+ ast_mutex_unlock(&parking_lock);
/* Wake up the (presumably select()ing) thread */
pthread_kill(parking_thread, SIGURG);
if (option_verbose > 1)
} else {
ast_log(LOG_WARNING, "No more parking spaces\n");
free(pu);
- ast_pthread_mutex_unlock(&parking_lock);
+ ast_mutex_unlock(&parking_lock);
return -1;
}
} else {
for (;;) {
ms = -1;
max = -1;
- ast_pthread_mutex_lock(&parking_lock);
+ ast_mutex_lock(&parking_lock);
pl = NULL;
pu = parkinglot;
gettimeofday(&tv, NULL);
}
}
}
- ast_pthread_mutex_unlock(&parking_lock);
+ ast_mutex_unlock(&parking_lock);
rfds = nrfds;
efds = nefds;
tv.tv_sec = ms / 1000;
}
LOCAL_USER_ADD(u);
park = atoi((char *)data);
- ast_pthread_mutex_lock(&parking_lock);
+ ast_mutex_lock(&parking_lock);
pu = parkinglot;
while(pu) {
if (pu->parkingnum == park) {
pl = pu;
pu = pu->next;
}
- ast_pthread_mutex_unlock(&parking_lock);
+ ast_mutex_unlock(&parking_lock);
if (pu) {
peer = pu->chan;
free(pu);
ast_cli(fd, "%4s %25s (%-15s %-12s %-4s) %-6s \n", "Num", "Channel"
, "Context", "Extension", "Pri", "Timeout");
- ast_pthread_mutex_lock(&parking_lock);
+ ast_mutex_lock(&parking_lock);
cur=parkinglot;
while(cur) {
cur = cur->next;
}
- ast_pthread_mutex_unlock(&parking_lock);
+ ast_mutex_unlock(&parking_lock);
return RESULT_SUCCESS;
}
/* if need DTMF, cant native bridge */
if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))
return -2;
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
pr0 = get_proto(c0);
pr1 = get_proto(c1);
if (!pr0) {
ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
return -1;
}
if (!pr1) {
ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
return -1;
}
pvt0 = c0->pvt->pvt;
vp1 = NULL;
if (!p0 || !p1) {
/* Somebody doesn't want to play... */
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
return -2;
}
if (pr0->set_rtp_peer(c0, p1, vp1))
if (vp0)
ast_rtp_get_peer(p0, &vac0);
}
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
cs[0] = c0;
cs[1] = c1;
cs[2] = NULL;
/* This could all be done more efficiently *IF* we chained packets together
by default, but it would also complicate virtually every application. */
-static pthread_mutex_t list_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t list_lock = AST_MUTEX_INITIALIZER;
static struct ast_translator *list = NULL;
struct ast_translator_dir {
return RESULT_SHOWUSAGE;
ast_cli(fd, " Translation times between formats (in milliseconds)\n");
ast_cli(fd, " Destination Format\n");
- ast_pthread_mutex_lock(&list_lock);
+ ast_mutex_lock(&list_lock);
for (x=0;x<SHOW_TRANS; x++) {
if (x == 1)
strcpy(line, " Src ");
snprintf(line + strlen(line), sizeof(line) - strlen(line), "\n");
ast_cli(fd, line);
}
- ast_pthread_mutex_unlock(&list_lock);
+ ast_mutex_unlock(&list_lock);
return RESULT_SUCCESS;
}
calc_cost(t);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %d to %d, cost %d\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), t->srcfmt, t->dstfmt, t->cost);
- ast_pthread_mutex_lock(&list_lock);
+ ast_mutex_lock(&list_lock);
if (!added_cli) {
ast_cli_register(&show_trans);
added_cli++;
t->next = list;
list = t;
rebuild_matrix();
- ast_pthread_mutex_unlock(&list_lock);
+ ast_mutex_unlock(&list_lock);
return 0;
}
int ast_unregister_translator(struct ast_translator *t)
{
struct ast_translator *u, *ul = NULL;
- ast_pthread_mutex_lock(&list_lock);
+ ast_mutex_lock(&list_lock);
u = list;
while(u) {
if (u == t) {
u = u->next;
}
rebuild_matrix();
- ast_pthread_mutex_unlock(&list_lock);
+ ast_mutex_unlock(&list_lock);
return (u ? 0 : -1);
}
int bestdst=0;
int cur = 1;
int besttime=999999999;
- ast_pthread_mutex_lock(&list_lock);
+ ast_mutex_lock(&list_lock);
for (y=0;y<MAX_FORMAT;y++) {
if ((cur & *dst) && (cur & *srcs)) {
/* This is a common format to both. Pick it if we don't have one already */
*dst = bestdst;
best = 0;
}
- ast_pthread_mutex_unlock(&list_lock);
+ ast_mutex_unlock(&list_lock);
return best;
}