Skip to content

Commit

Permalink
fix dataraces by aws#102
Browse files Browse the repository at this point in the history
  • Loading branch information
t-yuki committed Apr 4, 2019
1 parent 17591b3 commit f035196
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions xray/httptrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (xt *HTTPSubsegments) GetConn(hostPort string) {
// DNSStart begins a dns subsegment if the HTTP operation
// subsegment is still in progress.
func (xt *HTTPSubsegments) DNSStart(info httptrace.DNSStartInfo) {
xt.mu.Lock()
defer xt.mu.Unlock()
if GetSegment(xt.opCtx).safeInProgress() && xt.connCtx != nil {
xt.dnsCtx, _ = BeginSubsegment(xt.connCtx, "dns")
}
Expand Down
4 changes: 4 additions & 0 deletions xray/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ func (seg *Segment) RemoveSubsegment(remove *Segment) bool {
seg.rawSubsegments[len(seg.rawSubsegments)-1] = nil
seg.rawSubsegments = seg.rawSubsegments[:len(seg.rawSubsegments)-1]

if seg.ParentSegment != seg {
seg.ParentSegment.Lock()
defer seg.ParentSegment.Unlock()
}
seg.ParentSegment.totalSubSegments--
seg.openSegments--
return true
Expand Down

0 comments on commit f035196

Please sign in to comment.