Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
a6f3af18
Commit
a6f3af18
authored
May 06, 2013
by
Simon Morlat
Browse files
resolver callback must be called in case of error.
parent
4aa1a811
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/belle_sip_resolver.c
View file @
a6f3af18
...
...
@@ -104,6 +104,14 @@ static struct addrinfo * ai_list_append(struct addrinfo *ai_list, struct addrinf
return
ai_list
;
}
static
int
srv_compare_prio
(
const
void
*
psrv1
,
const
void
*
psrv2
){
struct
dns_srv
*
srv1
=
(
struct
dns_srv
*
)
psrv1
;
struct
dns_srv
*
srv2
=
(
struct
dns_srv
*
)
psrv2
;
if
(
srv1
->
priority
<
srv2
->
priority
)
return
-
1
;
if
(
srv1
->
priority
==
srv2
->
priority
)
return
0
;
return
1
;
}
static
int
resolver_process_data
(
belle_sip_resolver_context_t
*
ctx
,
unsigned
int
revents
)
{
char
host
[
NI_MAXHOST
+
1
];
char
service
[
NI_MAXSERV
+
1
];
...
...
@@ -170,7 +178,7 @@ static int resolver_process_data(belle_sip_resolver_context_t *ctx, unsigned int
struct
dns_srv
*
res
=
belle_sip_malloc
(
sizeof
(
struct
dns_srv
));
memcpy
(
res
,
srv
,
sizeof
(
struct
dns_srv
));
snprintf
(
host
,
sizeof
(
host
),
"[target:%s port:%d prio:%d weight:%d]"
,
srv
->
target
,
srv
->
port
,
srv
->
priority
,
srv
->
weight
);
ctx
->
srv_list
=
belle_sip_list_
appen
d
(
ctx
->
srv_list
,
res
);
ctx
->
srv_list
=
belle_sip_list_
insert_sorte
d
(
ctx
->
srv_list
,
res
,
srv_compare_prio
);
belle_sip_message
(
"SRV %s resolved to %s"
,
ctx
->
name
,
host
);
}
}
...
...
@@ -191,6 +199,11 @@ static int resolver_process_data(belle_sip_resolver_context_t *ctx, unsigned int
if
(
error
!=
DNS_EAGAIN
)
{
belle_sip_error
(
"%s dns_res_check error: %s (%d)"
,
__FUNCTION__
,
dns_strerror
(
error
),
error
);
ctx
->
done
=
TRUE
;
if
((
ctx
->
type
==
DNS_T_A
)
||
(
ctx
->
type
==
DNS_T_AAAA
))
{
ctx
->
cb
(
ctx
->
cb_data
,
ctx
->
name
,
NULL
);
}
else
if
(
ctx
->
type
==
DNS_T_SRV
)
{
ctx
->
srv_cb
(
ctx
->
cb_data
,
ctx
->
name
,
NULL
);
}
return
BELLE_SIP_STOP
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment