Lines Matching defs:cookie

44 	atomic. thread_count is the number of threads currently using the cookie
47 operations are done at a certain point when closing a cookie
87 AbstractLocker(tty_cookie* cookie)
89 fCookie(cookie),
129 ReaderLocker(tty_cookie* cookie);
146 inline bool Lock(tty_cookie* cookie)
150 if (cookie->closed)
153 cookie->thread_count++;
158 inline void Unlock(tty_cookie* cookie)
163 if (--cookie->thread_count == 0 && cookie->closed)
164 semaphore = cookie->blocking_semaphore;
169 TRACE(("TTYReference: cookie %p closed, last operation done, "
170 "releasing blocking sem %" B_PRId32 "\n", cookie, semaphore));
195 Request::Init(RequestOwner* owner, tty_cookie* cookie, size_t bytesNeeded)
198 fCookie = cookie;
231 kprintf("%s cookie: %p\n", prefix, fCookie);
293 RequestQueue::NotifyError(tty_cookie* cookie, status_t error)
299 if (request->TTYCookie() == cookie)
332 RequestOwner::Enqueue(tty_cookie* cookie, RequestQueue* queue1,
335 TRACE(("%p->RequestOwner::Enqueue(%p, %p, %p)\n", this, cookie, queue1,
338 fCookie = cookie;
343 fRequests[0].Init(this, cookie, fBytesNeeded);
349 fRequests[1].Init(this, cookie, fBytesNeeded);
636 ReaderLocker::ReaderLocker(tty_cookie* cookie)
638 AbstractLocker(cookie),
639 fTTY(cookie->tty),
1401 tty_cookie* cookie = new(std::nothrow) tty_cookie;
1402 if (cookie == NULL)
1405 cookie->blocking_semaphore = create_sem(0, "wait for tty close");
1406 if (cookie->blocking_semaphore < 0) {
1407 status_t status = cookie->blocking_semaphore;
1408 delete cookie;
1412 cookie->tty = tty;
1413 cookie->other_tty = otherTTY;
1414 cookie->open_mode = openMode;
1415 cookie->thread_count = 0;
1416 cookie->closed = false;
1419 RecursiveLocker locker(cookie->tty->lock);
1422 delete_sem(cookie->blocking_semaphore);
1423 delete cookie;
1427 // add to the TTY's cookie list
1428 tty->cookies.Add(cookie);
1433 *_cookie = cookie;
1440 tty_close_cookie(tty_cookie* cookie)
1446 if (cookie->closed)
1449 // set the cookie's `closed' flag
1450 cookie->closed = true;
1451 bool unblock = (cookie->thread_count > 0);
1455 cookie->tty->reader_queue.NotifyError(cookie, B_FILE_ERROR);
1456 cookie->tty->writer_queue.NotifyError(cookie, B_FILE_ERROR);
1458 if (cookie->other_tty->open_count > 0) {
1459 cookie->other_tty->reader_queue.NotifyError(cookie, B_FILE_ERROR);
1460 cookie->other_tty->writer_queue.NotifyError(cookie, B_FILE_ERROR);
1469 TRACE(("tty_close_cookie(): cookie %p, there're still pending "
1470 "operations, acquire blocking sem %" B_PRId32 "\n", cookie,
1471 cookie->blocking_semaphore));
1473 acquire_sem(cookie->blocking_semaphore);
1476 // For the removal of the cookie acquire the TTY's lock. This ensures, that
1479 RecursiveLocker ttyLocker(cookie->tty->lock);
1481 // remove the cookie from the TTY's cookie list
1482 cookie->tty->cookies.Remove(cookie);
1485 if (--cookie->tty->open_count == 0) {
1486 // The last cookie of this tty has been closed. We're going to close
1488 // be no read requests, since only a cookie of this TTY issues those.
1495 cookie->other_tty->reader_queue.NotifyError(B_FILE_ERROR);
1496 cookie->other_tty->writer_queue.NotifyError(B_FILE_ERROR);
1501 if (!cookie->tty->writer_queue.IsEmpty()) {
1503 cookie->tty->writer_queue.NotifyError(B_FILE_ERROR);
1507 requestOwner.Enqueue(cookie, &cookie->tty->writer_queue);
1512 clear_line_buffer(cookie->tty->input_buffer);
1530 if (cookie->other_tty->open_count > 0) {
1531 tty_notify_select_event(cookie->other_tty, B_SELECT_WRITE);
1532 tty_notify_select_event(cookie->other_tty, B_SELECT_READ);
1535 cookie->tty->is_exclusive = false;
1541 tty_destroy_cookie(tty_cookie* cookie)
1543 RecursiveLocker locker(cookie->tty->lock);
1544 cookie->tty->ref_count--;
1547 if (cookie->blocking_semaphore >= 0)
1548 delete_sem(cookie->blocking_semaphore);
1550 delete cookie;
1555 tty_read(tty_cookie* cookie, void* _buffer, size_t* _length)
1558 struct tty* tty = cookie->tty;
1559 uint32 mode = cookie->open_mode;
1574 TTYReference ttyReference(cookie);
1578 ReaderLocker locker(cookie);
1675 tty_control(tty_cookie* cookie, uint32 op, void* buffer, size_t length)
1677 struct tty* tty = cookie->tty;
1680 TTYReference ttyReference(cookie);
1692 cookie->open_mode &= ~O_NONBLOCK;
1695 cookie->open_mode |= O_NONBLOCK;
1817 ReaderLocker readLocker(cookie);
1843 ReaderLocker readLocker(cookie);
1863 WriterLocker writeLocker(cookie);
1956 struct tty* otherTTY = cookie->other_tty;
1991 tty_select(tty_cookie* cookie, uint8 event, uint32 ref, selectsync* sync)
1993 struct tty* tty = cookie->tty;
1995 TRACE(("tty_select(cookie = %p, event = %u, ref = %" B_PRIu32 ", sync = "
1996 "%p)\n", cookie, event, ref, sync));
2003 TTYReference ttyReference(cookie);
2005 TRACE(("tty_select() done: cookie %p already closed\n", cookie));
2011 // lock the TTY (allows us to freely access the cookie lists of this and
2016 struct tty* otherTTY = cookie->other_tty;
2074 tty_deselect(tty_cookie* cookie, uint8 event, selectsync* sync)
2076 struct tty* tty = cookie->tty;
2078 TRACE(("tty_deselect(cookie = %p, event = %u, sync = %p)\n", cookie, event,
2093 tty_hardware_signal(tty_cookie* cookie, int signal, bool set)
2116 cookie->tty->hardware_bits |= bit;
2118 cookie->tty->hardware_bits &= ~bit;