{"action":"created","comment":{"url":"https://api.github.com/repos/github/brubeck/pulls/comments/33923282","id":33923282,"diff_hunk":"@@ -48,28 +49,36 @@ static void statsd_run_recvmmsg(struct brubeck_statsd *statsd, int sock)\n \t\t\tcontinue;\n \t\t}\n \n-\t\t/* store stats */\n-\t\tbrubeck_atomic_add(&server->stats.metrics, SIM_PACKETS);\n-\t\tbrubeck_atomic_add(&statsd->sampler.inflow, SIM_PACKETS);\n-\n \t\tfor (i = 0; i < SIM_PACKETS; ++i) {\n-\t\t\tchar *buf = msgs[i].msg_hdr.msg_iov->iov_base;\n-\t\t\tint len = msgs[i].msg_len;\n-\n-\t\t\tif (brubeck_statsd_msg_parse(&msg, buf, len) < 0) {\n-\t\t\t\tif (msg.key_len > 0)\n-\t\t\t\t\tbuf[msg.key_len] = ':';\n-\n-\t\t\t\tlog_splunk(\"sampler=statsd event=bad_key key='%.*s'\", len, buf);\n-\n-\t\t\t\tbrubeck_server_mark_dropped(server);\n-\t\t\t\tcontinue;\n+\t\t\tchar *end = msgs[i].msg_hdr.msg_iov->iov_base + msgs[i].msg_len;\n+\t\t\t*end = '\\0';\n+\n+\t\t\tchar *tok;\n+\t\t\tchar *saveptr;\n+\t\t\ttok = strtok_r(msgs[i].msg_hdr.msg_iov->iov_base, \"\\n\", &saveptr);","path":"src/samplers/statsd.c","position":42,"original_position":42,"commit_id":"2886c12abf1d06021c49a869127461f94f9573c7","original_commit_id":"2886c12abf1d06021c49a869127461f94f9573c7","user":{"login":"vmg","id":42793,"avatar_url":"https://avatars.githubusercontent.com/u/42793?v=3","gravatar_id":"","url":"https://api.github.com/users/vmg","html_url":"https://github.com/vmg","followers_url":"https://api.github.com/users/vmg/followers","following_url":"https://api.github.com/users/vmg/following{/other_user}","gists_url":"https://api.github.com/users/vmg/gists{/gist_id}","starred_url":"https://api.github.com/users/vmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmg/subscriptions","organizations_url":"https://api.github.com/users/vmg/orgs","repos_url":"https://api.github.com/users/vmg/repos","events_url":"https://api.github.com/users/vmg/events{/privacy}","received_events_url":"https://api.github.com/users/vmg/received_events","type":"User","site_admin":true},"body":"This can be accomplished much easier with a `memchr` call, since `strtok` is an anypattern (even in the reentrant version), and you need to call `strlen` anyway on the buffer.","created_at":"2015-07-06T10:50:27Z","updated_at":"2015-07-06T10:50:27Z","html_url":"https://github.com/github/brubeck/pull/25#discussion_r33923282","pull_request_url":"https://api.github.com/repos/github/brubeck/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/github/brubeck/pulls/comments/33923282"},"html":{"href":"https://github.com/github/brubeck/pull/25#discussion_r33923282"},"pull_request":{"href":"https://api.github.com/repos/github/brubeck/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/github/brubeck/pulls/25","id":39171511,"html_url":"https://github.com/github/brubeck/pull/25","diff_url":"https://github.com/github/brubeck/pull/25.diff","patch_url":"https://github.com/github/brubeck/pull/25.patch","issue_url":"https://api.github.com/repos/github/brubeck/issues/25","number":25,"state":"open","locked":false,"title":"add support for multiple metrics in a single packet ","user":{"login":"goir","id":586209,"avatar_url":"https://avatars.githubusercontent.com/u/586209?v=3","gravatar_id":"","url":"https://api.github.com/users/goir","html_url":"https://github.com/goir","followers_url":"https://api.github.com/users/goir/followers","following_url":"https://api.github.com/users/goir/following{/other_user}","gists_url":"https://api.github.com/users/goir/gists{/gist_id}","starred_url":"https://api.github.com/users/goir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goir/subscriptions","organizations_url":"https://api.github.com/users/goir/orgs","repos_url":"https://api.github.com/users/goir/repos","events_url":"https://api.github.com/users/goir/events{/privacy}","received_events_url":"https://api.github.com/users/goir/received_events","type":"User","site_admin":false},"body":"add support for multiple metrics in a single packet separated by a newline character\r\n\r\nI'm no C expert, improvements are more than welcome. I've deployed it on our servers and its working fine. CPU load decreased by about 50% because of less packets to read or so :)\r\n\r\nfixes #16","created_at":"2015-07-03T12:29:38Z","updated_at":"2015-07-06T10:50:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da3b7f2c59b2fbcdfde4b2f7a297315d39a4c745","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/github/brubeck/pulls/25/commits","review_comments_url":"https://api.github.com/repos/github/brubeck/pulls/25/comments","review_comment_url":"https://api.github.com/repos/github/brubeck/pulls/comments{/number}","comments_url":"https://api.github.com/repos/github/brubeck/issues/25/comments","statuses_url":"https://api.github.com/repos/github/brubeck/statuses/2886c12abf1d06021c49a869127461f94f9573c7","head":{"label":"goir:support_multiple_one_packet","ref":"support_multiple_one_packet","sha":"2886c12abf1d06021c49a869127461f94f9573c7","user":{"login":"goir","id":586209,"avatar_url":"https://avatars.githubusercontent.com/u/586209?v=3","gravatar_id":"","url":"https://api.github.com/users/goir","html_url":"https://github.com/goir","followers_url":"https://api.github.com/users/goir/followers","following_url":"https://api.github.com/users/goir/following{/other_user}","gists_url":"https://api.github.com/users/goir/gists{/gist_id}","starred_url":"https://api.github.com/users/goir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goir/subscriptions","organizations_url":"https://api.github.com/users/goir/orgs","repos_url":"https://api.github.com/users/goir/repos","events_url":"https://api.github.com/users/goir/events{/privacy}","received_events_url":"https://api.github.com/users/goir/received_events","type":"User","site_admin":false},"repo":{"id":37771211,"name":"brubeck","full_name":"goir/brubeck","owner":{"login":"goir","id":586209,"avatar_url":"https://avatars.githubusercontent.com/u/586209?v=3","gravatar_id":"","url":"https://api.github.com/users/goir","html_url":"https://github.com/goir","followers_url":"https://api.github.com/users/goir/followers","following_url":"https://api.github.com/users/goir/following{/other_user}","gists_url":"https://api.github.com/users/goir/gists{/gist_id}","starred_url":"https://api.github.com/users/goir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goir/subscriptions","organizations_url":"https://api.github.com/users/goir/orgs","repos_url":"https://api.github.com/users/goir/repos","events_url":"https://api.github.com/users/goir/events{/privacy}","received_events_url":"https://api.github.com/users/goir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/goir/brubeck","description":"A Statsd-compatible metrics aggregator","fork":true,"url":"https://api.github.com/repos/goir/brubeck","forks_url":"https://api.github.com/repos/goir/brubeck/forks","keys_url":"https://api.github.com/repos/goir/brubeck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/goir/brubeck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/goir/brubeck/teams","hooks_url":"https://api.github.com/repos/goir/brubeck/hooks","issue_events_url":"https://api.github.com/repos/goir/brubeck/issues/events{/number}","events_url":"https://api.github.com/repos/goir/brubeck/events","assignees_url":"https://api.github.com/repos/goir/brubeck/assignees{/user}","branches_url":"https://api.github.com/repos/goir/brubeck/branches{/branch}","tags_url":"https://api.github.com/repos/goir/brubeck/tags","blobs_url":"https://api.github.com/repos/goir/brubeck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/goir/brubeck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/goir/brubeck/git/refs{/sha}","trees_url":"https://api.github.com/repos/goir/brubeck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/goir/brubeck/statuses/{sha}","languages_url":"https://api.github.com/repos/goir/brubeck/languages","stargazers_url":"https://api.github.com/repos/goir/brubeck/stargazers","contributors_url":"https://api.github.com/repos/goir/brubeck/contributors","subscribers_url":"https://api.github.com/repos/goir/brubeck/subscribers","subscription_url":"https://api.github.com/repos/goir/brubeck/subscription","commits_url":"https://api.github.com/repos/goir/brubeck/commits{/sha}","git_commits_url":"https://api.github.com/repos/goir/brubeck/git/commits{/sha}","comments_url":"https://api.github.com/repos/goir/brubeck/comments{/number}","issue_comment_url":"https://api.github.com/repos/goir/brubeck/issues/comments{/number}","contents_url":"https://api.github.com/repos/goir/brubeck/contents/{+path}","compare_url":"https://api.github.com/repos/goir/brubeck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/goir/brubeck/merges","archive_url":"https://api.github.com/repos/goir/brubeck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/goir/brubeck/downloads","issues_url":"https://api.github.com/repos/goir/brubeck/issues{/number}","pulls_url":"https://api.github.com/repos/goir/brubeck/pulls{/number}","milestones_url":"https://api.github.com/repos/goir/brubeck/milestones{/number}","notifications_url":"https://api.github.com/repos/goir/brubeck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/goir/brubeck/labels{/name}","releases_url":"https://api.github.com/repos/goir/brubeck/releases{/id}","created_at":"2015-06-20T13:42:07Z","updated_at":"2015-06-20T13:42:07Z","pushed_at":"2015-07-03T12:18:13Z","git_url":"git://github.com/goir/brubeck.git","ssh_url":"git@github.com:goir/brubeck.git","clone_url":"https://github.com/goir/brubeck.git","svn_url":"https://github.com/goir/brubeck","homepage":"","size":207,"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":"github:master","ref":"master","sha":"657498c47e0cabc6aaecc6e1b0db8b25e5c0be22","user":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"repo":{"id":37189021,"name":"brubeck","full_name":"github/brubeck","owner":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/github/brubeck","description":"A Statsd-compatible metrics aggregator","fork":false,"url":"https://api.github.com/repos/github/brubeck","forks_url":"https://api.github.com/repos/github/brubeck/forks","keys_url":"https://api.github.com/repos/github/brubeck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/brubeck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/brubeck/teams","hooks_url":"https://api.github.com/repos/github/brubeck/hooks","issue_events_url":"https://api.github.com/repos/github/brubeck/issues/events{/number}","events_url":"https://api.github.com/repos/github/brubeck/events","assignees_url":"https://api.github.com/repos/github/brubeck/assignees{/user}","branches_url":"https://api.github.com/repos/github/brubeck/branches{/branch}","tags_url":"https://api.github.com/repos/github/brubeck/tags","blobs_url":"https://api.github.com/repos/github/brubeck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/brubeck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/brubeck/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/brubeck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/brubeck/statuses/{sha}","languages_url":"https://api.github.com/repos/github/brubeck/languages","stargazers_url":"https://api.github.com/repos/github/brubeck/stargazers","contributors_url":"https://api.github.com/repos/github/brubeck/contributors","subscribers_url":"https://api.github.com/repos/github/brubeck/subscribers","subscription_url":"https://api.github.com/repos/github/brubeck/subscription","commits_url":"https://api.github.com/repos/github/brubeck/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/brubeck/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/brubeck/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/brubeck/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/brubeck/contents/{+path}","compare_url":"https://api.github.com/repos/github/brubeck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/brubeck/merges","archive_url":"https://api.github.com/repos/github/brubeck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/brubeck/downloads","issues_url":"https://api.github.com/repos/github/brubeck/issues{/number}","pulls_url":"https://api.github.com/repos/github/brubeck/pulls{/number}","milestones_url":"https://api.github.com/repos/github/brubeck/milestones{/number}","notifications_url":"https://api.github.com/repos/github/brubeck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/brubeck/labels{/name}","releases_url":"https://api.github.com/repos/github/brubeck/releases{/id}","created_at":"2015-06-10T09:51:42Z","updated_at":"2015-07-06T01:05:26Z","pushed_at":"2015-07-03T12:29:38Z","git_url":"git://github.com/github/brubeck.git","ssh_url":"git@github.com:github/brubeck.git","clone_url":"https://github.com/github/brubeck.git","svn_url":"https://github.com/github/brubeck","homepage":"","size":454,"stargazers_count":710,"watchers_count":710,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":3,"forks":16,"open_issues":3,"watchers":710,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/github/brubeck/pulls/25"},"html":{"href":"https://github.com/github/brubeck/pull/25"},"issue":{"href":"https://api.github.com/repos/github/brubeck/issues/25"},"comments":{"href":"https://api.github.com/repos/github/brubeck/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/github/brubeck/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/github/brubeck/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/github/brubeck/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/github/brubeck/statuses/2886c12abf1d06021c49a869127461f94f9573c7"}}}}