summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-04-25 20:09:05 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-04-25 20:09:05 +0000
commit6584590b18b43595c1e27e46fee6bb1d4a498471 (patch)
tree47bdd3cbf13d84263e7482808487ac9bc8694d98
parent0133c3cf8ed094736fdf38aad82c70a6841a188a (diff)
(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.
-rw-r--r--term/ptyio.c46
1 files 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
@@ -54,6 +54,31 @@ 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 ();
}