mirror of
https://github.com/go-i2p/go-sam-go.git
synced 2025-06-07 17:05:04 -04:00
Fix close race in DatagramSession
This commit is contained in:
@ -2,7 +2,6 @@ package raw
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
@ -97,8 +96,3 @@ func (rs *RawSession) DialI2PContext(ctx context.Context, addr i2pkeys.I2PAddr)
|
||||
logger.WithField("session_id", rs.ID()).Debug("Successfully created I2P raw connection")
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
// generateSessionID generates a unique session identifier
|
||||
func generateSessionID() string {
|
||||
return fmt.Sprintf("raw_%d", time.Now().UnixNano())
|
||||
}
|
||||
|
@ -39,7 +39,12 @@ func (r *RawReader) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
logger := log.WithField("session_id", r.session.ID())
|
||||
// Fix: Safe session ID retrieval with nil checks
|
||||
sessionID := "unknown"
|
||||
if r.session != nil && r.session.BaseSession != nil {
|
||||
sessionID = r.session.ID()
|
||||
}
|
||||
logger := log.WithField("session_id", sessionID)
|
||||
logger.Debug("Closing RawReader")
|
||||
|
||||
r.closed = true
|
||||
|
Reference in New Issue
Block a user