| 92 | } |
| 93 | |
| 94 | int |
| 95 | ttyoutq_setsize(struct ttyoutq *to, struct tty *tp, size_t size) |
| 96 | { |
| 97 | struct ttyoutq_block *tob; |
| 98 | |
| 99 | to->to_quota = howmany(size, TTYOUTQ_DATASIZE); |
| 100 | |
| 101 | while (to->to_quota > to->to_nblocks) { |
| 102 | /* |
| 103 | * List is getting bigger. |
| 104 | * Add new blocks to the tail of the list. |
| 105 | * |
| 106 | * We must unlock the TTY temporarily, because we need |
| 107 | * to allocate memory. This won't be a problem, because |
| 108 | * in the worst case, another thread ends up here, which |
| 109 | * may cause us to allocate too many blocks, but this |
| 110 | * will be caught by the loop below. |
| 111 | */ |
| 112 | tty_unlock(tp); |
| 113 | tob = uma_zalloc(ttyoutq_zone, M_WAITOK); |
| 114 | tty_lock(tp); |
| 115 | |
| 116 | if (tty_gone(tp)) { |
| 117 | uma_zfree(ttyoutq_zone, tob); |
| 118 | return (ENXIO); |
| 119 | } |
| 120 | |
| 121 | TTYOUTQ_INSERT_TAIL(to, tob); |
| 122 | } |
| 123 | return (0); |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | ttyoutq_free(struct ttyoutq *to) |
no test coverage detected