{"action":"created","comment":{"url":"https://api.github.com/repos/mer-packages/mkcal/pulls/comments/22656615","id":22656615,"diff_hunk":"@@ -0,0 +1,248 @@\n+/*\n+ * Copyright (C) 2013 Jolla Ltd. <matthew.vogt@jollamobile.com>\n+ *\n+ * You may use this file under the terms of the BSD license as follows:\n+ *\n+ * \"Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are\n+ * met:\n+ *   * Redistributions of source code must retain the above copyright\n+ *     notice, this list of conditions and the following disclaimer.\n+ *   * Redistributions in binary form must reproduce the above copyright\n+ *     notice, this list of conditions and the following disclaimer in\n+ *     the documentation and/or other materials provided with the\n+ *     distribution.\n+ *   * Neither the name of Nemo Mobile nor the names of its contributors\n+ *     may be used to endorse or promote products derived from this\n+ *     software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\"\n+ */\n+\n+#include \"semaphore_p.h\"\n+\n+#include <errno.h>\n+#include <unistd.h>\n+\n+#include <sys/sem.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n+#include <sys/ipc.h>\n+\n+#include <kdebug.h>\n+\n+namespace {\n+\n+// Defined as required for ::semun\n+union semun {\n+    int              val;\n+    struct semid_ds *buf;\n+    unsigned short  *array;\n+    struct seminfo  *__buf;\n+};\n+\n+void semaphoreError(const char *msg, const char *id, int error)\n+{\n+    kError() << QString::fromLatin1(\"%1 %2: %3 (%4)\").arg(msg).arg(id).arg(::strerror(error)).arg(error).toUtf8().constData();\n+}\n+\n+int semaphoreInit(const char *id, size_t count, const int *initialValues)\n+{\n+    int rv = -1;\n+\n+    key_t key = ::ftok(id, 0);","path":"src/semaphore_p.cpp","position":63,"original_position":63,"commit_id":"d9e647a50253bd5f992aaf977b940f79606b70d6","original_commit_id":"d9e647a50253bd5f992aaf977b940f79606b70d6","user":{"login":"pvuorela","id":2478615,"avatar_url":"https://avatars.githubusercontent.com/u/2478615?v=3","gravatar_id":"","url":"https://api.github.com/users/pvuorela","html_url":"https://github.com/pvuorela","followers_url":"https://api.github.com/users/pvuorela/followers","following_url":"https://api.github.com/users/pvuorela/following{/other_user}","gists_url":"https://api.github.com/users/pvuorela/gists{/gist_id}","starred_url":"https://api.github.com/users/pvuorela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvuorela/subscriptions","organizations_url":"https://api.github.com/users/pvuorela/orgs","repos_url":"https://api.github.com/users/pvuorela/repos","events_url":"https://api.github.com/users/pvuorela/events{/privacy}","received_events_url":"https://api.github.com/users/pvuorela/received_events","type":"User","site_admin":false},"body":"Exists already in qtcontacts-sqlite, but notice man page for ftok() wanting non-zero least significant 8 bits on second parameter. @matthewvogt ?","created_at":"2015-01-08T15:14:12Z","updated_at":"2015-01-08T15:14:12Z","html_url":"https://github.com/mer-packages/mkcal/pull/19#discussion_r22656615","pull_request_url":"https://api.github.com/repos/mer-packages/mkcal/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/mer-packages/mkcal/pulls/comments/22656615"},"html":{"href":"https://github.com/mer-packages/mkcal/pull/19#discussion_r22656615"},"pull_request":{"href":"https://api.github.com/repos/mer-packages/mkcal/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/mer-packages/mkcal/pulls/19","id":26867821,"html_url":"https://github.com/mer-packages/mkcal/pull/19","diff_url":"https://github.com/mer-packages/mkcal/pull/19.diff","patch_url":"https://github.com/mer-packages/mkcal/pull/19.patch","issue_url":"https://api.github.com/repos/mer-packages/mkcal/issues/19","number":19,"state":"open","locked":false,"title":"[mkcal] Fix inter-process locking of sqlite storeage.","user":{"login":"adenexter","id":2569799,"avatar_url":"https://avatars.githubusercontent.com/u/2569799?v=3","gravatar_id":"","url":"https://api.github.com/users/adenexter","html_url":"https://github.com/adenexter","followers_url":"https://api.github.com/users/adenexter/followers","following_url":"https://api.github.com/users/adenexter/following{/other_user}","gists_url":"https://api.github.com/users/adenexter/gists{/gist_id}","starred_url":"https://api.github.com/users/adenexter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adenexter/subscriptions","organizations_url":"https://api.github.com/users/adenexter/orgs","repos_url":"https://api.github.com/users/adenexter/repos","events_url":"https://api.github.com/users/adenexter/events{/privacy}","received_events_url":"https://api.github.com/users/adenexter/received_events","type":"User","site_admin":false},"body":"Constructing a QSystemSemaphore with the Create flag resets the\r\nsemaphore on construction releasing any lock held by another process\r\nat that time, the Open flag is more correct but has issues with crashed\r\nprocesses holding onto locks.  So use the inter-process mutex from\r\nqmf/qtcontacts-sqlite which doesn't have these issues instead of\r\nQSystemSemaphore.","created_at":"2015-01-06T03:23:13Z","updated_at":"2015-01-08T15:14:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19ae1c694e75d7ca18df1af054c1a1ec87f36a7a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mer-packages/mkcal/pulls/19/commits","review_comments_url":"https://api.github.com/repos/mer-packages/mkcal/pulls/19/comments","review_comment_url":"https://api.github.com/repos/mer-packages/mkcal/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mer-packages/mkcal/issues/19/comments","statuses_url":"https://api.github.com/repos/mer-packages/mkcal/statuses/d9e647a50253bd5f992aaf977b940f79606b70d6","head":{"label":"adenexter:locking","ref":"locking","sha":"d9e647a50253bd5f992aaf977b940f79606b70d6","user":{"login":"adenexter","id":2569799,"avatar_url":"https://avatars.githubusercontent.com/u/2569799?v=3","gravatar_id":"","url":"https://api.github.com/users/adenexter","html_url":"https://github.com/adenexter","followers_url":"https://api.github.com/users/adenexter/followers","following_url":"https://api.github.com/users/adenexter/following{/other_user}","gists_url":"https://api.github.com/users/adenexter/gists{/gist_id}","starred_url":"https://api.github.com/users/adenexter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adenexter/subscriptions","organizations_url":"https://api.github.com/users/adenexter/orgs","repos_url":"https://api.github.com/users/adenexter/repos","events_url":"https://api.github.com/users/adenexter/events{/privacy}","received_events_url":"https://api.github.com/users/adenexter/received_events","type":"User","site_admin":false},"repo":{"id":28839409,"name":"mkcal","full_name":"adenexter/mkcal","owner":{"login":"adenexter","id":2569799,"avatar_url":"https://avatars.githubusercontent.com/u/2569799?v=3","gravatar_id":"","url":"https://api.github.com/users/adenexter","html_url":"https://github.com/adenexter","followers_url":"https://api.github.com/users/adenexter/followers","following_url":"https://api.github.com/users/adenexter/following{/other_user}","gists_url":"https://api.github.com/users/adenexter/gists{/gist_id}","starred_url":"https://api.github.com/users/adenexter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adenexter/subscriptions","organizations_url":"https://api.github.com/users/adenexter/orgs","repos_url":"https://api.github.com/users/adenexter/repos","events_url":"https://api.github.com/users/adenexter/events{/privacy}","received_events_url":"https://api.github.com/users/adenexter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adenexter/mkcal","description":"","fork":true,"url":"https://api.github.com/repos/adenexter/mkcal","forks_url":"https://api.github.com/repos/adenexter/mkcal/forks","keys_url":"https://api.github.com/repos/adenexter/mkcal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adenexter/mkcal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adenexter/mkcal/teams","hooks_url":"https://api.github.com/repos/adenexter/mkcal/hooks","issue_events_url":"https://api.github.com/repos/adenexter/mkcal/issues/events{/number}","events_url":"https://api.github.com/repos/adenexter/mkcal/events","assignees_url":"https://api.github.com/repos/adenexter/mkcal/assignees{/user}","branches_url":"https://api.github.com/repos/adenexter/mkcal/branches{/branch}","tags_url":"https://api.github.com/repos/adenexter/mkcal/tags","blobs_url":"https://api.github.com/repos/adenexter/mkcal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adenexter/mkcal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adenexter/mkcal/git/refs{/sha}","trees_url":"https://api.github.com/repos/adenexter/mkcal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adenexter/mkcal/statuses/{sha}","languages_url":"https://api.github.com/repos/adenexter/mkcal/languages","stargazers_url":"https://api.github.com/repos/adenexter/mkcal/stargazers","contributors_url":"https://api.github.com/repos/adenexter/mkcal/contributors","subscribers_url":"https://api.github.com/repos/adenexter/mkcal/subscribers","subscription_url":"https://api.github.com/repos/adenexter/mkcal/subscription","commits_url":"https://api.github.com/repos/adenexter/mkcal/commits{/sha}","git_commits_url":"https://api.github.com/repos/adenexter/mkcal/git/commits{/sha}","comments_url":"https://api.github.com/repos/adenexter/mkcal/comments{/number}","issue_comment_url":"https://api.github.com/repos/adenexter/mkcal/issues/comments/{number}","contents_url":"https://api.github.com/repos/adenexter/mkcal/contents/{+path}","compare_url":"https://api.github.com/repos/adenexter/mkcal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adenexter/mkcal/merges","archive_url":"https://api.github.com/repos/adenexter/mkcal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adenexter/mkcal/downloads","issues_url":"https://api.github.com/repos/adenexter/mkcal/issues{/number}","pulls_url":"https://api.github.com/repos/adenexter/mkcal/pulls{/number}","milestones_url":"https://api.github.com/repos/adenexter/mkcal/milestones{/number}","notifications_url":"https://api.github.com/repos/adenexter/mkcal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adenexter/mkcal/labels{/name}","releases_url":"https://api.github.com/repos/adenexter/mkcal/releases{/id}","created_at":"2015-01-06T00:44:36Z","updated_at":"2015-01-06T00:44:36Z","pushed_at":"2015-01-06T11:30:17Z","git_url":"git://github.com/adenexter/mkcal.git","ssh_url":"git@github.com:adenexter/mkcal.git","clone_url":"https://github.com/adenexter/mkcal.git","svn_url":"https://github.com/adenexter/mkcal","homepage":null,"size":654,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mer-packages:master","ref":"master","sha":"e0b46b49a476d5db29c7f04b712348e1e82ba139","user":{"login":"mer-packages","id":3016659,"avatar_url":"https://avatars.githubusercontent.com/u/3016659?v=3","gravatar_id":"","url":"https://api.github.com/users/mer-packages","html_url":"https://github.com/mer-packages","followers_url":"https://api.github.com/users/mer-packages/followers","following_url":"https://api.github.com/users/mer-packages/following{/other_user}","gists_url":"https://api.github.com/users/mer-packages/gists{/gist_id}","starred_url":"https://api.github.com/users/mer-packages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mer-packages/subscriptions","organizations_url":"https://api.github.com/users/mer-packages/orgs","repos_url":"https://api.github.com/users/mer-packages/repos","events_url":"https://api.github.com/users/mer-packages/events{/privacy}","received_events_url":"https://api.github.com/users/mer-packages/received_events","type":"Organization","site_admin":false},"repo":{"id":9514735,"name":"mkcal","full_name":"mer-packages/mkcal","owner":{"login":"mer-packages","id":3016659,"avatar_url":"https://avatars.githubusercontent.com/u/3016659?v=3","gravatar_id":"","url":"https://api.github.com/users/mer-packages","html_url":"https://github.com/mer-packages","followers_url":"https://api.github.com/users/mer-packages/followers","following_url":"https://api.github.com/users/mer-packages/following{/other_user}","gists_url":"https://api.github.com/users/mer-packages/gists{/gist_id}","starred_url":"https://api.github.com/users/mer-packages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mer-packages/subscriptions","organizations_url":"https://api.github.com/users/mer-packages/orgs","repos_url":"https://api.github.com/users/mer-packages/repos","events_url":"https://api.github.com/users/mer-packages/events{/privacy}","received_events_url":"https://api.github.com/users/mer-packages/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mer-packages/mkcal","description":"","fork":false,"url":"https://api.github.com/repos/mer-packages/mkcal","forks_url":"https://api.github.com/repos/mer-packages/mkcal/forks","keys_url":"https://api.github.com/repos/mer-packages/mkcal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mer-packages/mkcal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mer-packages/mkcal/teams","hooks_url":"https://api.github.com/repos/mer-packages/mkcal/hooks","issue_events_url":"https://api.github.com/repos/mer-packages/mkcal/issues/events{/number}","events_url":"https://api.github.com/repos/mer-packages/mkcal/events","assignees_url":"https://api.github.com/repos/mer-packages/mkcal/assignees{/user}","branches_url":"https://api.github.com/repos/mer-packages/mkcal/branches{/branch}","tags_url":"https://api.github.com/repos/mer-packages/mkcal/tags","blobs_url":"https://api.github.com/repos/mer-packages/mkcal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mer-packages/mkcal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mer-packages/mkcal/git/refs{/sha}","trees_url":"https://api.github.com/repos/mer-packages/mkcal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mer-packages/mkcal/statuses/{sha}","languages_url":"https://api.github.com/repos/mer-packages/mkcal/languages","stargazers_url":"https://api.github.com/repos/mer-packages/mkcal/stargazers","contributors_url":"https://api.github.com/repos/mer-packages/mkcal/contributors","subscribers_url":"https://api.github.com/repos/mer-packages/mkcal/subscribers","subscription_url":"https://api.github.com/repos/mer-packages/mkcal/subscription","commits_url":"https://api.github.com/repos/mer-packages/mkcal/commits{/sha}","git_commits_url":"https://api.github.com/repos/mer-packages/mkcal/git/commits{/sha}","comments_url":"https://api.github.com/repos/mer-packages/mkcal/comments{/number}","issue_comment_url":"https://api.github.com/repos/mer-packages/mkcal/issues/comments/{number}","contents_url":"https://api.github.com/repos/mer-packages/mkcal/contents/{+path}","compare_url":"https://api.github.com/repos/mer-packages/mkcal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mer-packages/mkcal/merges","archive_url":"https://api.github.com/repos/mer-packages/mkcal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mer-packages/mkcal/downloads","issues_url":"https://api.github.com/repos/mer-packages/mkcal/issues{/number}","pulls_url":"https://api.github.com/repos/mer-packages/mkcal/pulls{/number}","milestones_url":"https://api.github.com/repos/mer-packages/mkcal/milestones{/number}","notifications_url":"https://api.github.com/repos/mer-packages/mkcal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mer-packages/mkcal/labels{/name}","releases_url":"https://api.github.com/repos/mer-packages/mkcal/releases{/id}","created_at":"2013-04-18T06:03:44Z","updated_at":"2014-10-04T10:54:55Z","pushed_at":"2014-10-06T08:56:49Z","git_url":"git://github.com/mer-packages/mkcal.git","ssh_url":"git@github.com:mer-packages/mkcal.git","clone_url":"https://github.com/mer-packages/mkcal.git","svn_url":"https://github.com/mer-packages/mkcal","homepage":null,"size":1038,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":3,"forks":10,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mer-packages/mkcal/pulls/19"},"html":{"href":"https://github.com/mer-packages/mkcal/pull/19"},"issue":{"href":"https://api.github.com/repos/mer-packages/mkcal/issues/19"},"comments":{"href":"https://api.github.com/repos/mer-packages/mkcal/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/mer-packages/mkcal/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/mer-packages/mkcal/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mer-packages/mkcal/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/mer-packages/mkcal/statuses/d9e647a50253bd5f992aaf977b940f79606b70d6"}}}}