{"action":"created","issue":{"url":"https://api.github.com/repos/pebbe/zmq4/issues/55","labels_url":"https://api.github.com/repos/pebbe/zmq4/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/pebbe/zmq4/issues/55/comments","events_url":"https://api.github.com/repos/pebbe/zmq4/issues/55/events","html_url":"https://github.com/pebbe/zmq4/issues/55","id":102054449,"number":55,"title":"AuthStop() and Term() causes a hang on shutdown","user":{"login":"aletheia7","id":4336021,"avatar_url":"https://avatars.githubusercontent.com/u/4336021?v=3","gravatar_id":"","url":"https://api.github.com/users/aletheia7","html_url":"https://github.com/aletheia7","followers_url":"https://api.github.com/users/aletheia7/followers","following_url":"https://api.github.com/users/aletheia7/following{/other_user}","gists_url":"https://api.github.com/users/aletheia7/gists{/gist_id}","starred_url":"https://api.github.com/users/aletheia7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aletheia7/subscriptions","organizations_url":"https://api.github.com/users/aletheia7/orgs","repos_url":"https://api.github.com/users/aletheia7/repos","events_url":"https://api.github.com/users/aletheia7/events{/privacy}","received_events_url":"https://api.github.com/users/aletheia7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-08-20T03:58:43Z","updated_at":"2015-08-21T10:32:36Z","closed_at":null,"body":"zmq4 version: 4b5b0725b5d36cef61e2744bd7c93067180e3edf (latest)\r\nzeromq-4.1.3 (latest)\r\nlibsodium: 1.0.3 (latest)\r\n\r\nThere appears to be a race condition with the AuthStop() and Term() functions. Steps to reproduce the problem:\r\n\r\n1. Run the below code\r\n2. Wait 2 seconds and ctrl-c.\r\n3. It will hang within 3-5 tries.\r\n4. A second ctrl-c exists the program.\r\n\r\nComment-out the AuthStop() and Term() code below and the program exits cleanly upon ctrl-c.\r\n\r\n__Workaround__: Do not use AuthStop() and Term(). The program will end just fine.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n        \"log\"\r\n        \"os\"\r\n        \"os/signal\"\r\n        \"syscall\"\r\n        \"time\"\r\n\r\n        z \"github.com/pebbe/zmq4\"\r\n)\r\n\r\nfunc main() {\r\n        us_public_key := \"VVPVGyASr0?}lkRR28ULJj}N4Ut-NC>Q?qZ6!F3N\"\r\n        us_secret_key := \"lU9<Y]^0CG*gI6N7Gyx.Sb/Q5:SX=[3moZv>B<c9\"\r\n        them_public_key := \"K!y%@qX/ukA=Tw0E+#Lt.]k{Xu9yzZFf66TK&L@R\"\r\n        defer log.Println(\"After Term(), stopped\")\r\n        defer z.Term() // Comment-out to avoid hang\r\n        defer log.Println(\"before Term()\")\r\n        z.AuthStart()\r\n        defer z.AuthStop() // Comment-out to avoid hang\r\n        defer log.Println(\"before AuthStop()\")\r\n        z.AuthCurveAdd(\"*\", them_public_key)\r\n        defer z.AuthCurveRemoveAll(\"*\")\r\n        sock, _ := z.NewSocket(z.ROUTER)\r\n        defer sock.Close()\r\n        sock.SetIdentity(\"a\")\r\n        sock.ClientAuthCurve(them_public_key, us_public_key, us_secret_key)\r\n        connect := \"tcp://127.0.0.1:5000\"\r\n        sock.SetReconnectIvl(time.Second * 1)\r\n        sock.SetReconnectIvlMax(time.Second * 1)\r\n        sock.Connect(connect)\r\n        defer sock.Disconnect(connect)\r\n        defer sock.SetLinger(0)\r\n        sigc := make(chan os.Signal, 10)\r\n        signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)\r\n        log.Println(\"Waiting ..\")\r\n        <-time.After(3 * time.Second)\r\n        log.Println(\"ok to ctrl-c\")\r\n        <-sigc\r\n        log.Println(\"received sigc\")\r\n}\r\n```\r\n\r\nAlso hangs with zeromq-3.2.5.\r\n\r\nThank you for creating the golang library. Works great."},"comment":{"url":"https://api.github.com/repos/pebbe/zmq4/issues/comments/133368701","html_url":"https://github.com/pebbe/zmq4/issues/55#issuecomment-133368701","issue_url":"https://api.github.com/repos/pebbe/zmq4/issues/55","id":133368701,"user":{"login":"pebbe","id":829557,"avatar_url":"https://avatars.githubusercontent.com/u/829557?v=3","gravatar_id":"","url":"https://api.github.com/users/pebbe","html_url":"https://github.com/pebbe","followers_url":"https://api.github.com/users/pebbe/followers","following_url":"https://api.github.com/users/pebbe/following{/other_user}","gists_url":"https://api.github.com/users/pebbe/gists{/gist_id}","starred_url":"https://api.github.com/users/pebbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebbe/subscriptions","organizations_url":"https://api.github.com/users/pebbe/orgs","repos_url":"https://api.github.com/users/pebbe/repos","events_url":"https://api.github.com/users/pebbe/events{/privacy}","received_events_url":"https://api.github.com/users/pebbe/received_events","type":"User","site_admin":false},"created_at":"2015-08-21T10:32:36Z","updated_at":"2015-08-21T10:32:36Z","body":"I just pushed an update to github. Go 1.4.2 should now work without problems."}}