Merge pull request #60 from FyZhu97/bugfix/inflightRequest-deadlock

[bugfix] fix inflightRequestLock deadlock in tcp/udp tracing
This commit is contained in:
tsosunchia
2024-07-15 19:01:11 +08:00
committed by GitHub
3 changed files with 3 additions and 3 deletions

View File

@@ -264,7 +264,7 @@ func (t *TCPTracer) send(ttl int) error {
return err
}
t.inflightRequestLock.Lock()
hopCh := make(chan Hop)
hopCh := make(chan Hop, 1)
t.inflightRequest[int(sequenceNumber)] = hopCh
t.inflightRequestLock.Unlock()
/*

View File

@@ -251,7 +251,7 @@ func (t *TCPTracerv6) send(ttl int) error {
}
// log.Println(ttl, sequenceNumber)
t.inflightRequestLock.Lock()
hopCh := make(chan Hop)
hopCh := make(chan Hop, 1)
t.inflightRequest[int(sequenceNumber)] = hopCh
t.inflightRequestLock.Unlock()

View File

@@ -225,7 +225,7 @@ func (t *UDPTracer) send(ttl int) error {
// 在对inflightRequest进行写操作的时候应该加锁保护以免多个goroutine协程试图同时写入造成panic
t.inflightRequestLock.Lock()
hopCh := make(chan Hop)
hopCh := make(chan Hop, 1)
t.inflightRequest[srcPort] = hopCh
t.inflightRequestLock.Unlock()
defer func() {