On 4/20/14 5:54 PM, Iñaki Baz Castillo wrote:
Hi,
I don't understand how to properly behave in the following case:
I have a loop with a single uv_tcp_t handle (a TCP server), but the
call to uv_tcp_bind() fails (unavailable address or any other reason).
After such a failure the loops automatically exists (it seems that a
uv_tcp_t handle is not active until it is listening or connected, am I
right?). Assuming this is true: can I safely free() the handle? or do
I need to call uv_close() and free it in the close callback?
Thanks a lot.
Hi,
You still need to go through the uv_close callback dance. When you
initialize a handle (uv_tcp_init in your case) the loop adds it to a
list of handles it keeps. That list can be walked using uv_walk. So, if
you free the handle before uv_close, you'd have some use-after-free case
when that list is modified (ie, when a new handle is created, uv_walk is
used, etc).
Cheers.
--
Saúl Ibarra Corretgé
http://bettercallsaghul.com
--
You received this message because you are subscribed to the Google Groups
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.