Github user jpeach commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/653#discussion_r66907362 --- Diff: iocore/hostdb/I_HostDBProcessor.h --- @@ -139,10 +141,62 @@ struct SRVInfo { unsigned int key; }; -struct HostDBInfo { +struct HostDBInfo : public RefCountObj { /** Internal IP address data. This is at least large enough to hold an IPv6 address. */ + + int iobuffer_index; + static HostDBInfo * + alloc(int size = 0) + { + size += sizeof(HostDBInfo); + int iobuffer_index = iobuffer_size_to_index(size); + ink_release_assert(iobuffer_index >= 0); + void *ptr = ioBufAllocator[iobuffer_index].alloc_void(); + memset(ptr, 0, size); + HostDBInfo *ret = new (ptr) HostDBInfo(); + ret->iobuffer_index = iobuffer_index; + return ret; + } + + void + free() + { + ioBufAllocator[iobuffer_index].free_void((void *)(this)); + } + + // return a version number-- so we can manage compatibility with the marshal/unmarshal + static VersionNumber + version() + { + return VersionNumber(1, 0); + } + + static HostDBInfo * + unmarshall(char *buf, unsigned int size) + { + if (size < sizeof(HostDBInfo)) { + return NULL; + } + HostDBInfo *ret = HostDBInfo::alloc(size - sizeof(HostDBInfo)); + int buf_index = ret->iobuffer_index; + memcpy((void *)ret, buf, size); + // Reset the refcount back to 0, this is a bit ugly-- but I'm not sure we want to expose a method + // to mess with the refcount, since this is a fairly unique use case + ret = new (ret) HostDBInfo(); --- End diff -- You allocated ``sizeof(HostDBInfo)`` less than the given size, then put a ``HostDBInfo`` into it after all? Can you comment what is going on there?
--- 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. ---