Index: channels/chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.15
diff -u -r1.15 chan_sip.c
--- channels/chan_sip.c	28 Mar 2003 06:59:34 -0000	1.15
+++ channels/chan_sip.c	29 Sep 2003 22:05:25 -0000
@@ -342,7 +342,7 @@
 {
 	struct sip_pkt *pkt=data;
 	int res = 0;
-	ast_pthread_mutex_lock(&pkt->owner->lock);
+	ast_mutex_lock(&pkt->owner->lock);
 	if (pkt->retrans < MAX_RETRANS) {
 		pkt->retrans++;
 		if (sipdebug) {
@@ -364,7 +364,7 @@
 			sip_destroy(pkt->owner);
 		}
 	}
-	ast_pthread_mutex_unlock(&pkt->owner->lock);
+	ast_mutex_unlock(&pkt->owner->lock);
 	return res;
 }
 
@@ -509,7 +509,7 @@
 	struct sip_peer *p;
 	int found=0;
 	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)) {
@@ -549,7 +549,7 @@
 		}
 		p = p->next;
 	}
-	ast_pthread_mutex_unlock(&peerl.lock);
+	ast_mutex_unlock(&peerl.lock);
 	if (!p && !found) {
 		hp = gethostbyname(peer);
 		if (hp) {
@@ -570,16 +570,16 @@
 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)) {
 			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;
 }
 
@@ -692,11 +692,11 @@
 	/* 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) {
@@ -726,9 +726,9 @@
 }
 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);
 }
 
 /* Interface lookup code courtesy Tilghman of DrunkCoder.com.  Thanks! */
@@ -838,11 +838,11 @@
 		ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
 		return 0;
 	}
-	ast_pthread_mutex_lock(&p->lock);
+	ast_mutex_lock(&p->lock);
 	/* 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))
@@ -865,7 +865,7 @@
 			transmit_request(p, "BYE", 1, 1);
 		}
 	}
-	ast_pthread_mutex_unlock(&p->lock);
+	ast_mutex_unlock(&p->lock);
 	return 0;
 }
 
@@ -916,7 +916,7 @@
 		}
 	}
 	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);
@@ -924,7 +924,7 @@
 			}
 			res =  ast_rtp_write(p->rtp, frame);
 		}
-		ast_pthread_mutex_unlock(&p->lock);
+		ast_mutex_unlock(&p->lock);
 	}
 	return res;
 }
@@ -932,14 +932,14 @@
 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;
 }
 
@@ -1040,9 +1040,9 @@
 		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);
@@ -1173,9 +1173,9 @@
 {
 	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(p);
-	ast_pthread_mutex_unlock(&p->lock);
+	ast_mutex_unlock(&p->lock);
 	return fr;
 }
 
@@ -1205,7 +1205,7 @@
 	memset(p, 0, sizeof(struct sip_pvt));
 	p->initid = -1;
 	p->autokillid = -1;
-	p->rtp = ast_rtp_new(NULL, NULL);
+	p->rtp = ast_rtp_new(NULL, NULL, 0, 0);
 	p->branch = rand();	
 	p->tag = rand();
 	/* Start with 101 instead of 1 */
@@ -1222,7 +1222,7 @@
 		memcpy(&p->recv, sin, sizeof(p->recv));
 		ast_rtp_setnat(p->rtp, p->nat);
 	}
-	ast_pthread_mutex_init(&p->lock);
+	ast_mutex_init(&p->lock);
 #if 0
 	ast_rtp_set_data(p->rtp, p);
 	ast_rtp_set_callback(p->rtp, rtpready);
@@ -1244,10 +1244,10 @@
 	if (p->dtmfmode & SIP_DTMF_RFC2833)
 		p->noncodeccapability |= AST_RTP_DTMF;
 	/* 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;
@@ -1262,7 +1262,7 @@
 		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)) {
@@ -1275,16 +1275,16 @@
 					snprintf(orig, sizeof(orig), "%s:%d", inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port));
 					snprintf(new, sizeof(new), "%s:%d", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
 					ast_log(LOG_WARNING, "Looks like %s is trying to steal call '%s' from %s?\n", new, p->callid, orig);
-					ast_pthread_mutex_unlock(&iflock);
+					ast_mutex_unlock(&iflock);
 					return NULL;
 			}
 #endif
-			ast_pthread_mutex_unlock(&iflock);
+			ast_mutex_unlock(&iflock);
 			return p;
 		}
 		p = p->next;
 	}
-	ast_pthread_mutex_unlock(&iflock);
+	ast_mutex_unlock(&iflock);
 	return sip_alloc(callid, sin, 1);
 }
 
@@ -2139,9 +2139,9 @@
 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;
 }
 
@@ -2150,13 +2150,13 @@
 	/* if we are here, our registration timed out, so we'll just do it over */
 	struct sip_registry *r=data;
 	int res;
-	ast_pthread_mutex_lock(&r->lock);
+	ast_mutex_lock(&r->lock);
 	ast_log(LOG_NOTICE, "Registration timed out, trying again\n"); 
 	r->regstate=REG_STATE_UNREGISTERED;
 	/* cancel ourselves first!!! */
 	/* ast_sched_del(sched,r->timeout); */
 	res=transmit_register(r, "REGISTER", NULL);
-	ast_pthread_mutex_unlock(&r->lock);
+	ast_mutex_unlock(&r->lock);
 	return res;
 }
 
@@ -2484,7 +2484,7 @@
 	c = strchr(name, '@');
 	if (c) 
 		*c = '\0';
-	ast_pthread_mutex_lock(&peerl.lock);
+	ast_mutex_lock(&peerl.lock);
 	peer = peerl.peers;
 	while(peer) {
 		if (!strcasecmp(peer->name, name) && peer->dynamic) {
@@ -2504,7 +2504,7 @@
 		}	
 		peer = peer->next;
 	}
-	ast_pthread_mutex_unlock(&peerl.lock);
+	ast_mutex_unlock(&peerl.lock);
 	if (res < 0)
 		transmit_response(p, "401 Unauthorized", &p->initreq);
 	return res;
@@ -2617,19 +2617,19 @@
 		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
@@ -2726,7 +2726,7 @@
 	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)) {
@@ -2755,10 +2755,10 @@
 		}
 		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 (!memcmp(&peer->addr, &p->recv, sizeof(peer->addr))) {
@@ -2781,7 +2781,7 @@
 			}
 			peer = peer->next;
 		}
-		ast_pthread_mutex_unlock(&peerl.lock);
+		ast_mutex_unlock(&peerl.lock);
 	}
 	return res;
 }
@@ -2824,14 +2824,14 @@
 	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
 }
@@ -2844,7 +2844,7 @@
 	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] = "";
@@ -2871,7 +2871,7 @@
 					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
@@ -2907,14 +2907,14 @@
 	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
@@ -2928,7 +2928,7 @@
 	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", "Username", "Call ID", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
 	while (cur) {
@@ -2942,7 +2942,7 @@
 		cur = cur->next;
 		numchans++;
 	}
-	ast_pthread_mutex_unlock(&iflock);
+	ast_mutex_unlock(&iflock);
 	ast_cli(fd, "%d active SIP channel(s)\n", numchans);
 	return RESULT_SUCCESS;
 #undef FORMAT
@@ -2954,7 +2954,7 @@
 	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))) {
@@ -2965,7 +2965,7 @@
 		}
 		cur = cur->next;
 	}
-	ast_pthread_mutex_unlock(&iflock);
+	ast_mutex_unlock(&iflock);
 	return c;
 }
 
@@ -2975,7 +2975,7 @@
 	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])) {
@@ -2997,7 +2997,7 @@
 		}
 		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;
@@ -3205,11 +3205,11 @@
 	msg = strchr(c, ' ');
 	if (!msg) msg = ""; else msg++;
 retrylock:
-	ast_pthread_mutex_lock(&p->lock);
+	ast_mutex_lock(&p->lock);
 	/* Go ahead and lock the owner if it has one -- we may need it */
 	if (p->owner && pthread_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);
 		goto retrylock;
@@ -3396,9 +3396,9 @@
 		}
 	}
 	if (owner)
-		ast_pthread_mutex_unlock(&owner->lock);
+		ast_mutex_unlock(&owner->lock);
 	if (p)
-		ast_pthread_mutex_unlock(&p->lock);
+		ast_mutex_unlock(&p->lock);
 }
 
 static int determine_firstline_parts( struct sip_request *req ) {
@@ -3675,7 +3675,7 @@
 			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");
@@ -3772,13 +3772,13 @@
 		return 1;
 	}
 	/* Process request, with netlock held */
-	ast_pthread_mutex_lock(&netlock);
+	ast_mutex_lock(&netlock);
 	p = find_call(&req, &sin);
 	if (p) {
 		memcpy(&p->recv, &sin, sizeof(p->recv));
 		handle_request(p, &req, &sin);
 	}
-	ast_pthread_mutex_unlock(&netlock);
+	ast_mutex_unlock(&netlock);
 	return 1;
 }
 
@@ -3795,19 +3795,19 @@
 	
 	/* 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, peer->name)) {
 		/* Maybe they're not registered, etc. */
 		sip_destroy(p);
@@ -3839,7 +3839,7 @@
 	/* 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) {
@@ -3849,26 +3849,26 @@
 			}
 			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 ((res < 0) || (res > 1000))
 			res = 1000;
 		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);
 		while(peer) {
@@ -3880,8 +3880,8 @@
 		}
 		/* Remember, sip_send_mwi_to_peer releases the lock if we've called it */
 		if (!peer)
-			ast_pthread_mutex_unlock(&peerl.lock);
-		ast_pthread_mutex_unlock(&monlock);
+			ast_mutex_unlock(&peerl.lock);
+		ast_mutex_unlock(&monlock);
 	}
 	/* Never reached */
 	return NULL;
@@ -3893,12 +3893,12 @@
 	/* 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;
 	}
@@ -3908,12 +3908,12 @@
 	} 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;
 }
 
@@ -4105,7 +4105,7 @@
 	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)) {	
@@ -4122,9 +4122,9 @@
 		} 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;
@@ -4370,19 +4370,19 @@
 				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");
@@ -4502,14 +4502,14 @@
 			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();
 	}
@@ -4523,7 +4523,7 @@
 	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;
@@ -4531,7 +4531,7 @@
 		free(userlast);
 	}
 	userl.users=NULL;
-	ast_pthread_mutex_unlock(&userl.lock);
+	ast_mutex_unlock(&userl.lock);
 
 	for (reg = registrations;reg;) {
 		regl = reg;
@@ -4541,20 +4541,20 @@
 		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);
 }
 
 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;
@@ -4575,7 +4575,7 @@
 			peerlast = peer;
 		peer=peernext;
 	}
-	ast_pthread_mutex_unlock(&peerl.lock);
+	ast_mutex_unlock(&peerl.lock);
 }
 
 int reload(void)
@@ -4590,10 +4590,10 @@
 	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;
 }
 
@@ -4602,7 +4602,7 @@
 	struct sip_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) {
@@ -4611,25 +4611,25 @@
 			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) {
@@ -4639,7 +4639,7 @@
 			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;
@@ -4651,9 +4651,9 @@
 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;
 }
 
