{"action":"created","issue":{"url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/41","repository_url":"https://api.github.com/repos/aerospike/aerospike-client-c","labels_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/41/comments","events_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/41/events","html_url":"https://github.com/aerospike/aerospike-client-c/issues/41","id":165462143,"number":41,"title":"Cleanup is not finished on return from aerospike_close when using libuv","user":{"login":"XeCycle","id":763350,"avatar_url":"https://avatars.githubusercontent.com/u/763350?v=3","gravatar_id":"","url":"https://api.github.com/users/XeCycle","html_url":"https://github.com/XeCycle","followers_url":"https://api.github.com/users/XeCycle/followers","following_url":"https://api.github.com/users/XeCycle/following{/other_user}","gists_url":"https://api.github.com/users/XeCycle/gists{/gist_id}","starred_url":"https://api.github.com/users/XeCycle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XeCycle/subscriptions","organizations_url":"https://api.github.com/users/XeCycle/orgs","repos_url":"https://api.github.com/users/XeCycle/repos","events_url":"https://api.github.com/users/XeCycle/events{/privacy}","received_events_url":"https://api.github.com/users/XeCycle/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-14T02:23:23Z","updated_at":"2016-07-28T00:07:04Z","closed_at":"2016-07-28T00:07:04Z","body":"The [uv code](https://github.com/aerospike/aerospike-client-c/blob/master/src/main/aerospike/as_event_uv.c#L657-L662) queues up closing of connections but the [ev code](https://github.com/aerospike/aerospike-client-c/blob/master/src/main/aerospike/as_event_ev.c#L577-L578) closes immediately.  As a result, when using libuv, a return from `aerospike_close` still leaves open connections to be closed, which will be executed on later loop iterations; but at this point it is unsafe to call `as_event_close_loops` from one of the loop threads, because a loop will be [closed immediately if detected to be on the same thread as the caller](https://github.com/aerospike/aerospike-client-c/blob/master/src/main/aerospike/as_event.c#L150-L153), and pending connections will be leaked.\r\n\r\nBtw. in uv the aerospike_close -> aerospike_destroy -> as_event_close_loops process gives me a segfault in trying to unlock a mutex at [the end](https://github.com/aerospike/aerospike-client-c/blob/master/src/main/aerospike/as_event_uv.c#L702); I am not sure if these are related, but if I skip that thread == current thread check and blindly queue up the close command, it works fine."},"comment":{"url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/comments/235759295","html_url":"https://github.com/aerospike/aerospike-client-c/issues/41#issuecomment-235759295","issue_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/41","id":235759295,"user":{"login":"BrianNichols","id":1761530,"avatar_url":"https://avatars.githubusercontent.com/u/1761530?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianNichols","html_url":"https://github.com/BrianNichols","followers_url":"https://api.github.com/users/BrianNichols/followers","following_url":"https://api.github.com/users/BrianNichols/following{/other_user}","gists_url":"https://api.github.com/users/BrianNichols/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianNichols/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianNichols/subscriptions","organizations_url":"https://api.github.com/users/BrianNichols/orgs","repos_url":"https://api.github.com/users/BrianNichols/repos","events_url":"https://api.github.com/users/BrianNichols/events{/privacy}","received_events_url":"https://api.github.com/users/BrianNichols/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T00:07:03Z","updated_at":"2016-07-28T00:07:03Z","body":"C client  4.0.7 now always queues the event loop close."}}
{"actor":{"display_login":"BrianNichols"}}