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
fbf2b34d
Commit
fbf2b34d
authored
Jun 06, 2013
by
Simon Morlat
Browse files
fix potential double close of socket file descriptors
parent
ab0f6d5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/channel.c
View file @
fbf2b34d
...
...
@@ -379,7 +379,7 @@ int belle_sip_channel_recv(belle_sip_channel_t *obj, void *buf, size_t buflen){
void
belle_sip_channel_close
(
belle_sip_channel_t
*
obj
){
if
(
BELLE_SIP_OBJECT_VPTR
(
obj
,
belle_sip_channel_t
)
->
close
)
BELLE_SIP_OBJECT_VPTR
(
obj
,
belle_sip_channel_t
)
->
close
(
obj
);
/*udp channel don't have close function*/
BELLE_SIP_OBJECT_VPTR
(
obj
,
belle_sip_channel_t
)
->
close
(
obj
);
/*udp channel do
es
n't have close function*/
belle_sip_main_loop_remove_source
(
obj
->
stack
->
ml
,(
belle_sip_source_t
*
)
obj
);
belle_sip_source_uninit
((
belle_sip_source_t
*
)
obj
);
}
...
...
src/transports/stream_channel.c
View file @
fbf2b34d
...
...
@@ -71,7 +71,6 @@ int stream_channel_recv(belle_sip_stream_channel_t *obj, void *buf, size_t bufle
void
stream_channel_close
(
belle_sip_stream_channel_t
*
obj
){
belle_sip_socket_t
sock
=
belle_sip_source_get_socket
((
belle_sip_source_t
*
)
obj
);
if
(
sock
!=
(
belle_sip_socket_t
)
-
1
){
close_socket
(
sock
);
#ifdef TARGET_OS_IPHONE
if
(
obj
->
read_stream
!=
NULL
)
{
CFReadStreamClose
(
obj
->
read_stream
);
...
...
@@ -84,6 +83,7 @@ void stream_channel_close(belle_sip_stream_channel_t *obj){
obj
->
write_stream
=
NULL
;
}
#endif
close_socket
(
sock
);
}
}
...
...
@@ -132,8 +132,6 @@ int stream_channel_connect(belle_sip_stream_channel_t *obj, const struct addrinf
belle_sip_error
(
"setsockopt TCP_NODELAY failed: [%s]"
,
belle_sip_get_socket_error_string
());
}
belle_sip_socket_set_nonblocking
(
sock
);
belle_sip_channel_set_socket
((
belle_sip_channel_t
*
)
obj
,
sock
,(
belle_sip_source_func_t
)
stream_channel_process_data
);
belle_sip_source_set_events
((
belle_sip_source_t
*
)
obj
,
BELLE_SIP_EVENT_WRITE
|
BELLE_SIP_EVENT_ERROR
);
err
=
connect
(
sock
,
ai
->
ai_addr
,
ai
->
ai_addrlen
);
if
(
err
!=
0
&&
get_socket_error
()
!=
BELLESIP_EINPROGRESS
&&
get_socket_error
()
!=
BELLESIP_EWOULDBLOCK
)
{
...
...
@@ -141,6 +139,8 @@ int stream_channel_connect(belle_sip_stream_channel_t *obj, const struct addrinf
close_socket
(
sock
);
return
-
1
;
}
belle_sip_channel_set_socket
((
belle_sip_channel_t
*
)
obj
,
sock
,(
belle_sip_source_func_t
)
stream_channel_process_data
);
belle_sip_source_set_events
((
belle_sip_source_t
*
)
obj
,
BELLE_SIP_EVENT_WRITE
|
BELLE_SIP_EVENT_ERROR
);
belle_sip_main_loop_add_source
(
obj
->
base
.
stack
->
ml
,(
belle_sip_source_t
*
)
obj
);
return
0
;
}
...
...
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