From 6584590b18b43595c1e27e46fee6bb1d4a498471 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 25 Apr 1996 20:09:05 +0000 Subject: (pty_open_hook): Don't do increment of nptyperopens here. (pty_po_create_hook): Increment nptyperopens here, but only if this is for O_READ or O_WRITE. (pty_po_destroy_hook): Only do decrement if this was for O_READ or O_WRITE. --- term/ptyio.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/term/ptyio.c b/term/ptyio.c index 36265f72..3ad8d55a 100644 --- a/term/ptyio.c +++ b/term/ptyio.c @@ -53,6 +53,31 @@ static int pktnostop = 0; static int ptyopen = 0; static int nptyperopens = 0; + + +enum rb +{ + RB_OPEN = 1, + RB_BUSY = 2, + RB_INC = 3, + RB_CREATE = 4, + RB_DESTROY = 5, + RB_DEC = 6, + RB_DROP_CARR = 7, +}; + +static enum rb record_buf[10000]; +static enum rb *rbc = record_buf; +static spin_lock_t rblock = SPIN_LOCK_INITIALIZER; +static void +xxx_record (enum rb n) +{ + spin_lock (&rblock); + *rbc++ = n; + spin_unlock (&rblock); +} + + void ptyio_init () @@ -74,13 +99,13 @@ pty_open_hook (struct trivfs_control *cntl, if (ptyopen) { + xxx_record (RB_BUSY); mutex_unlock (&global_lock); return EBUSY; } + xxx_record (RB_OPEN); ptyopen = 1; - nptyperopens++; - report_carrier_on (); mutex_unlock (&global_lock); return 0; } @@ -88,16 +113,33 @@ pty_open_hook (struct trivfs_control *cntl, error_t pty_po_create_hook (struct trivfs_peropen *po) { + xxx_record (RB_CREATE); + mutex_lock (&global_lock); + if (po->flags & (O_READ | O_WRITE)) + { + xxx_record (RB_INC); + nptyperopens++; + report_carrier_on (); + } + mutex_unlock (&global_lock); return 0; } error_t pty_po_destroy_hook (struct trivfs_peropen *po) { + xxx_record (RB_DESTROY); mutex_lock (&global_lock); + if ((po->flags & (O_READ | O_WRITE)) == 0) + { + mutex_unlock (&global_lock); + return 0; + } nptyperopens--; + xxx_record (RB_DEC); if (!nptyperopens) { + xxx_record (RB_DROP_CARR); ptyopen = 0; report_carrier_off (); } -- cgit v1.2.3