On 08/15/2014 08:24 PM, Susheel Aroskar wrote:
> I have a noob question. Where do I free() handles like uv_tcp_t and
> uv_connect_t? Is it safe to do it in a on_close callback? I'm getting
> SIGSEGV exception when I run mu program and when linked with libefence
> and run in gdb it points to following line as a culrpit. I'm guessing
> I'm freeing request handle prematurely - before libuv has been done with it.
> 

You can free the handle in the request callback, and the connect request
in the connect callback. If you close the handle the connect callback
will be called with UV_ECANCELED (IIRC), so it;s guaranteed that you'll
be able to free it there.

> Program terminated with signal SIGSEGV, Segmentation fault.
> 
> #0  0x00007fd0d9c4b981 in uv__finish_close (handle=<optimized out>) at
> src/unix/core.c:242
> 
> 242  QUEUE_REMOVE(&handle->handle_queue);
> 
> (gdb) bt full
> 
> #0  0x00007fd0d9c4b981 in uv__finish_close (handle=<optimized out>) at
> src/unix/core.c:242
> 
> No locals.
> 
> #1  uv__run_closing_handles (loop=<optimized out>) at src/unix/core.c:259
> 
>         p = <optimized out>
> 
>         q = <optimized out>
> 
> #2  uv_run (loop=0x7fd0d9e60b40 <default_loop_struct>, mode=UV_RUN_ONCE)
> at src/unix/core.c:327
> 
>         timeout = <optimized out>
> 
> -- 
> 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]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/libuv.
> For more options, visit https://groups.google.com/d/optout.


-- 
Saúl Ibarra Corretgé
bettercallsaghul.com


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to