diff options
author | ed <ed@FreeBSD.org> | 2008-08-30 09:18:27 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-08-30 09:18:27 +0000 |
commit | fa61dcef0fdcc71803bc5438ff017c9b2d2c2597 (patch) | |
tree | 3f7f8cef40eb7fcfa5fa1ed51119fbefef384553 /sys/sys/ttyqueue.h | |
parent | 558a49e6d851cbd77e26165d30a40ac601ece5ce (diff) | |
download | FreeBSD-src-fa61dcef0fdcc71803bc5438ff017c9b2d2c2597.zip FreeBSD-src-fa61dcef0fdcc71803bc5438ff017c9b2d2c2597.tar.gz |
Fix some edge cases in the TTY queues:
- In the current design, when a TTY decreases its baud rate, it tries to
shrink the queues. This may not always be possible, because it will
not free any blocks that are still filled with data.
Change the TTY queues to store a `quota' value as well, which means it
will not free any blocks when changing the baud rate, but when placing
blocks back into the queue. When the amount of blocks exceeds the
quota, they get freed.
It also fixes some edge cases, where TIOCSETA during read()/
write()-calls could actually make the queue a tiny bit bigger than in
normal cases.
- Don't leak blocks of memory when calling TIOCSETA when the device
driver abandons the TTY while allocating memory.
- Create ttyoutq_init() and ttyinq_init() to initialize the queues,
instead of initializing them by hand. The new TTY snoop driver also
creates an outq, so it's good to have a proper interface to do this.
Obtained from: //depot/projects/mpsafetty/...
Diffstat (limited to 'sys/sys/ttyqueue.h')
-rw-r--r-- | sys/sys/ttyqueue.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/sys/ttyqueue.h b/sys/sys/ttyqueue.h index 3e72fef..24e1187 100644 --- a/sys/sys/ttyqueue.h +++ b/sys/sys/ttyqueue.h @@ -52,6 +52,7 @@ struct ttyinq { unsigned int ti_reprint; unsigned int ti_end; unsigned int ti_nblocks; + unsigned int ti_quota; }; #define TTYINQ_DATASIZE 128 @@ -62,12 +63,14 @@ struct ttyoutq { unsigned int to_begin; unsigned int to_end; unsigned int to_nblocks; + unsigned int to_quota; }; #define TTYOUTQ_DATASIZE (256 - sizeof(STAILQ_ENTRY(ttyoutq_block))) #ifdef _KERNEL /* Input queue handling routines. */ void ttyinq_setsize(struct ttyinq *, struct tty *, size_t); +void ttyinq_free(struct ttyinq *); int ttyinq_read_uio(struct ttyinq *, struct tty *, struct uio *, size_t, size_t); size_t ttyinq_write(struct ttyinq *, const void *, size_t, int); @@ -80,6 +83,13 @@ void ttyinq_unputchar(struct ttyinq *); void ttyinq_reprintpos_set(struct ttyinq *); void ttyinq_reprintpos_reset(struct ttyinq *); +static __inline void +ttyinq_init(struct ttyinq *ti) +{ + + TAILQ_INIT(&ti->ti_list); +} + static __inline size_t ttyinq_getsize(struct ttyinq *ti) { @@ -124,11 +134,19 @@ void ttyinq_line_iterate_from_reprintpos(struct ttyinq *, /* Output queue handling routines. */ void ttyoutq_flush(struct ttyoutq *); void ttyoutq_setsize(struct ttyoutq *, struct tty *, size_t); +void ttyoutq_free(struct ttyoutq *); size_t ttyoutq_read(struct ttyoutq *, void *, size_t); int ttyoutq_read_uio(struct ttyoutq *, struct tty *, struct uio *); size_t ttyoutq_write(struct ttyoutq *, const void *, size_t); int ttyoutq_write_nofrag(struct ttyoutq *, const void *, size_t); +static __inline void +ttyoutq_init(struct ttyoutq *to) +{ + + STAILQ_INIT(&to->to_list); +} + static __inline size_t ttyoutq_getsize(struct ttyoutq *to) { |