| 274 | } |
| 275 | |
| 276 | static int |
| 277 | ttydisc_read_raw_interbyte_timer(struct tty *tp, struct uio *uio, int ioflag) |
| 278 | { |
| 279 | size_t vmin = tp->t_termios.c_cc[VMIN]; |
| 280 | ssize_t oresid = uio->uio_resid; |
| 281 | int error; |
| 282 | |
| 283 | MPASS(tp->t_termios.c_cc[VMIN] != 0); |
| 284 | MPASS(tp->t_termios.c_cc[VTIME] != 0); |
| 285 | |
| 286 | /* |
| 287 | * When using the interbyte timer, the timer should be started |
| 288 | * after the first byte has been received. We just call into the |
| 289 | * generic read timer code after we've received the first byte. |
| 290 | */ |
| 291 | |
| 292 | for (;;) { |
| 293 | error = tty_wait_background(tp, curthread, SIGTTIN); |
| 294 | if (error) |
| 295 | return (error); |
| 296 | |
| 297 | error = ttyinq_read_uio(&tp->t_inq, tp, uio, |
| 298 | uio->uio_resid, 0); |
| 299 | if (error) |
| 300 | return (error); |
| 301 | if (uio->uio_resid == 0 || (oresid - uio->uio_resid) >= vmin) |
| 302 | return (0); |
| 303 | |
| 304 | /* |
| 305 | * Not enough data, but we did receive some, which means |
| 306 | * we'll now start using the interbyte timer. |
| 307 | */ |
| 308 | if (oresid != uio->uio_resid) |
| 309 | break; |
| 310 | |
| 311 | /* We have to wait for more. */ |
| 312 | if (tp->t_flags & TF_ZOMBIE) |
| 313 | return (0); |
| 314 | else if (ioflag & IO_NDELAY) |
| 315 | return (EWOULDBLOCK); |
| 316 | |
| 317 | error = tty_wait(tp, &tp->t_inwait); |
| 318 | if (error) |
| 319 | return (error); |
| 320 | } |
| 321 | |
| 322 | return ttydisc_read_raw_read_timer(tp, uio, ioflag, oresid); |
| 323 | } |
| 324 | |
| 325 | int |
| 326 | ttydisc_read(struct tty *tp, struct uio *uio, int ioflag) |
no test coverage detected