diff options
author | dg <dg@FreeBSD.org> | 1994-07-06 06:42:34 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-07-06 06:42:34 +0000 |
commit | f9a6051213b00e70433b2b73687deb9703033f6a (patch) | |
tree | 255211be243ad6e9afac55b3760f9ef388060886 /sys | |
parent | 01f3eb67e3ada8ebe824007654b12d5aef6b3728 (diff) | |
download | FreeBSD-src-f9a6051213b00e70433b2b73687deb9703033f6a.zip FreeBSD-src-f9a6051213b00e70433b2b73687deb9703033f6a.tar.gz |
Added code to allocate and deallocate a number of cblocks on open/close of
a tty.
Note that this might conflict with the collateral use of TS_WOPEN, but
for the moment I can find no problems associated with this. (TS_WOPEN
will likely go away in the future anyway). This should be looked at
again in the future (the potential problem is that the cblock pool
may either run out or accumulate too many cblocks).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/tty.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 23309a3..ed5724d 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -69,6 +69,10 @@ char ttybuf[] = "ttybuf"; char ttyin[] = "ttyin"; char ttyout[] = "ttyout"; +#ifndef CBLOCKS_PER_TTY +#define CBLOCKS_PER_TTY 10 +#endif + /* * Table with character classes and parity. The 8th bit indicates parity, * the 7th bit indicates the character is an alphameric or underscore (for @@ -162,6 +166,10 @@ ttyopen(device, tp) if (!ISSET(tp->t_state, TS_ISOPEN)) { SET(tp->t_state, TS_ISOPEN); bzero(&tp->t_winsize, sizeof(tp->t_winsize)); + /* + * Add some cblocks to the clistfree pool. + */ + cblock_alloc_cblocks(CBLOCKS_PER_TTY); } CLR(tp->t_state, TS_WOPEN); splx(s); @@ -187,6 +195,13 @@ ttyclose(tp) tp->t_gen++; tp->t_pgrp = NULL; tp->t_session = NULL; + /* + * If the tty has not already been closed, free the cblocks + * that were allocated in ttyopen() back to the system malloc + * pool. + */ + if (ISSET(tp->t_state, (TS_ISOPEN|TS_WOPEN))) + cblock_free_cblocks(CBLOCKS_PER_TTY); tp->t_state = 0; return (0); } |