prepareRead sets the read timeout and checks whether the connection is closed.
(ctx context.Context)
| 219 | |
| 220 | // prepareRead sets the read timeout and checks whether the connection is closed. |
| 221 | func (c *Conn) prepareRead(ctx context.Context) (bool, error) { |
| 222 | select { |
| 223 | case <-c.closed: |
| 224 | return false, net.ErrClosed |
| 225 | default: |
| 226 | } |
| 227 | timeoutSet := c.setupReadTimeout(ctx) |
| 228 | |
| 229 | c.closeStateMu.Lock() |
| 230 | closeReceivedErr := c.closeReceivedErr |
| 231 | c.closeStateMu.Unlock() |
| 232 | if closeReceivedErr != nil { |
| 233 | if timeoutSet { |
| 234 | c.clearReadTimeout() |
| 235 | } |
| 236 | return false, closeReceivedErr |
| 237 | } |
| 238 | |
| 239 | return timeoutSet, nil |
| 240 | } |
| 241 | |
| 242 | // finishRead clears the read timeout and reports whether the connection or |
| 243 | // operation context ended while the read was in progress. |
no test coverage detected