* Allocate buffer space if necessary, and set low watermarks, based on speed. * Note that the ttyxxxq_setsize() functions may drop and then reacquire the tty * lock during memory allocation. They will return ENXIO if the tty disappears * while unlocked. */
| 100 | * while unlocked. |
| 101 | */ |
| 102 | static int tty_watermarks(struct lwp_tty *tp) |
| 103 | { |
| 104 | size_t bs = 0; |
| 105 | int error; |
| 106 | |
| 107 | /* Provide an input buffer for 2 seconds of data. */ |
| 108 | if (tp->t_termios.c_cflag & CREAD) |
| 109 | bs = |
| 110 | MIN(bsd_speed_to_integer(tp->t_termios.__c_ispeed) / 5, TTYBUF_MAX); |
| 111 | error = ttyinq_setsize(&tp->t_inq, tp, bs); |
| 112 | if (error != 0) |
| 113 | return error; |
| 114 | |
| 115 | /* Set low watermark at 10% (when 90% is available). */ |
| 116 | tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10; |
| 117 | |
| 118 | /* Provide an output buffer for 2 seconds of data. */ |
| 119 | bs = MIN(bsd_speed_to_integer(tp->t_termios.__c_ospeed) / 5, TTYBUF_MAX); |
| 120 | error = ttyoutq_setsize(&tp->t_outq, tp, bs); |
| 121 | if (error != 0) |
| 122 | return error; |
| 123 | |
| 124 | /* Set low watermark at 10% (when 90% is available). */ |
| 125 | tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10; |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Drain outq |
no test coverage detected