{"action":"created","comment":{"url":"https://api.github.com/repos/apache/trafficserver/pulls/comments/33837875","id":33837875,"diff_hunk":"@@ -2833,15 +2650,8 @@ ParseHostFile(char const *path)\n     }\n   }\n \n-  if (!HostFilePairs.empty()) {\n-    // Need to sort by name so multiple address hosts are\n-    // contiguous.\n-    std::sort(HostFilePairs.begin(), HostFilePairs.end(), &CmpHostFilePair);\n-    HostDBFileContinuation::scheduleUpdate(0);\n-  } else if (!HostFileKeys.empty()) {\n-    HostDBFileContinuation::scheduleRemove(-1, 0);\n-  } else {\n-    // Nothing in new data, nothing in old data, just clean up.\n-    HostDBFileContinuation::finish(0);\n-  }\n+  // Swap out hostDB's map for ours\n+  hostDB.hosts_file_ptr = parsed_hosts_file_ptr;\n+  // Make a new map, so we can do it all again\n+  parsed_hosts_file_ptr = new RefCountedHostsFileMap();","path":"iocore/hostdb/HostDB.cc","position":395,"original_position":294,"commit_id":"b17ac79db78a2e97a26dc99917417b727cd1622e","original_commit_id":"9ba4f230494e3fbe372ed1bbd431413578a90ca1","user":{"login":"jacksontj","id":1619869,"avatar_url":"https://avatars.githubusercontent.com/u/1619869?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksontj","html_url":"https://github.com/jacksontj","followers_url":"https://api.github.com/users/jacksontj/followers","following_url":"https://api.github.com/users/jacksontj/following{/other_user}","gists_url":"https://api.github.com/users/jacksontj/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksontj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksontj/subscriptions","organizations_url":"https://api.github.com/users/jacksontj/orgs","repos_url":"https://api.github.com/users/jacksontj/repos","events_url":"https://api.github.com/users/jacksontj/events{/privacy}","received_events_url":"https://api.github.com/users/jacksontj/received_events","type":"User","site_admin":false},"body":"Not to be a nuisance, but why is it more clear? The comment says exactly\nwhat its doing ;)\n\nOn Thu, Jul 2, 2015 at 7:08 PM, Brian Geffon <notifications@github.com>\nwrote:\n\n> In iocore/hostdb/HostDB.cc\n> <https://github.com/apache/trafficserver/pull/240#discussion_r33836997>:\n>\n> > @@ -2833,15 +2650,8 @@ ParseHostFile(char const *path)\n> >      }\n> >    }\n> >\n> > -  if (!HostFilePairs.empty()) {\n> > -    // Need to sort by name so multiple address hosts are\n> > -    // contiguous.\n> > -    std::sort(HostFilePairs.begin(), HostFilePairs.end(), &CmpHostFilePair);\n> > -    HostDBFileContinuation::scheduleUpdate(0);\n> > -  } else if (!HostFileKeys.empty()) {\n> > -    HostDBFileContinuation::scheduleRemove(-1, 0);\n> > -  } else {\n> > -    // Nothing in new data, nothing in old data, just clean up.\n> > -    HostDBFileContinuation::finish(0);\n> > -  }\n> > +  // Swap out hostDB's map for ours\n> > +  hostDB.hosts_file_ptr = parsed_hosts_file_ptr;\n> > +  // Make a new map, so we can do it all again\n> > +  parsed_hosts_file_ptr = new RefCountedHostsFileMap();\n>\n> I had the same question when I saw that, and it's likely others will\n> wonder the same thing looking at this code in the future. It might be\n> clearer if you do it at the start rather than at the completion of parsing.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/apache/trafficserver/pull/240/files#r33836997>.\n>\n","created_at":"2015-07-03T02:48:38Z","updated_at":"2015-07-03T02:48:38Z","html_url":"https://github.com/apache/trafficserver/pull/240#discussion_r33837875","pull_request_url":"https://api.github.com/repos/apache/trafficserver/pulls/240","_links":{"self":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/comments/33837875"},"html":{"href":"https://github.com/apache/trafficserver/pull/240#discussion_r33837875"},"pull_request":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/240"}}},"pull_request":{"url":"https://api.github.com/repos/apache/trafficserver/pulls/240","id":39036821,"html_url":"https://github.com/apache/trafficserver/pull/240","diff_url":"https://github.com/apache/trafficserver/pull/240.diff","patch_url":"https://github.com/apache/trafficserver/pull/240.patch","issue_url":"https://api.github.com/repos/apache/trafficserver/issues/240","number":240,"state":"open","locked":false,"title":"Maintain and use a mapping of hostname -> IP to implement host file support","user":{"login":"jacksontj","id":1619869,"avatar_url":"https://avatars.githubusercontent.com/u/1619869?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksontj","html_url":"https://github.com/jacksontj","followers_url":"https://api.github.com/users/jacksontj/followers","following_url":"https://api.github.com/users/jacksontj/following{/other_user}","gists_url":"https://api.github.com/users/jacksontj/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksontj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksontj/subscriptions","organizations_url":"https://api.github.com/users/jacksontj/orgs","repos_url":"https://api.github.com/users/jacksontj/repos","events_url":"https://api.github.com/users/jacksontj/events{/privacy}","received_events_url":"https://api.github.com/users/jacksontj/received_events","type":"User","site_admin":false},"body":"This allows the background thread to populate a map of overrides, which we simply inject in the lookup method-- in place of calling to DNS.\r\n\r\nI'm sure this implementation is riddled with holes, but it works in the most basic of cases. Pointers to get it cleaned up are much appreciated :)","created_at":"2015-07-01T23:54:47Z","updated_at":"2015-07-03T02:48:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12b718e7fb214fa5f7c0a2cafee8da42ce4184bd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/trafficserver/pulls/240/commits","review_comments_url":"https://api.github.com/repos/apache/trafficserver/pulls/240/comments","review_comment_url":"https://api.github.com/repos/apache/trafficserver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/trafficserver/issues/240/comments","statuses_url":"https://api.github.com/repos/apache/trafficserver/statuses/b17ac79db78a2e97a26dc99917417b727cd1622e","head":{"label":"jacksontj:master","ref":"master","sha":"b17ac79db78a2e97a26dc99917417b727cd1622e","user":{"login":"jacksontj","id":1619869,"avatar_url":"https://avatars.githubusercontent.com/u/1619869?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksontj","html_url":"https://github.com/jacksontj","followers_url":"https://api.github.com/users/jacksontj/followers","following_url":"https://api.github.com/users/jacksontj/following{/other_user}","gists_url":"https://api.github.com/users/jacksontj/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksontj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksontj/subscriptions","organizations_url":"https://api.github.com/users/jacksontj/orgs","repos_url":"https://api.github.com/users/jacksontj/repos","events_url":"https://api.github.com/users/jacksontj/events{/privacy}","received_events_url":"https://api.github.com/users/jacksontj/received_events","type":"User","site_admin":false},"repo":{"id":14320413,"name":"trafficserver","full_name":"jacksontj/trafficserver","owner":{"login":"jacksontj","id":1619869,"avatar_url":"https://avatars.githubusercontent.com/u/1619869?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksontj","html_url":"https://github.com/jacksontj","followers_url":"https://api.github.com/users/jacksontj/followers","following_url":"https://api.github.com/users/jacksontj/following{/other_user}","gists_url":"https://api.github.com/users/jacksontj/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksontj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksontj/subscriptions","organizations_url":"https://api.github.com/users/jacksontj/orgs","repos_url":"https://api.github.com/users/jacksontj/repos","events_url":"https://api.github.com/users/jacksontj/events{/privacy}","received_events_url":"https://api.github.com/users/jacksontj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacksontj/trafficserver","description":"Mirror of Apache Traffic Server","fork":true,"url":"https://api.github.com/repos/jacksontj/trafficserver","forks_url":"https://api.github.com/repos/jacksontj/trafficserver/forks","keys_url":"https://api.github.com/repos/jacksontj/trafficserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacksontj/trafficserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacksontj/trafficserver/teams","hooks_url":"https://api.github.com/repos/jacksontj/trafficserver/hooks","issue_events_url":"https://api.github.com/repos/jacksontj/trafficserver/issues/events{/number}","events_url":"https://api.github.com/repos/jacksontj/trafficserver/events","assignees_url":"https://api.github.com/repos/jacksontj/trafficserver/assignees{/user}","branches_url":"https://api.github.com/repos/jacksontj/trafficserver/branches{/branch}","tags_url":"https://api.github.com/repos/jacksontj/trafficserver/tags","blobs_url":"https://api.github.com/repos/jacksontj/trafficserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacksontj/trafficserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacksontj/trafficserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacksontj/trafficserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacksontj/trafficserver/statuses/{sha}","languages_url":"https://api.github.com/repos/jacksontj/trafficserver/languages","stargazers_url":"https://api.github.com/repos/jacksontj/trafficserver/stargazers","contributors_url":"https://api.github.com/repos/jacksontj/trafficserver/contributors","subscribers_url":"https://api.github.com/repos/jacksontj/trafficserver/subscribers","subscription_url":"https://api.github.com/repos/jacksontj/trafficserver/subscription","commits_url":"https://api.github.com/repos/jacksontj/trafficserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacksontj/trafficserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacksontj/trafficserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacksontj/trafficserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacksontj/trafficserver/contents/{+path}","compare_url":"https://api.github.com/repos/jacksontj/trafficserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacksontj/trafficserver/merges","archive_url":"https://api.github.com/repos/jacksontj/trafficserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacksontj/trafficserver/downloads","issues_url":"https://api.github.com/repos/jacksontj/trafficserver/issues{/number}","pulls_url":"https://api.github.com/repos/jacksontj/trafficserver/pulls{/number}","milestones_url":"https://api.github.com/repos/jacksontj/trafficserver/milestones{/number}","notifications_url":"https://api.github.com/repos/jacksontj/trafficserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacksontj/trafficserver/labels{/name}","releases_url":"https://api.github.com/repos/jacksontj/trafficserver/releases{/id}","created_at":"2013-11-12T02:49:24Z","updated_at":"2015-05-01T02:49:11Z","pushed_at":"2015-07-03T01:26:50Z","git_url":"git://github.com/jacksontj/trafficserver.git","ssh_url":"git@github.com:jacksontj/trafficserver.git","clone_url":"https://github.com/jacksontj/trafficserver.git","svn_url":"https://github.com/jacksontj/trafficserver","homepage":null,"size":46228,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"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":"apache:master","ref":"master","sha":"ee446f9c42ece4bb0e6a7fe4a08d17f367a0a352","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":356066,"name":"trafficserver","full_name":"apache/trafficserver","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/trafficserver","description":"Mirror of Apache Traffic Server","fork":false,"url":"https://api.github.com/repos/apache/trafficserver","forks_url":"https://api.github.com/repos/apache/trafficserver/forks","keys_url":"https://api.github.com/repos/apache/trafficserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/trafficserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/trafficserver/teams","hooks_url":"https://api.github.com/repos/apache/trafficserver/hooks","issue_events_url":"https://api.github.com/repos/apache/trafficserver/issues/events{/number}","events_url":"https://api.github.com/repos/apache/trafficserver/events","assignees_url":"https://api.github.com/repos/apache/trafficserver/assignees{/user}","branches_url":"https://api.github.com/repos/apache/trafficserver/branches{/branch}","tags_url":"https://api.github.com/repos/apache/trafficserver/tags","blobs_url":"https://api.github.com/repos/apache/trafficserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/trafficserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/trafficserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/trafficserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/trafficserver/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/trafficserver/languages","stargazers_url":"https://api.github.com/repos/apache/trafficserver/stargazers","contributors_url":"https://api.github.com/repos/apache/trafficserver/contributors","subscribers_url":"https://api.github.com/repos/apache/trafficserver/subscribers","subscription_url":"https://api.github.com/repos/apache/trafficserver/subscription","commits_url":"https://api.github.com/repos/apache/trafficserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/trafficserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/trafficserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/trafficserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/trafficserver/contents/{+path}","compare_url":"https://api.github.com/repos/apache/trafficserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/trafficserver/merges","archive_url":"https://api.github.com/repos/apache/trafficserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/trafficserver/downloads","issues_url":"https://api.github.com/repos/apache/trafficserver/issues{/number}","pulls_url":"https://api.github.com/repos/apache/trafficserver/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/trafficserver/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/trafficserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/trafficserver/labels{/name}","releases_url":"https://api.github.com/repos/apache/trafficserver/releases{/id}","created_at":"2009-10-31T08:00:10Z","updated_at":"2015-07-02T01:53:56Z","pushed_at":"2015-07-03T01:26:50Z","git_url":"git://github.com/apache/trafficserver.git","ssh_url":"git@github.com:apache/trafficserver.git","clone_url":"https://github.com/apache/trafficserver.git","svn_url":"https://github.com/apache/trafficserver","homepage":null,"size":68639,"stargazers_count":296,"watchers_count":296,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":201,"mirror_url":"git://git.apache.org/trafficserver.git","open_issues_count":20,"forks":201,"open_issues":20,"watchers":296,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/240"},"html":{"href":"https://github.com/apache/trafficserver/pull/240"},"issue":{"href":"https://api.github.com/repos/apache/trafficserver/issues/240"},"comments":{"href":"https://api.github.com/repos/apache/trafficserver/issues/240/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/240/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/240/commits"},"statuses":{"href":"https://api.github.com/repos/apache/trafficserver/statuses/b17ac79db78a2e97a26dc99917417b727cd1622e"}}}}