MCPcopy Create free account
hub / github.com/imroc/req / closeWithError

Method closeWithError

internal/http2/pipe.go:122–145  ·  view source on GitHub ↗
(dst *error, err error, fn func())

Source from the content-addressed store, hash-verified

120func (p *pipe) closeWithErrorAndCode(err error, fn func()) { p.closeWithError(&p.err, err, fn) }
121
122func (p *pipe) closeWithError(dst *error, err error, fn func()) {
123 if err == nil {
124 panic("err must be non-nil")
125 }
126 p.mu.Lock()
127 defer p.mu.Unlock()
128 if p.c.L == nil {
129 p.c.L = &p.mu
130 }
131 defer p.c.Signal()
132 if *dst != nil {
133 // Already been done.
134 return
135 }
136 p.readFn = fn
137 if dst == &p.breakErr {
138 if p.b != nil {
139 p.unread += p.b.Len()
140 }
141 p.b = nil
142 }
143 *dst = err
144 p.closeDoneLocked()
145}
146
147// requires p.mu be held.
148func (p *pipe) closeDoneLocked() {

Callers 3

CloseWithErrorMethod · 0.95
BreakWithErrorMethod · 0.95
closeWithErrorAndCodeMethod · 0.95

Calls 4

closeDoneLockedMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
LenMethod · 0.65

Tested by

no test coverage detected