{"action":"created","comment":{"url":"https://api.github.com/repos/memcached/memcached/pulls/comments/67963693","id":67963693,"diff_hunk":"@@ -306,6 +308,89 @@ static int add_msghdr(conn *c)\n \n extern pthread_mutex_t conn_lock;\n \n+/* Connection timeout thread bits */\n+static pthread_t conn_timeout_tid;\n+\n+#define CONNS_PER_SLICE 100\n+#define TIMEOUT_MSG_SIZE (1 + sizeof(int))\n+static void *conn_timeout_thread(void *arg) {\n+    int i;\n+    conn *c;\n+    char buf[TIMEOUT_MSG_SIZE];\n+    rel_time_t oldest_last_cmd;\n+    int sleep_time;\n+    useconds_t timeslice = 1000000 / (max_fds / CONNS_PER_SLICE);\n+\n+","path":"memcached.c","position":33,"original_position":33,"commit_id":"c4c7c410a6f68d6cc4ec4cc2c4f9789461666152","original_commit_id":"c4c7c410a6f68d6cc4ec4cc2c4f9789461666152","user":{"login":"elfchief","id":2739199,"avatar_url":"https://avatars.githubusercontent.com/u/2739199?v=3","gravatar_id":"","url":"https://api.github.com/users/elfchief","html_url":"https://github.com/elfchief","followers_url":"https://api.github.com/users/elfchief/followers","following_url":"https://api.github.com/users/elfchief/following{/other_user}","gists_url":"https://api.github.com/users/elfchief/gists{/gist_id}","starred_url":"https://api.github.com/users/elfchief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elfchief/subscriptions","organizations_url":"https://api.github.com/users/elfchief/orgs","repos_url":"https://api.github.com/users/elfchief/repos","events_url":"https://api.github.com/users/elfchief/events{/privacy}","received_events_url":"https://api.github.com/users/elfchief/received_events","type":"User","site_admin":false},"body":"These are hand-crafted *artisan* newlines! :)","created_at":"2016-06-21T22:25:02Z","updated_at":"2016-06-21T22:25:02Z","html_url":"https://github.com/memcached/memcached/pull/80#discussion_r67963693","pull_request_url":"https://api.github.com/repos/memcached/memcached/pulls/80","_links":{"self":{"href":"https://api.github.com/repos/memcached/memcached/pulls/comments/67963693"},"html":{"href":"https://github.com/memcached/memcached/pull/80#discussion_r67963693"},"pull_request":{"href":"https://api.github.com/repos/memcached/memcached/pulls/80"}}},"pull_request":{"url":"https://api.github.com/repos/memcached/memcached/pulls/80","id":20715518,"html_url":"https://github.com/memcached/memcached/pull/80","diff_url":"https://github.com/memcached/memcached/pull/80.diff","patch_url":"https://github.com/memcached/memcached/pull/80.patch","issue_url":"https://api.github.com/repos/memcached/memcached/issues/80","number":80,"state":"open","locked":false,"title":"idle connection kicker using 'stats conns' and event notifier frameworks","user":{"login":"elfchief","id":2739199,"avatar_url":"https://avatars.githubusercontent.com/u/2739199?v=3","gravatar_id":"","url":"https://api.github.com/users/elfchief","html_url":"https://github.com/elfchief","followers_url":"https://api.github.com/users/elfchief/followers","following_url":"https://api.github.com/users/elfchief/following{/other_user}","gists_url":"https://api.github.com/users/elfchief/gists{/gist_id}","starred_url":"https://api.github.com/users/elfchief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elfchief/subscriptions","organizations_url":"https://api.github.com/users/elfchief/orgs","repos_url":"https://api.github.com/users/elfchief/repos","events_url":"https://api.github.com/users/elfchief/events{/privacy}","received_events_url":"https://api.github.com/users/elfchief/received_events","type":"User","site_admin":false},"body":"Still needs some cleanup and a stats counter, but submitting now for review. Could you please let me know if I'm missing anything obvious and that I'm following the suggested path for making this happen?\r\n\r\nPossible problems/issues/observations:\r\n\r\n1. it wasn't real obvious how many connections to do per run through the thread, or how long to sleep. I ended up picking an arbitrary number (100) and sleeping for enough time that it takes roughly 1 second to cycle through all the possible connections. This may be a bit heavyweight (we could probably get away with once per 10 seconds or once per minute)\r\n2. That number is just a #define right now. I don't really see much value in making it tunable at runtime, though.\r\n3. There might be a more efficient way to doing this by figuring out which connection would time out next, and then scanning the entire connection list to find a new one when that connection expires/updates, but that requires doing a full connection scan and probably a mutex'd variable that's checked on every command, plus is way more complex, so probably isn't worth it.\r\n4. Only works on idle (rather than stuck-in-transmission) connections. Not sure how hard it would be to make it kill 'active' connections too.","created_at":"2014-09-04T00:26:00Z","updated_at":"2016-06-21T22:25:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"050ac462bcedd5a443f4658f618b778ab420e623","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/memcached/memcached/pulls/80/commits","review_comments_url":"https://api.github.com/repos/memcached/memcached/pulls/80/comments","review_comment_url":"https://api.github.com/repos/memcached/memcached/pulls/comments{/number}","comments_url":"https://api.github.com/repos/memcached/memcached/issues/80/comments","statuses_url":"https://api.github.com/repos/memcached/memcached/statuses/c4c7c410a6f68d6cc4ec4cc2c4f9789461666152","head":{"label":"elfchief:idlekick","ref":"idlekick","sha":"c4c7c410a6f68d6cc4ec4cc2c4f9789461666152","user":{"login":"elfchief","id":2739199,"avatar_url":"https://avatars.githubusercontent.com/u/2739199?v=3","gravatar_id":"","url":"https://api.github.com/users/elfchief","html_url":"https://github.com/elfchief","followers_url":"https://api.github.com/users/elfchief/followers","following_url":"https://api.github.com/users/elfchief/following{/other_user}","gists_url":"https://api.github.com/users/elfchief/gists{/gist_id}","starred_url":"https://api.github.com/users/elfchief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elfchief/subscriptions","organizations_url":"https://api.github.com/users/elfchief/orgs","repos_url":"https://api.github.com/users/elfchief/repos","events_url":"https://api.github.com/users/elfchief/events{/privacy}","received_events_url":"https://api.github.com/users/elfchief/received_events","type":"User","site_admin":false},"repo":{"id":22862620,"name":"memcached","full_name":"elfchief/memcached","owner":{"login":"elfchief","id":2739199,"avatar_url":"https://avatars.githubusercontent.com/u/2739199?v=3","gravatar_id":"","url":"https://api.github.com/users/elfchief","html_url":"https://github.com/elfchief","followers_url":"https://api.github.com/users/elfchief/followers","following_url":"https://api.github.com/users/elfchief/following{/other_user}","gists_url":"https://api.github.com/users/elfchief/gists{/gist_id}","starred_url":"https://api.github.com/users/elfchief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elfchief/subscriptions","organizations_url":"https://api.github.com/users/elfchief/orgs","repos_url":"https://api.github.com/users/elfchief/repos","events_url":"https://api.github.com/users/elfchief/events{/privacy}","received_events_url":"https://api.github.com/users/elfchief/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/elfchief/memcached","description":"memcached development tree","fork":true,"url":"https://api.github.com/repos/elfchief/memcached","forks_url":"https://api.github.com/repos/elfchief/memcached/forks","keys_url":"https://api.github.com/repos/elfchief/memcached/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elfchief/memcached/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elfchief/memcached/teams","hooks_url":"https://api.github.com/repos/elfchief/memcached/hooks","issue_events_url":"https://api.github.com/repos/elfchief/memcached/issues/events{/number}","events_url":"https://api.github.com/repos/elfchief/memcached/events","assignees_url":"https://api.github.com/repos/elfchief/memcached/assignees{/user}","branches_url":"https://api.github.com/repos/elfchief/memcached/branches{/branch}","tags_url":"https://api.github.com/repos/elfchief/memcached/tags","blobs_url":"https://api.github.com/repos/elfchief/memcached/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elfchief/memcached/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elfchief/memcached/git/refs{/sha}","trees_url":"https://api.github.com/repos/elfchief/memcached/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elfchief/memcached/statuses/{sha}","languages_url":"https://api.github.com/repos/elfchief/memcached/languages","stargazers_url":"https://api.github.com/repos/elfchief/memcached/stargazers","contributors_url":"https://api.github.com/repos/elfchief/memcached/contributors","subscribers_url":"https://api.github.com/repos/elfchief/memcached/subscribers","subscription_url":"https://api.github.com/repos/elfchief/memcached/subscription","commits_url":"https://api.github.com/repos/elfchief/memcached/commits{/sha}","git_commits_url":"https://api.github.com/repos/elfchief/memcached/git/commits{/sha}","comments_url":"https://api.github.com/repos/elfchief/memcached/comments{/number}","issue_comment_url":"https://api.github.com/repos/elfchief/memcached/issues/comments{/number}","contents_url":"https://api.github.com/repos/elfchief/memcached/contents/{+path}","compare_url":"https://api.github.com/repos/elfchief/memcached/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elfchief/memcached/merges","archive_url":"https://api.github.com/repos/elfchief/memcached/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elfchief/memcached/downloads","issues_url":"https://api.github.com/repos/elfchief/memcached/issues{/number}","pulls_url":"https://api.github.com/repos/elfchief/memcached/pulls{/number}","milestones_url":"https://api.github.com/repos/elfchief/memcached/milestones{/number}","notifications_url":"https://api.github.com/repos/elfchief/memcached/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elfchief/memcached/labels{/name}","releases_url":"https://api.github.com/repos/elfchief/memcached/releases{/id}","deployments_url":"https://api.github.com/repos/elfchief/memcached/deployments","created_at":"2014-08-12T02:50:34Z","updated_at":"2016-06-17T20:27:31Z","pushed_at":"2016-06-17T20:44:34Z","git_url":"git://github.com/elfchief/memcached.git","ssh_url":"git@github.com:elfchief/memcached.git","clone_url":"https://github.com/elfchief/memcached.git","svn_url":"https://github.com/elfchief/memcached","homepage":"http://code.google.com/p/memcached/","size":6926,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"memcached:master","ref":"master","sha":"4267ed80477b7b56675d4fdbb549b383f2ef13f2","user":{"login":"memcached","id":41836,"avatar_url":"https://avatars.githubusercontent.com/u/41836?v=3","gravatar_id":"","url":"https://api.github.com/users/memcached","html_url":"https://github.com/memcached","followers_url":"https://api.github.com/users/memcached/followers","following_url":"https://api.github.com/users/memcached/following{/other_user}","gists_url":"https://api.github.com/users/memcached/gists{/gist_id}","starred_url":"https://api.github.com/users/memcached/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/memcached/subscriptions","organizations_url":"https://api.github.com/users/memcached/orgs","repos_url":"https://api.github.com/users/memcached/repos","events_url":"https://api.github.com/users/memcached/events{/privacy}","received_events_url":"https://api.github.com/users/memcached/received_events","type":"Organization","site_admin":false},"repo":{"id":184981,"name":"memcached","full_name":"memcached/memcached","owner":{"login":"memcached","id":41836,"avatar_url":"https://avatars.githubusercontent.com/u/41836?v=3","gravatar_id":"","url":"https://api.github.com/users/memcached","html_url":"https://github.com/memcached","followers_url":"https://api.github.com/users/memcached/followers","following_url":"https://api.github.com/users/memcached/following{/other_user}","gists_url":"https://api.github.com/users/memcached/gists{/gist_id}","starred_url":"https://api.github.com/users/memcached/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/memcached/subscriptions","organizations_url":"https://api.github.com/users/memcached/orgs","repos_url":"https://api.github.com/users/memcached/repos","events_url":"https://api.github.com/users/memcached/events{/privacy}","received_events_url":"https://api.github.com/users/memcached/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/memcached/memcached","description":"memcached development tree","fork":false,"url":"https://api.github.com/repos/memcached/memcached","forks_url":"https://api.github.com/repos/memcached/memcached/forks","keys_url":"https://api.github.com/repos/memcached/memcached/keys{/key_id}","collaborators_url":"https://api.github.com/repos/memcached/memcached/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/memcached/memcached/teams","hooks_url":"https://api.github.com/repos/memcached/memcached/hooks","issue_events_url":"https://api.github.com/repos/memcached/memcached/issues/events{/number}","events_url":"https://api.github.com/repos/memcached/memcached/events","assignees_url":"https://api.github.com/repos/memcached/memcached/assignees{/user}","branches_url":"https://api.github.com/repos/memcached/memcached/branches{/branch}","tags_url":"https://api.github.com/repos/memcached/memcached/tags","blobs_url":"https://api.github.com/repos/memcached/memcached/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/memcached/memcached/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/memcached/memcached/git/refs{/sha}","trees_url":"https://api.github.com/repos/memcached/memcached/git/trees{/sha}","statuses_url":"https://api.github.com/repos/memcached/memcached/statuses/{sha}","languages_url":"https://api.github.com/repos/memcached/memcached/languages","stargazers_url":"https://api.github.com/repos/memcached/memcached/stargazers","contributors_url":"https://api.github.com/repos/memcached/memcached/contributors","subscribers_url":"https://api.github.com/repos/memcached/memcached/subscribers","subscription_url":"https://api.github.com/repos/memcached/memcached/subscription","commits_url":"https://api.github.com/repos/memcached/memcached/commits{/sha}","git_commits_url":"https://api.github.com/repos/memcached/memcached/git/commits{/sha}","comments_url":"https://api.github.com/repos/memcached/memcached/comments{/number}","issue_comment_url":"https://api.github.com/repos/memcached/memcached/issues/comments{/number}","contents_url":"https://api.github.com/repos/memcached/memcached/contents/{+path}","compare_url":"https://api.github.com/repos/memcached/memcached/compare/{base}...{head}","merges_url":"https://api.github.com/repos/memcached/memcached/merges","archive_url":"https://api.github.com/repos/memcached/memcached/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/memcached/memcached/downloads","issues_url":"https://api.github.com/repos/memcached/memcached/issues{/number}","pulls_url":"https://api.github.com/repos/memcached/memcached/pulls{/number}","milestones_url":"https://api.github.com/repos/memcached/memcached/milestones{/number}","notifications_url":"https://api.github.com/repos/memcached/memcached/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/memcached/memcached/labels{/name}","releases_url":"https://api.github.com/repos/memcached/memcached/releases{/id}","deployments_url":"https://api.github.com/repos/memcached/memcached/deployments","created_at":"2009-04-24T23:34:25Z","updated_at":"2016-06-21T20:51:14Z","pushed_at":"2016-06-21T01:12:54Z","git_url":"git://github.com/memcached/memcached.git","ssh_url":"git@github.com:memcached/memcached.git","clone_url":"https://github.com/memcached/memcached.git","svn_url":"https://github.com/memcached/memcached","homepage":"http://code.google.com/p/memcached/","size":8176,"stargazers_count":4848,"watchers_count":4848,"language":"C","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":1706,"mirror_url":null,"open_issues_count":18,"forks":1706,"open_issues":18,"watchers":4848,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/memcached/memcached/pulls/80"},"html":{"href":"https://github.com/memcached/memcached/pull/80"},"issue":{"href":"https://api.github.com/repos/memcached/memcached/issues/80"},"comments":{"href":"https://api.github.com/repos/memcached/memcached/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/memcached/memcached/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/memcached/memcached/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/memcached/memcached/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/memcached/memcached/statuses/c4c7c410a6f68d6cc4ec4cc2c4f9789461666152"}}}}
{"actor":{"display_login":"elfchief"}}