{"action":"opened","issue":{"url":"https://api.github.com/repos/blackberry/WebWorks-Community-APIs/issues/407","labels_url":"https://api.github.com/repos/blackberry/WebWorks-Community-APIs/issues/407/labels{/name}","comments_url":"https://api.github.com/repos/blackberry/WebWorks-Community-APIs/issues/407/comments","events_url":"https://api.github.com/repos/blackberry/WebWorks-Community-APIs/issues/407/events","html_url":"https://github.com/blackberry/WebWorks-Community-APIs/issues/407","id":82486655,"number":407,"title":"Plugin Template: mutex not initialized correctly","user":{"login":"dsc28","id":6614172,"avatar_url":"https://avatars.githubusercontent.com/u/6614172?v=3","gravatar_id":"","url":"https://api.github.com/users/dsc28","html_url":"https://github.com/dsc28","followers_url":"https://api.github.com/users/dsc28/followers","following_url":"https://api.github.com/users/dsc28/following{/other_user}","gists_url":"https://api.github.com/users/dsc28/gists{/gist_id}","starred_url":"https://api.github.com/users/dsc28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsc28/subscriptions","organizations_url":"https://api.github.com/users/dsc28/orgs","repos_url":"https://api.github.com/users/dsc28/repos","events_url":"https://api.github.com/users/dsc28/events{/privacy}","received_events_url":"https://api.github.com/users/dsc28/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-29T16:05:52Z","updated_at":"2015-05-29T16:05:52Z","closed_at":null,"body":"I have written a Webworks plugin based off your excellent plugin template, in the course of that I found a bug: `template_ndk.hpp` defines two private member variables `cond` and `mutex` (see [here](https://github.com/blackberry/WebWorks-Community-APIs/blob/master/BB10-Cordova/Template/plugin/src/blackberry10/native/src/template_ndk.hpp#L58#L59)).\r\n\r\nIn the corresponding constructor in `template_ndk.cpp`, these two are supposed to get initialized, but they aren't. Instead, new variables, which are local to the constructor, are declared (see [here](https://github.com/blackberry/WebWorks-Community-APIs/blob/master/BB10-Cordova/Template/plugin/src/blackberry10/native/src/template_ndk.cpp#L33#L34)), which for me meant that the mutex was never correctly initialized, my thread synchronization acted weirdly and my app froze.\r\n\r\nLong story short: in `template_ndk.cpp`, this:\r\n```C++\r\n\t\tpthread_cond_t cond  = PTHREAD_COND_INITIALIZER;\r\n\t\tpthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;\r\n```\r\nshould become this:\r\n```C++\r\n\t\tcond  = PTHREAD_COND_INITIALIZER;\r\n\t\tmutex = PTHREAD_MUTEX_INITIALIZER;\r\n```\r\n\r\nThanks for this (otherwise ;-) ) great template."}}