summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_clist.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-10-25 17:59:58 +0000
committerbde <bde@FreeBSD.org>1995-10-25 17:59:58 +0000
commitfcc3ae3084cf7b56d83f4b418f21301165d1c738 (patch)
tree52c403405e20c5b91f5e5cd32022cb0e11f8330c /sys/kern/subr_clist.c
parenta82dbdecafb66d5c1992b9d3922ecd9d5d99d403 (diff)
downloadFreeBSD-src-fcc3ae3084cf7b56d83f4b418f21301165d1c738.zip
FreeBSD-src-fcc3ae3084cf7b56d83f4b418f21301165d1c738.tar.gz
Fix clist limits. They were usually one too low. E.g., for a limit of
TTYHOG = 1024 bytes, 10 cblocks were reserved. This was thought to provide 10 * CBSIZE = 1080 bytes of buffering, but if the head pointer is at the end of a cblock, then it only provides 1 + 9 * CBSIZE = 973 bytes of buffering. This caused serious data loss for ptys because the flow control is deterministic and requires at least TTYHOG bytes of buffering. For ttys, if input flow control is used then there is usually enough slop in the high watermark to avoid problems, and if input flow control isn't used then a limit of 973 is not much different from a limit of 1024. Add prototypes. Continue cleaning up new init stuff.
Diffstat (limited to 'sys/kern/subr_clist.c')
-rw-r--r--sys/kern/subr_clist.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/kern/subr_clist.c b/sys/kern/subr_clist.c
index ec88067..734f797 100644
--- a/sys/kern/subr_clist.c
+++ b/sys/kern/subr_clist.c
@@ -6,7 +6,7 @@
* of this software, nor does the author assume any responsibility
* for damages incurred with its use.
*
- * $Id: tty_subr.c,v 1.12 1995/08/28 09:18:50 julian Exp $
+ * $Id: tty_subr.c,v 1.13 1995/09/09 18:10:10 davidg Exp $
*/
/*
@@ -21,10 +21,6 @@
#include <sys/clist.h>
#include <sys/malloc.h>
-/*
- * System initialization
- */
-
static void clist_init __P((void *));
SYSINIT(clist, SI_SUB_CLIST, SI_ORDER_FIRST, clist_init, NULL)
@@ -37,11 +33,15 @@ static int ctotcount;
#define INITIAL_CBLOCKS 50
#endif
+static struct cblock *cblock_alloc __P((void));
static void cblock_alloc_cblocks __P((int number));
+static void cblock_free __P((struct cblock *cblockp));
static void cblock_free_cblocks __P((int number));
#define CBLOCK_DIAG
#ifdef CBLOCK_DIAG
+static void cbstat __P((void));
+
static void
cbstat()
{
@@ -57,8 +57,8 @@ cbstat()
*/
/* ARGSUSED*/
static void
-clist_init(udata)
- void *udata; /* not used*/
+clist_init(dummy)
+ void *dummy;
{
/*
* Allocate an initial base set of cblocks as a 'slush'.
@@ -137,6 +137,14 @@ clist_alloc_cblocks(clistp, ccmax, ccreserved)
{
int dcbr;
+ /*
+ * Allow for wasted space at the head.
+ */
+ if (ccmax != 0)
+ ccmax += CBSIZE - 1;
+ if (ccreserved != 0)
+ ccreserved += CBSIZE - 1;
+
clistp->c_cbmax = roundup(ccmax, CBSIZE) / CBSIZE;
dcbr = roundup(ccreserved, CBSIZE) / CBSIZE - clistp->c_cbreserved;
if (dcbr >= 0)
OpenPOWER on IntegriCloud