Skip to content

Commit fee5d42

Browse files
committed
Drop context.Context implementation from Deadline
Deadline never satisfied the Context contract. Set revives it, so Err goes from non-nil back to nil and Done hands out a new channel while earlier holders still see the old one closed: two observers of the same "context" disagreeing permanently. Any context derived from it can panic in the standard library, because both propagateCancel paths read parent.Err() after observing Done, and cancelCtx.cancel panics on a nil error. This reproduces today with no callback API involved. Dropping the no-op Value method breaks the interface assertion and turns those derivations into compile errors. Callers that want a context should use Deadline.Context, which is monotonic. Set, Done, Err and Deadline are untouched: across pion/transport, pion/dtls and pion/sctp the only methods invoked on a Deadline are Set and Done. Known downstream fallout, both passing a Deadline to an unexported function that takes a context.Context: pion/dtls conn.go:586 c.contextWithClose(c.writeDeadline) pion/sctp stream.go:330 sendPayloadData(s.writeDeadline, chunks)
1 parent b2a362c commit fee5d42

1 file changed

Lines changed: 0 additions & 8 deletions

File tree

deadline/deadline.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ func init() {
2828
exceededContext = ctx
2929
}
3030

31-
var _ context.Context = (*Deadline)(nil)
32-
3331
// Deadline signals updatable deadline timer.
34-
// Also, it implements context.Context.
3532
type Deadline struct {
3633
mu sync.RWMutex
3734
timer timer
@@ -170,8 +167,3 @@ func (d *Deadline) Deadline() (time.Time, bool) {
170167

171168
return d.deadline, true
172169
}
173-
174-
// Value returns nil.
175-
func (d *Deadline) Value(any) any {
176-
return nil
177-
}

0 commit comments

Comments
 (0)