Commit 7e6f11fd authored by Pekka Pessi's avatar Pekka Pessi

Merge branch 'updates'

parents cdd19851 0c7b4ed4
......@@ -7121,6 +7121,7 @@ static int outgoing_try_another(nta_outgoing_t *orq);
#else
#define outgoing_other_destinations(orq) (0)
#define outgoing_try_another(orq) (0)
#define outgoing_cancel_resolver(orq) ((void)0)
#endif
/** Create a default outgoing transaction.
......@@ -8886,6 +8887,8 @@ outgoing_complete(nta_outgoing_t *orq)
return outgoing_terminate(orq);
}
outgoing_cancel_resolver(orq);
if (orq->orq_method == sip_method_invite) {
if (orq->orq_queue != orq->orq_agent->sa_out.inv_completed)
outgoing_queue(orq->orq_agent->sa_out.inv_completed, orq); /* Timer D */
......@@ -8989,6 +8992,8 @@ int outgoing_terminate(nta_outgoing_t *orq)
{
orq->orq_terminated = 1;
outgoing_cancel_resolver(orq);
if (!orq->orq_destroyed) {
outgoing_queue(orq->orq_agent->sa_out.terminated, orq);
return 0;
......@@ -9155,7 +9160,8 @@ int outgoing_recv(nta_outgoing_t *_orq,
if (status < 200) {
outgoing_send(cancel, 0);
outgoing_complete(orq);
if (outgoing_complete(orq))
return 0;
}
else {
outgoing_reply(cancel, SIP_481_NO_TRANSACTION, 0);
......@@ -9265,15 +9271,23 @@ int outgoing_recv(nta_outgoing_t *_orq,
*/
if (!orq->orq_reliable)
orq->orq_interval = sa->sa_t2;
#if notyet /* Destination has been already flushed */
if (orq->orq_queue == sa->sa_out.resolving) {
/* A response from (previously resolved) destination? */
outgoing_cancel_resolver(orq);
outgoing_trying(orq);
}
#endif
}
else if (!outgoing_complete(orq)) {
else if (outgoing_complete(orq)) {
msg_destroy(msg); /* Transaction was terminated and destroyed */
return 0;
}
else {
if (orq->orq_sigcomp_zap && orq->orq_tport && orq->orq_cc)
agent_zap_compressor(orq->orq_agent, orq->orq_cc);
}
else /* outgoing_complete */ {
msg_destroy(msg);
return 0;
}
}
else {
/* Already completed or terminated */
......@@ -9892,6 +9906,9 @@ outgoing_resolve_next(nta_outgoing_t *orq)
{
struct sipdns_resolver *sr = orq->orq_resolver;
if (orq->orq_completed)
return 0;
if (sr == NULL) {
outgoing_resolving_error(orq, SIP_500_INTERNAL_SERVER_ERROR);
return 0;
......@@ -9940,7 +9957,12 @@ outgoing_resolve_next(nta_outgoing_t *orq)
static int
outgoing_other_destinations(nta_outgoing_t const *orq)
{
struct sipdns_resolver *sr = orq->orq_resolver;
struct sipdns_resolver *sr;
if (orq->orq_completed)
return 0;
sr = orq->orq_resolver;
if (!sr)
return 0;
......@@ -10049,9 +10071,7 @@ su_inline void outgoing_cancel_resolver(nta_outgoing_t *orq)
{
struct sipdns_resolver *sr = orq->orq_resolver;
assert(orq->orq_resolver);
if (sr->sr_query) /* Cancel resolver query */
if (sr && sr->sr_query) /* Cancel resolver query */
sres_query_bind(sr->sr_query, NULL, NULL), sr->sr_query = NULL;
}
......@@ -10722,6 +10742,9 @@ outgoing_query_results(nta_outgoing_t *orq,
else
sr->sr_current = NULL;
if (orq->orq_completed)
return;
if (rlen > 0) {
orq->orq_resolved = 1;
orq->orq_tpn->tpn_host = results[0];
......
......@@ -1508,21 +1508,27 @@ static int soa_static_process_reject(soa_session_t *ss,
{
soa_static_session_t *sss = (soa_static_session_t *)ss;
struct soa_description d[1];
int *u2s, *s2u;
soa_base_process_reject(ss, NULL);
*d = *ss->ss_local;
u2s = sss->sss_u2s, s2u = sss->sss_s2u;
*ss->ss_local = *ss->ss_previous;
ss->ss_local_user_version = ss->ss_previous_user_version;
ss->ss_local_remote_version = ss->ss_previous_remote_version;
sss->sss_u2s = sss->sss_previous.u2s;
sss->sss_s2u = sss->sss_previous.s2u;
memset(ss->ss_previous, 0, (sizeof *ss->ss_previous));
memset(&sss->sss_previous, 0, (sizeof sss->sss_previous));
soa_description_free(ss, d);
su_free(ss->ss_home, sss->sss_previous.u2s), sss->sss_previous.u2s = NULL;
su_free(ss->ss_home, sss->sss_previous.s2u), sss->sss_previous.s2u = NULL;
ss->ss_previous_user_version = 0;
ss->ss_previous_remote_version = 0;
su_free(ss->ss_home, u2s);
su_free(ss->ss_home, s2u);
su_free(ss->ss_home, sss->sss_latest), sss->sss_latest = NULL;
return 0;
......
......@@ -1945,6 +1945,13 @@ int test_large_sessions(struct context *ctx)
n = soa_generate_offer(a, 1, test_completed); TEST(n, 0);
n = soa_get_local_sdp(a, NULL, &offer, &offerlen); TEST(n, 1);
TEST_1(offer != NULL && offer != NONE);
soa_process_reject(a, test_completed);
n = soa_generate_offer(a, 1, test_completed); TEST(n, 0);
n = soa_get_local_sdp(a, NULL, &offer, &offerlen); TEST(n, 1);
TEST_1(offer != NULL && offer != NONE);
/* printf("offer1: %s\n", offer); */
n = soa_set_remote_sdp(b, 0, offer, offerlen); TEST(n, 1);
n = soa_get_local_sdp(b, NULL, &answer, &answerlen); TEST(n, 0);
......
......@@ -608,47 +608,50 @@ int stun_free_message(stun_msg_t *msg) {
return 0;
}
void stun_free_message_data(stun_msg_t *msg)
{
stun_attr_t *a, *next;
free(msg->enc_buf.data), msg->enc_buf.data = NULL;
msg->enc_buf.size = 0;
for (a = msg->stun_attr; a; a = next) {
next = a->next, a->next = NULL;
if (a->pattr)
free(a->pattr), a->pattr = NULL;
if (a->enc_buf.data)
free(a->enc_buf.data), a->enc_buf.data = NULL;
free(a);
}
msg->stun_attr = NULL;
}
int stun_send_message(su_socket_t s, su_sockaddr_t *to_addr,
stun_msg_t *msg, stun_buffer_t *pwd)
{
int err;
char ipaddr[SU_ADDRSIZE + 2];
stun_attr_t **a, *b;
stun_encode_message(msg, pwd);
err = su_sendto(s, msg->enc_buf.data, msg->enc_buf.size, 0,
to_addr, SU_SOCKADDR_SIZE(to_addr));
free(msg->enc_buf.data), msg->enc_buf.data = NULL;
msg->enc_buf.size = 0;
for (a = &msg->stun_attr; *a;) {
if ((*a)->pattr)
free((*a)->pattr), (*a)->pattr = NULL;
if ((*a)->enc_buf.data)
free((*a)->enc_buf.data), (*a)->enc_buf.data = NULL;
b = *a;
b = b->next;
free(*a);
*a = NULL;
*a = b;
}
if (err > 0) {
su_inet_ntop(to_addr->su_family, SU_ADDR(to_addr), ipaddr, sizeof(ipaddr));
SU_DEBUG_5(("%s: message sent to %s:%u\n", __func__,
ipaddr, ntohs(to_addr->su_port)));
debug_print(&msg->enc_buf);
}
else
STUN_ERROR(errno, sendto);
stun_free_message_data(msg);
return err;
}
......
......@@ -98,6 +98,8 @@ int stun_make_sharedsecret_req(stun_msg_t *msg);
int stun_send_message(su_socket_t s, su_sockaddr_t *srvr,
stun_msg_t *msg, stun_buffer_t *pwd);
void stun_free_message_data(stun_msg_t *msg);
int stun_make_binding_req(stun_handle_t *se, stun_request_t *req,
stun_msg_t *msg,
tag_type_t, tag_value_t, ...);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment