MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ttyinq_setsize

Function ttyinq_setsize

freebsd/kern/tty_inq.c:117–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115} while (0)
116
117int
118ttyinq_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
149void
150ttyinq_free(struct ttyinq *ti)

Callers 1

tty_watermarksFunction · 0.85

Calls 2

uma_zallocFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected