drainOutput will drain the output until errEndOfStream is sent.
()
| 250 | |
| 251 | // drainOutput will drain the output until errEndOfStream is sent. |
| 252 | func (d *Decoder) drainOutput() { |
| 253 | if d.current.cancel != nil { |
| 254 | if debugDecoder { |
| 255 | println("cancelling current") |
| 256 | } |
| 257 | d.current.cancel() |
| 258 | d.current.cancel = nil |
| 259 | } |
| 260 | if d.current.d != nil { |
| 261 | if debugDecoder { |
| 262 | printf("re-adding current decoder %p, decoders: %d", d.current.d, len(d.decoders)) |
| 263 | } |
| 264 | d.decoders <- d.current.d |
| 265 | d.current.d = nil |
| 266 | d.current.b = nil |
| 267 | } |
| 268 | if d.current.output == nil || d.current.flushed { |
| 269 | println("current already flushed") |
| 270 | return |
| 271 | } |
| 272 | for v := range d.current.output { |
| 273 | if v.d != nil { |
| 274 | if debugDecoder { |
| 275 | printf("re-adding decoder %p", v.d) |
| 276 | } |
| 277 | d.decoders <- v.d |
| 278 | } |
| 279 | } |
| 280 | d.current.output = nil |
| 281 | d.current.flushed = true |
| 282 | } |
| 283 | |
| 284 | // WriteTo writes data to w until there's no more data to write or when an error occurs. |
| 285 | // The return value n is the number of bytes written. |