| 115 | } while (0) |
| 116 | |
| 117 | int |
| 118 | ttyinq_setsize(struct ttyinq *ti, struct tty *tp, size_t size) |
| 119 | { |
| 120 | struct ttyinq_block *tib; |
| 121 | |
| 122 | ti->ti_quota = howmany(size, TTYINQ_DATASIZE); |
| 123 | |
| 124 | while (ti->ti_quota > ti->ti_nblocks) { |
| 125 | /* |
| 126 | * List is getting bigger. |
| 127 | * Add new blocks to the tail of the list. |
| 128 | * |
| 129 | * We must unlock the TTY temporarily, because we need |
| 130 | * to allocate memory. This won't be a problem, because |
| 131 | * in the worst case, another thread ends up here, which |
| 132 | * may cause us to allocate too many blocks, but this |
| 133 | * will be caught by the loop below. |
| 134 | */ |
| 135 | tty_unlock(tp); |
| 136 | tib = uma_zalloc(ttyinq_zone, M_WAITOK); |
| 137 | tty_lock(tp); |
| 138 | |
| 139 | if (tty_gone(tp)) { |
| 140 | uma_zfree(ttyinq_zone, tib); |
| 141 | return (ENXIO); |
| 142 | } |
| 143 | |
| 144 | TTYINQ_INSERT_TAIL(ti, tib); |
| 145 | } |
| 146 | return (0); |
| 147 | } |
| 148 | |
| 149 | void |
| 150 | ttyinq_free(struct ttyinq *ti) |
no test coverage detected