On 07/20/2015 08:13 AM, Zhang GuoQi wrote:
> here is my test code. two handle, a timer and a async .
>
> #include "uv.h"
> #include <stdio.h>
> #include <stdlib.h>
> #include <assert.h>
>
> static uv_async_t async;
> static uv_timer_t timer;
>
> static void async_cb(uv_async_t* handle) {
> int n;
>
> assert(handle == &async);
>
> uv_close((uv_handle_t*)&async, 0);
> }
>
> static void timer_run_once_timer_cb(uv_timer_t* handle) {
> uv_timer_stop(handle);
> uv_async_send(&async);
> }
>
> int main()
> {
> int r;
>
> uv_loop_t* loop = (uv_loop_t*)malloc(sizeof(uv_loop_t));
> uv_loop_init(loop);
>
> fprintf(stderr, "new loop: %0x\n", loop);
>
> r = uv_timer_init(loop, &timer);
> assert(r == 0);
>
> r = uv_timer_start(&timer, timer_run_once_timer_cb, 1000, 0);
> assert(r == 0);
>
> r = uv_async_init(loop, &async, async_cb);
> assert(r == 0);
>
> r = uv_run(loop, UV_RUN_DEFAULT);
> assert(r == 0);
>
> fprintf(stderr, "close loop: %0x\n", loop);
>
> r = uv_loop_close(loop);
> assert (r == 0); // ######################### core here
>
> free(loop);
>
> return 0;
> }
> You need to close all handles. You have closed the async handle but not the timer handle. uv_run did return because there is no active handle (the timer is stopped), but there are still handles attached to the loop, namely the timer handle. Cheers, -- Saúl Ibarra Corretgé 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.
signature.asc
Description: OpenPGP digital signature
