return -1;
}
ast_mutex_lock(&iaxsl[callno]);
- if (!iaxs[callno])
+ if (!iaxs[callno]) {
+ if (ast_test_flag(p, IAX_TEMPONLY))
+ destroy_peer(p);
return -1;
+ }
if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS))) {
if (sin->sin_addr.s_addr) {
}
/* Make sure our call still exists, an INVAL at the right point may make it go away */
- if (!iaxs[callno])
+ if (!iaxs[callno]) {
+ if (ast_test_flag(p, IAX_TEMPONLY))
+ destroy_peer(p);
return 0;
+ }
/* Store socket fd */
p->sockfd = fd;
ast_mutex_unlock(&iaxsl[callno]);
p = find_peer(peer_name, 1);
ast_mutex_lock(&iaxsl[callno]);
- if (!iaxs[callno])
+ if (!iaxs[callno]) {
+ if (p && ast_test_flag(p, IAX_TEMPONLY))
+ destroy_peer(p);
return -1;
+ }
if (p) {
memset(&ied, 0, sizeof(ied));
iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods);
}
}
+ if (ast_test_flag(peer, IAX_TEMPONLY))
+ destroy_peer(peer);
+
return 0;
}