[
https://issues.apache.org/jira/browse/TS-3774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14632250#comment-14632250
]
Alan M. Carroll commented on TS-3774:
-------------------------------------
What I recommend at this point is double buffering the host file table. Instead
of having a current pointer, have a current and previous pointer and rotate new
tables through. Then the old table will stick around for a while so that any
references stay valid. Because HttpSM doesn't keep the pointers but copies them
out in the same event dispatch the old table doesn't have to stay around for
very long at all. If we presume the table is small (very likely) then it's a
low memory footprint and avoids all of the problems - pointer to static
returned, leakage, potentially dangling reference on reload. And it's very
simple to implement. If you did that, then you could not even {{new}} the
{{HostDBInfo}} elements but just directly embed in the {{std::map}}.
> Bug in HostDB hosts file implementation
> ---------------------------------------
>
> Key: TS-3774
> URL: https://issues.apache.org/jira/browse/TS-3774
> Project: Traffic Server
> Issue Type: Bug
> Components: HostDB
> Reporter: Brian Geffon
> Assignee: Alan M. Carroll
> Attachments: ts-3774.patch
>
>
> There is a bug in the current implementation of hostdb's use of hostsfiles.
> Because it uses a static local variable the storage is shared and ultimately
> will lead to race conditions if the hosts file is reloaded.
> {code}
> if (find_result != current_host_file_map->hosts_file_map.end()) {
> // TODO: Something to make this not local :/
> static HostDBInfo r;
> r.round_robin = false;
> r.round_robin_elt = false;
> r.reverse_dns = false;
> r.is_srv = false;
> ats_ip_set(r.ip(), (*find_result).second);
> return &r;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)