Skip to content

Commit 3cf0e52

Browse files
committed
fix: atomic nil
Signed-off-by: Gaius <[email protected]>
1 parent 562baa1 commit 3cf0e52

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

scheduler/supervisor/cdn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (c *cdn) receivePiece(ctx context.Context, task *Task, stream *client.Piece
124124
if err != nil {
125125
if err == io.EOF {
126126
logger.Infof("task %s connection closed", task.ID)
127-
if task.GetStatus() == TaskStatusSuccess && cdnPeer != nil {
127+
if cdnPeer != nil && task.GetStatus() == TaskStatusSuccess {
128128
span.SetAttributes(config.AttributePeerDownloadSuccess.Bool(true))
129129
return cdnPeer, nil
130130
}

scheduler/supervisor/peer.go

+8
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ func (peer *Peer) GetChildren() *sync.Map {
329329
}
330330

331331
func (peer *Peer) SetParent(parent *Peer) {
332+
if parent == nil {
333+
return
334+
}
335+
332336
peer.parent.Store(parent)
333337
}
334338

@@ -457,6 +461,10 @@ func (peer *Peer) BindNewConn(stream scheduler.Scheduler_ReportPieceResultServer
457461
}
458462

459463
func (peer *Peer) setConn(conn *Channel) {
464+
if conn == nil {
465+
return
466+
}
467+
460468
peer.conn.Store(conn)
461469
}
462470

0 commit comments

Comments
 (0)