Skip to content

Commit

Permalink
Fix: mutex deadlock (#393)
Browse files Browse the repository at this point in the history
Co-authored-by: Prashant Srivastava <50466688+srprash@users.noreply.github.com>
  • Loading branch information
nikolaianohyn and srprash authored Jan 31, 2023
1 parent bd15b17 commit 7df7dc4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xray/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,21 @@ func (seg *Segment) CloseAndStream(err error) {
if SdkDisabled() {
return
}

seg.Lock()
defer seg.Unlock()


if seg.parent != nil {
logger.Debugf("Ending subsegment named: %s", seg.Name)
seg.Lock()
seg.EndTime = float64(time.Now().UnixNano()) / float64(time.Second)
seg.InProgress = false
seg.Emitted = true
seg.Unlock()
if seg.parent.RemoveSubsegment(seg) {
logger.Debugf("Removing subsegment named: %s", seg.Name)
}
}

seg.Lock()
defer seg.Unlock()

if err != nil {
seg.addError(err)
Expand Down

0 comments on commit 7df7dc4

Please sign in to comment.