Files
containerd/core/metadata
Sebastiaan van Stijn ada7bdf19f replace "cleanup.Background" for "context.WithoutCancel"
the `cleanup.Background` utility was introduced in f606c4eba7,
at which time the project used go1.19, and Go's stdlib context did not yet
have [`context.WithoutCancel`], which was introduced in go1.21.

This patch replaces `cleanup.Background` for `context.WithoutCancel`, which
is near-identical, and part of go stdlib;

`cleanup.Background`:

    type clearCancel struct {
        context.Context
    }

    func (cc clearCancel) Deadline() (deadline time.Time, ok bool) {
        return
    }

    func (cc clearCancel) Done() <-chan struct{} {
        return nil
    }

    func (cc clearCancel) Err() error {
        return nil
    }

    // Background creates a new context which clears out the parent errors
    func Background(ctx context.Context) context.Context {
        return clearCancel{ctx}
    }

`context.WithoutCancel`:

    // WithoutCancel returns a derived context that points to the parent context
    // and is not canceled when parent is canceled.
    // The returned context returns no Deadline or Err, and its Done channel is nil.
    // Calling [Cause] on the returned context returns nil.
    func WithoutCancel(parent Context) Context {
        if parent == nil {
            panic("cannot create context from nil parent")
        }
        return withoutCancelCtx{parent}
    }

    type withoutCancelCtx struct {
        c Context
    }

    func (withoutCancelCtx) Deadline() (deadline time.Time, ok bool) {
        return
    }

    func (withoutCancelCtx) Done() <-chan struct{} {
        return nil
    }

    func (withoutCancelCtx) Err() error {
        return nil
    }

    func (c withoutCancelCtx) Value(key any) any {
        return value(c, key)
    }

    func (c withoutCancelCtx) String() string {
        return contextName(c.c) + ".WithoutCancel"
    }

[`context.WithoutCancel`]: https://pkg.go.dev/context@go1.21.0#WithoutCancel

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-07 12:34:59 +02:00
..
2024-01-17 09:54:54 -08:00
2024-01-17 09:52:03 -08:00
2024-12-23 23:14:49 -07:00
2024-01-17 09:55:12 -08:00
2024-12-23 23:14:49 -07:00
2024-12-23 23:14:49 -07:00
2024-01-25 22:18:45 -08:00