Github user jacksontj commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/240#discussion_r33837875 --- Diff: iocore/hostdb/HostDB.cc --- @@ -2833,15 +2650,8 @@ ParseHostFile(char const *path) } } - if (!HostFilePairs.empty()) { - // Need to sort by name so multiple address hosts are - // contiguous. - std::sort(HostFilePairs.begin(), HostFilePairs.end(), &CmpHostFilePair); - HostDBFileContinuation::scheduleUpdate(0); - } else if (!HostFileKeys.empty()) { - HostDBFileContinuation::scheduleRemove(-1, 0); - } else { - // Nothing in new data, nothing in old data, just clean up. - HostDBFileContinuation::finish(0); - } + // Swap out hostDB's map for ours + hostDB.hosts_file_ptr = parsed_hosts_file_ptr; + // Make a new map, so we can do it all again + parsed_hosts_file_ptr = new RefCountedHostsFileMap(); --- End diff -- Not to be a nuisance, but why is it more clear? The comment says exactly what its doing ;) On Thu, Jul 2, 2015 at 7:08 PM, Brian Geffon <notificati...@github.com> wrote: > In iocore/hostdb/HostDB.cc > <https://github.com/apache/trafficserver/pull/240#discussion_r33836997>: > > > @@ -2833,15 +2650,8 @@ ParseHostFile(char const *path) > > } > > } > > > > - if (!HostFilePairs.empty()) { > > - // Need to sort by name so multiple address hosts are > > - // contiguous. > > - std::sort(HostFilePairs.begin(), HostFilePairs.end(), &CmpHostFilePair); > > - HostDBFileContinuation::scheduleUpdate(0); > > - } else if (!HostFileKeys.empty()) { > > - HostDBFileContinuation::scheduleRemove(-1, 0); > > - } else { > > - // Nothing in new data, nothing in old data, just clean up. > > - HostDBFileContinuation::finish(0); > > - } > > + // Swap out hostDB's map for ours > > + hostDB.hosts_file_ptr = parsed_hosts_file_ptr; > > + // Make a new map, so we can do it all again > > + parsed_hosts_file_ptr = new RefCountedHostsFileMap(); > > I had the same question when I saw that, and it's likely others will > wonder the same thing looking at this code in the future. It might be > clearer if you do it at the start rather than at the completion of parsing. > > â > Reply to this email directly or view it on GitHub > <https://github.com/apache/trafficserver/pull/240/files#r33836997>. >
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---