• Emmanuel T Odeke's avatar
    net: preserve unexpired context values for LookupIPAddr · 5d392600
    Emmanuel T Odeke authored
    To avoid any cancelation of the parent context from affecting
    lookupGroup operations, Resolver.LookupIPAddr previously used
    an entirely new context created from context.Background().
    However, this meant that all the values in the parent context
    with which LookupIPAddr was invoked were dropped.
    
    This change provides a custom context implementation
    that only preserves values of the parent context by composing
    context.Background() and the parent context. It only falls back
    to the parent context to perform value lookups if the parent
    context has not yet expired.
    This context is never canceled, and has no deadlines.
    
    Fixes #28600
    
    Change-Id: If2f570caa26c65bad638b7102c35c79d5e429fea
    Reviewed-on: https://go-review.googlesource.com/c/148698
    Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    5d392600
lookup.go 15.4 KB