{"action":"opened","number":469,"pull_request":{"url":"https://api.github.com/repos/meetecho/janus-gateway/pulls/469","id":59480307,"html_url":"https://github.com/meetecho/janus-gateway/pull/469","diff_url":"https://github.com/meetecho/janus-gateway/pull/469.diff","patch_url":"https://github.com/meetecho/janus-gateway/pull/469.patch","issue_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/469","number":469,"state":"open","locked":false,"title":"Fix for occasional race conditions when shutting down the SIP stack","user":{"login":"lminiero","id":3684796,"avatar_url":"https://avatars.githubusercontent.com/u/3684796?v=3","gravatar_id":"","url":"https://api.github.com/users/lminiero","html_url":"https://github.com/lminiero","followers_url":"https://api.github.com/users/lminiero/followers","following_url":"https://api.github.com/users/lminiero/following{/other_user}","gists_url":"https://api.github.com/users/lminiero/gists{/gist_id}","starred_url":"https://api.github.com/users/lminiero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lminiero/subscriptions","organizations_url":"https://api.github.com/users/lminiero/orgs","repos_url":"https://api.github.com/users/lminiero/repos","events_url":"https://api.github.com/users/lminiero/events{/privacy}","received_events_url":"https://api.github.com/users/lminiero/received_events","type":"User","site_admin":false},"body":"This PR fixes a problem that @bhakimi reported. Specifically, Janus would at times crash, apparently for no reason, while using the SIP plugin. Looking at traces, we found out that, when this happened, the Sofia stack had just received a shutdown event (```nua_r_shutdown```), and the exact cause was a race condition where the plugin session had already been freed, thus crashing the plugin when trying to access its content.\r\n\r\nTo fix this, I modified the plugin code to do the following:\r\n\r\n1. only initialise the SIP stack within the ```janus_sip_sofia_thread``` Sofia loop thread: this way the stack is only freed when the loop ends, that is after the shutdown event;\r\n2. modified the way the lazy garbage collector kicks in: immediately adding the session to the \"old\" list if there is no stack (i.e., plugin session never handled a successfull register request), or at the end of the above mentioned Sofia loop thread (so that the session is only collected after the stack has been shut down).\r\n\r\nI also fixed a couple of leaks here and there, and verified this seems to be working as expected now, but since this is a serious change and I don't want it to break anything people has working correctly as of now, I decided to publish it as a PR for the moment.\r\n\r\nIf you're using SIP please test this and let me know if it's safe to merge. Mentioning some of the people I know are using this because of recent related issues/PR activity, so forgive the spam: @saghul @hoangtuansu @cwerner-bfs @s-schumann @phillcz @MichaelB76 @shrhoads","created_at":"2016-02-16T11:55:45Z","updated_at":"2016-02-16T11:55:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/meetecho/janus-gateway/pulls/469/commits","review_comments_url":"https://api.github.com/repos/meetecho/janus-gateway/pulls/469/comments","review_comment_url":"https://api.github.com/repos/meetecho/janus-gateway/pulls/comments{/number}","comments_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/469/comments","statuses_url":"https://api.github.com/repos/meetecho/janus-gateway/statuses/838e2a39af1c3d0aa90336375ce6e2ca134eeed1","head":{"label":"meetecho:sip-shutdown","ref":"sip-shutdown","sha":"838e2a39af1c3d0aa90336375ce6e2ca134eeed1","user":{"login":"meetecho","id":4520545,"avatar_url":"https://avatars.githubusercontent.com/u/4520545?v=3","gravatar_id":"","url":"https://api.github.com/users/meetecho","html_url":"https://github.com/meetecho","followers_url":"https://api.github.com/users/meetecho/followers","following_url":"https://api.github.com/users/meetecho/following{/other_user}","gists_url":"https://api.github.com/users/meetecho/gists{/gist_id}","starred_url":"https://api.github.com/users/meetecho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetecho/subscriptions","organizations_url":"https://api.github.com/users/meetecho/orgs","repos_url":"https://api.github.com/users/meetecho/repos","events_url":"https://api.github.com/users/meetecho/events{/privacy}","received_events_url":"https://api.github.com/users/meetecho/received_events","type":"Organization","site_admin":false},"repo":{"id":16734696,"name":"janus-gateway","full_name":"meetecho/janus-gateway","owner":{"login":"meetecho","id":4520545,"avatar_url":"https://avatars.githubusercontent.com/u/4520545?v=3","gravatar_id":"","url":"https://api.github.com/users/meetecho","html_url":"https://github.com/meetecho","followers_url":"https://api.github.com/users/meetecho/followers","following_url":"https://api.github.com/users/meetecho/following{/other_user}","gists_url":"https://api.github.com/users/meetecho/gists{/gist_id}","starred_url":"https://api.github.com/users/meetecho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetecho/subscriptions","organizations_url":"https://api.github.com/users/meetecho/orgs","repos_url":"https://api.github.com/users/meetecho/repos","events_url":"https://api.github.com/users/meetecho/events{/privacy}","received_events_url":"https://api.github.com/users/meetecho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/meetecho/janus-gateway","description":"Janus WebRTC Gateway","fork":false,"url":"https://api.github.com/repos/meetecho/janus-gateway","forks_url":"https://api.github.com/repos/meetecho/janus-gateway/forks","keys_url":"https://api.github.com/repos/meetecho/janus-gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meetecho/janus-gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meetecho/janus-gateway/teams","hooks_url":"https://api.github.com/repos/meetecho/janus-gateway/hooks","issue_events_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/events{/number}","events_url":"https://api.github.com/repos/meetecho/janus-gateway/events","assignees_url":"https://api.github.com/repos/meetecho/janus-gateway/assignees{/user}","branches_url":"https://api.github.com/repos/meetecho/janus-gateway/branches{/branch}","tags_url":"https://api.github.com/repos/meetecho/janus-gateway/tags","blobs_url":"https://api.github.com/repos/meetecho/janus-gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meetecho/janus-gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meetecho/janus-gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/meetecho/janus-gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meetecho/janus-gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/meetecho/janus-gateway/languages","stargazers_url":"https://api.github.com/repos/meetecho/janus-gateway/stargazers","contributors_url":"https://api.github.com/repos/meetecho/janus-gateway/contributors","subscribers_url":"https://api.github.com/repos/meetecho/janus-gateway/subscribers","subscription_url":"https://api.github.com/repos/meetecho/janus-gateway/subscription","commits_url":"https://api.github.com/repos/meetecho/janus-gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/meetecho/janus-gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/meetecho/janus-gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/meetecho/janus-gateway/contents/{+path}","compare_url":"https://api.github.com/repos/meetecho/janus-gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meetecho/janus-gateway/merges","archive_url":"https://api.github.com/repos/meetecho/janus-gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meetecho/janus-gateway/downloads","issues_url":"https://api.github.com/repos/meetecho/janus-gateway/issues{/number}","pulls_url":"https://api.github.com/repos/meetecho/janus-gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/meetecho/janus-gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/meetecho/janus-gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meetecho/janus-gateway/labels{/name}","releases_url":"https://api.github.com/repos/meetecho/janus-gateway/releases{/id}","deployments_url":"https://api.github.com/repos/meetecho/janus-gateway/deployments","created_at":"2014-02-11T15:14:39Z","updated_at":"2016-02-16T06:45:14Z","pushed_at":"2016-02-16T11:55:46Z","git_url":"git://github.com/meetecho/janus-gateway.git","ssh_url":"git@github.com:meetecho/janus-gateway.git","clone_url":"https://github.com/meetecho/janus-gateway.git","svn_url":"https://github.com/meetecho/janus-gateway","homepage":null,"size":12272,"stargazers_count":471,"watchers_count":471,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":199,"mirror_url":null,"open_issues_count":21,"forks":199,"open_issues":21,"watchers":471,"default_branch":"master"}},"base":{"label":"meetecho:master","ref":"master","sha":"8a9023c733e1196852e0b7405aff348567fca92d","user":{"login":"meetecho","id":4520545,"avatar_url":"https://avatars.githubusercontent.com/u/4520545?v=3","gravatar_id":"","url":"https://api.github.com/users/meetecho","html_url":"https://github.com/meetecho","followers_url":"https://api.github.com/users/meetecho/followers","following_url":"https://api.github.com/users/meetecho/following{/other_user}","gists_url":"https://api.github.com/users/meetecho/gists{/gist_id}","starred_url":"https://api.github.com/users/meetecho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetecho/subscriptions","organizations_url":"https://api.github.com/users/meetecho/orgs","repos_url":"https://api.github.com/users/meetecho/repos","events_url":"https://api.github.com/users/meetecho/events{/privacy}","received_events_url":"https://api.github.com/users/meetecho/received_events","type":"Organization","site_admin":false},"repo":{"id":16734696,"name":"janus-gateway","full_name":"meetecho/janus-gateway","owner":{"login":"meetecho","id":4520545,"avatar_url":"https://avatars.githubusercontent.com/u/4520545?v=3","gravatar_id":"","url":"https://api.github.com/users/meetecho","html_url":"https://github.com/meetecho","followers_url":"https://api.github.com/users/meetecho/followers","following_url":"https://api.github.com/users/meetecho/following{/other_user}","gists_url":"https://api.github.com/users/meetecho/gists{/gist_id}","starred_url":"https://api.github.com/users/meetecho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetecho/subscriptions","organizations_url":"https://api.github.com/users/meetecho/orgs","repos_url":"https://api.github.com/users/meetecho/repos","events_url":"https://api.github.com/users/meetecho/events{/privacy}","received_events_url":"https://api.github.com/users/meetecho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/meetecho/janus-gateway","description":"Janus WebRTC Gateway","fork":false,"url":"https://api.github.com/repos/meetecho/janus-gateway","forks_url":"https://api.github.com/repos/meetecho/janus-gateway/forks","keys_url":"https://api.github.com/repos/meetecho/janus-gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meetecho/janus-gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meetecho/janus-gateway/teams","hooks_url":"https://api.github.com/repos/meetecho/janus-gateway/hooks","issue_events_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/events{/number}","events_url":"https://api.github.com/repos/meetecho/janus-gateway/events","assignees_url":"https://api.github.com/repos/meetecho/janus-gateway/assignees{/user}","branches_url":"https://api.github.com/repos/meetecho/janus-gateway/branches{/branch}","tags_url":"https://api.github.com/repos/meetecho/janus-gateway/tags","blobs_url":"https://api.github.com/repos/meetecho/janus-gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meetecho/janus-gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meetecho/janus-gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/meetecho/janus-gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meetecho/janus-gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/meetecho/janus-gateway/languages","stargazers_url":"https://api.github.com/repos/meetecho/janus-gateway/stargazers","contributors_url":"https://api.github.com/repos/meetecho/janus-gateway/contributors","subscribers_url":"https://api.github.com/repos/meetecho/janus-gateway/subscribers","subscription_url":"https://api.github.com/repos/meetecho/janus-gateway/subscription","commits_url":"https://api.github.com/repos/meetecho/janus-gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/meetecho/janus-gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/meetecho/janus-gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/meetecho/janus-gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/meetecho/janus-gateway/contents/{+path}","compare_url":"https://api.github.com/repos/meetecho/janus-gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meetecho/janus-gateway/merges","archive_url":"https://api.github.com/repos/meetecho/janus-gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meetecho/janus-gateway/downloads","issues_url":"https://api.github.com/repos/meetecho/janus-gateway/issues{/number}","pulls_url":"https://api.github.com/repos/meetecho/janus-gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/meetecho/janus-gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/meetecho/janus-gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meetecho/janus-gateway/labels{/name}","releases_url":"https://api.github.com/repos/meetecho/janus-gateway/releases{/id}","deployments_url":"https://api.github.com/repos/meetecho/janus-gateway/deployments","created_at":"2014-02-11T15:14:39Z","updated_at":"2016-02-16T06:45:14Z","pushed_at":"2016-02-16T11:55:46Z","git_url":"git://github.com/meetecho/janus-gateway.git","ssh_url":"git@github.com:meetecho/janus-gateway.git","clone_url":"https://github.com/meetecho/janus-gateway.git","svn_url":"https://github.com/meetecho/janus-gateway","homepage":null,"size":12272,"stargazers_count":471,"watchers_count":471,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":199,"mirror_url":null,"open_issues_count":21,"forks":199,"open_issues":21,"watchers":471,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/meetecho/janus-gateway/pulls/469"},"html":{"href":"https://github.com/meetecho/janus-gateway/pull/469"},"issue":{"href":"https://api.github.com/repos/meetecho/janus-gateway/issues/469"},"comments":{"href":"https://api.github.com/repos/meetecho/janus-gateway/issues/469/comments"},"review_comments":{"href":"https://api.github.com/repos/meetecho/janus-gateway/pulls/469/comments"},"review_comment":{"href":"https://api.github.com/repos/meetecho/janus-gateway/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/meetecho/janus-gateway/pulls/469/commits"},"statuses":{"href":"https://api.github.com/repos/meetecho/janus-gateway/statuses/838e2a39af1c3d0aa90336375ce6e2ca134eeed1"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":33,"deletions":18,"changed_files":1}}