{"action":"opened","issue":{"url":"https://api.github.com/repos/bcosca/fatfree-core/issues/157","repository_url":"https://api.github.com/repos/bcosca/fatfree-core","labels_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/157/comments","events_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/157/events","html_url":"https://github.com/bcosca/fatfree-core/issues/157","id":181629347,"number":157,"title":"Suggestion: unlink mutex lock files on exceptions","user":{"login":"Kallys","id":1195845,"avatar_url":"https://avatars.githubusercontent.com/u/1195845?v=3","gravatar_id":"","url":"https://api.github.com/users/Kallys","html_url":"https://github.com/Kallys","followers_url":"https://api.github.com/users/Kallys/followers","following_url":"https://api.github.com/users/Kallys/following{/other_user}","gists_url":"https://api.github.com/users/Kallys/gists{/gist_id}","starred_url":"https://api.github.com/users/Kallys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kallys/subscriptions","organizations_url":"https://api.github.com/users/Kallys/orgs","repos_url":"https://api.github.com/users/Kallys/repos","events_url":"https://api.github.com/users/Kallys/events{/privacy}","received_events_url":"https://api.github.com/users/Kallys/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-07T09:59:05Z","updated_at":"2016-10-07T09:59:05Z","closed_at":null,"body":"Hey guys !\r\n\r\nSuch a good framework fatfree is, and I'm using it a lot for many private projects : thanks !\r\n\r\nToday I want to share you a thought about fatfree mutex.\r\nMaybe I'm doing something wrong, but in that case I'm open for advices !\r\n\r\nSo, here is my problem. Even if I'm trying to avoid it as much as possible, my mutex callback functions may throw exceptions. And if an exception occurs inside the mutex callback, whether I catch it or not, the lock file will remains inside the temp folder.\r\n\r\n```php\r\ntry{\r\n\t\\Base::instance()->mutex($mutex_id, function() {\r\n\t\tthrow new \\Exception('Error!');\r\n\t});\r\n}\r\ncatch (\\Exception $e)\r\n{\r\n\t// Handle error\r\n}\r\n\r\n// Here mutex lock file still exists\r\n```\r\n\r\nI've used few workarounds to manage those cases, but today I'm wondering if it is not a good idea to make fatfree handle it itself ?\r\n\r\nFew suggestions here:\r\n\r\n1. Add a try/catch block around the call method inside mutex method in order to unlink lock file on exception before rethrowing the exception\r\n2. Maintain a list of open lock files in hive and unlink them inside unload callback\r\n\r\nPlease let me know what you think about this!\r\n\r\nThanks,\r\nK."}}
{"actor":{"display_login":"Kallys"}}