{"action":"opened","issue":{"url":"https://api.github.com/repos/eclipse/mosquitto/issues/165","repository_url":"https://api.github.com/repos/eclipse/mosquitto","labels_url":"https://api.github.com/repos/eclipse/mosquitto/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/eclipse/mosquitto/issues/165/comments","events_url":"https://api.github.com/repos/eclipse/mosquitto/issues/165/events","html_url":"https://github.com/eclipse/mosquitto/issues/165","id":155259112,"number":165,"title":"Race conditions with disconnecting and mosquitto loop","user":{"login":"jcavar","id":3751289,"avatar_url":"https://avatars.githubusercontent.com/u/3751289?v=3","gravatar_id":"","url":"https://api.github.com/users/jcavar","html_url":"https://github.com/jcavar","followers_url":"https://api.github.com/users/jcavar/followers","following_url":"https://api.github.com/users/jcavar/following{/other_user}","gists_url":"https://api.github.com/users/jcavar/gists{/gist_id}","starred_url":"https://api.github.com/users/jcavar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcavar/subscriptions","organizations_url":"https://api.github.com/users/jcavar/orgs","repos_url":"https://api.github.com/users/jcavar/repos","events_url":"https://api.github.com/users/jcavar/events{/privacy}","received_events_url":"https://api.github.com/users/jcavar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-17T13:26:40Z","updated_at":"2016-05-17T13:26:40Z","closed_at":null,"body":"Hi,\r\nIt seems there is a race condition issue with mosquitto loop and disconnecting.\r\nSo `mosquitto_loop_forever` calls `mosquitto_loop` without any mutexes. Then `mosquitto_loop` calls `mosquitto__socket_connect_tls` which eventually calls `SSL_connect(mosq->ssl)`. If `_mosquitto_socket_close` is called before, this results in EXC_BAD_ACCESS on `mosq->ssl`. \r\n\r\nWe were able to reproduce this by calling connect/disconnect in a loop on different threads.\r\nAre we missing something here, or this is really bug?"}}