From c16bf37e86329dad434477c2ebfdf4d9ceff2d18 Mon Sep 17 00:00:00 2001 From: David Greenman Date: Wed, 6 Jul 1994 06:42:34 +0000 Subject: [PATCH] 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). --- sys/kern/tty.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 23309a3a7f6..ed5724d77e0 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); }