A TTY now refuses read/write requests while the other end is dead; it also
notified the other end when it has been closed. This fixes bug #388. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16965 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public:
|
|||||||
{
|
{
|
||||||
MutexLocker _(gTTYCookieLock);
|
MutexLocker _(gTTYCookieLock);
|
||||||
|
|
||||||
if (cookie->closed)
|
if (cookie->closed || cookie->other_tty->open_count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cookie->thread_count++;
|
cookie->thread_count++;
|
||||||
@@ -915,11 +915,16 @@ tty_close_cookie(struct tty_cookie *cookie)
|
|||||||
// We do this by first notifying all queued requests of the error
|
// We do this by first notifying all queued requests of the error
|
||||||
// condition. We then clear the line buffer for the TTY and queue
|
// condition. We then clear the line buffer for the TTY and queue
|
||||||
// an own request.
|
// an own request.
|
||||||
|
|
||||||
|
// Notify the other TTY first; it doesn't accept any read/writes
|
||||||
|
// while there is only one end.
|
||||||
|
cookie->other_tty->reader_queue.NotifyError(B_FILE_ERROR);
|
||||||
|
cookie->other_tty->writer_queue.NotifyError(B_FILE_ERROR);
|
||||||
|
|
||||||
RecursiveLocker requestLocker(gTTYRequestLock);
|
RecursiveLocker requestLocker(gTTYRequestLock);
|
||||||
|
|
||||||
// we only need to do all this, if the writer queue is not empty
|
// we only need to do all this, if the writer queue is not empty
|
||||||
if (!cookie->tty->writer_queue.IsEmpty()) {
|
if (!cookie->tty->writer_queue.IsEmpty()) {
|
||||||
|
|
||||||
// notify the blocking writers
|
// notify the blocking writers
|
||||||
cookie->tty->writer_queue.NotifyError(B_FILE_ERROR);
|
cookie->tty->writer_queue.NotifyError(B_FILE_ERROR);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user