summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_clist.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1995-10-31 19:00:00 +0000
committerpeter <peter@FreeBSD.org>1995-10-31 19:00:00 +0000
commit6b6349e58305cd604fb25305de71d18c9a135e6a (patch)
tree862e93052eefece7cec0f88ce619d9a3d6345bb8 /sys/kern/subr_clist.c
parent9ee584cede8268f85847eb50639583c40c8120c2 (diff)
downloadFreeBSD-src-6b6349e58305cd604fb25305de71d18c9a135e6a.zip
FreeBSD-src-6b6349e58305cd604fb25305de71d18c9a135e6a.tar.gz
Make a putc()/b_to_q() to a clist that hasn't had cblocks reserved
non-fatal. I've make it return an appropriate error to the caller instead of panic()ing. Handling an error condition is inherently more friendly than exploding the kernel.. :-) The new behavior is a little closer to traditional clists, potentially making porting a little simpler. Suggested by: bde (many months ago, I've been using this for a while..)
Diffstat (limited to 'sys/kern/subr_clist.c')
-rw-r--r--sys/kern/subr_clist.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/kern/subr_clist.c b/sys/kern/subr_clist.c
index 734f797..9123397 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.13 1995/09/09 18:10:10 davidg Exp $
+ * $Id: tty_subr.c,v 1.14 1995/10/25 17:59:58 bde Exp $
*/
/*
@@ -349,8 +349,13 @@ putc(chr, clistp)
s = spltty();
if (clistp->c_cl == NULL) {
- if (clistp->c_cbreserved < 1)
- panic("putc to a clist with no reserved cblocks");
+ if (clistp->c_cbreserved < 1) {
+ splx(s);
+#ifdef DIAGNOSTIC
+ printf("putc to a clist with no reserved cblocks");
+#endif
+ return (-1);
+ }
cblockp = cblock_alloc();
clistp->c_cbcount = 1;
clistp->c_cf = clistp->c_cl = cblockp->c_info;
@@ -425,8 +430,13 @@ b_to_q(src, amount, clistp)
* then get one.
*/
if (clistp->c_cl == NULL) {
- if (clistp->c_cbreserved < 1)
- panic("b_to_q to a clist with no reserved cblocks");
+ if (clistp->c_cbreserved < 1) {
+ splx(s);
+#ifdef DIAGNOSTIC
+ printf("b_to_q to a clist with no reserved cblocks");
+#endif
+ return (amount);
+ }
cblockp = cblock_alloc();
clistp->c_cbcount = 1;
clistp->c_cf = clistp->c_cl = cblockp->c_info;
OpenPOWER on IntegriCloud