{"action":"created","issue":{"url":"https://api.github.com/repos/libuv/libuv/issues/276","labels_url":"https://api.github.com/repos/libuv/libuv/issues/276/labels{/name}","comments_url":"https://api.github.com/repos/libuv/libuv/issues/276/comments","events_url":"https://api.github.com/repos/libuv/libuv/issues/276/events","html_url":"https://github.com/libuv/libuv/issues/276","id":63039801,"number":276,"title":"Callback won't fire on async handle if unref'd and primed before uv_run()","user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-19T17:07:30Z","updated_at":"2015-03-19T23:11:20Z","closed_at":null,"body":"```c\r\n#include <assert.h>\r\n#include \"uv.h\"\r\n\r\nstatic void async_cb(uv_async_t* handle) {\r\n  *(unsigned*) handle->data += 1;\r\n}\r\n\r\nint main(void) {\r\n  uv_loop_t loop;\r\n  uv_async_t handle;\r\n  unsigned numcalls;\r\n\r\n  assert(0 == uv_loop_init(&loop));\r\n  assert(0 == uv_async_init(&loop, &handle, async_cb));\r\n  handle.data = &numcalls;\r\n  numcalls = 0;\r\n\r\n  uv_unref((uv_handle_t*) &handle);\r\n  assert(0 == uv_async_send(&handle));\r\n  assert(0 == uv_run(&loop, UV_RUN_DEFAULT));\r\n  assert(1 == numcalls);  /* Fails because numcalls == 0. */\r\n\r\n  return 0;\r\n}\r\n```\r\n\r\nIt's arguably a bug.  At the very least, it's unexpected.\r\n\r\n/cc @petkaantonov"},"comment":{"url":"https://api.github.com/repos/libuv/libuv/issues/comments/83798024","html_url":"https://github.com/libuv/libuv/issues/276#issuecomment-83798024","issue_url":"https://api.github.com/repos/libuv/libuv/issues/276","id":83798024,"user":{"login":"petkaantonov","id":829734,"avatar_url":"https://avatars.githubusercontent.com/u/829734?v=3","gravatar_id":"","url":"https://api.github.com/users/petkaantonov","html_url":"https://github.com/petkaantonov","followers_url":"https://api.github.com/users/petkaantonov/followers","following_url":"https://api.github.com/users/petkaantonov/following{/other_user}","gists_url":"https://api.github.com/users/petkaantonov/gists{/gist_id}","starred_url":"https://api.github.com/users/petkaantonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petkaantonov/subscriptions","organizations_url":"https://api.github.com/users/petkaantonov/orgs","repos_url":"https://api.github.com/users/petkaantonov/repos","events_url":"https://api.github.com/users/petkaantonov/events{/privacy}","received_events_url":"https://api.github.com/users/petkaantonov/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T23:11:20Z","updated_at":"2015-03-19T23:11:20Z","body":"Sure but async_send is completely different because you are supposed to be able to use it to notify another thread, which could momentarily be outside uv_run (unless using RUN_DEFAULT) as you notify it. So this means it's unsuitable for what appears to be its only purpose..."}}