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

Function ttyoutq_setsize

freebsd/kern/tty_outq.c:94–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94int
95ttyoutq_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
126void
127ttyoutq_free(struct ttyoutq *to)

Callers 1

tty_watermarksFunction · 0.85

Calls 2

uma_zallocFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected