* fhandler.h (fhandler_dev_tape::_lock): Add bool parameter.
* fhandler_tape.cc (lock): Call _lock with false argument. (_lock): Take bool cancelable parameter. Handle O_NONBLOCK. Make cancelable if cancelabe parameter is true. (fhandler_dev_tape::raw_read): Call _lock with true argument. (fhandler_dev_tape::raw_write): Ditto.
This commit is contained in:
parent
5152a53ade
commit
412693ab65
@ -1,3 +1,12 @@
|
|||||||
|
2011-05-04 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler.h (fhandler_dev_tape::_lock): Add bool parameter.
|
||||||
|
* fhandler_tape.cc (lock): Call _lock with false argument.
|
||||||
|
(_lock): Take bool cancelable parameter. Handle O_NONBLOCK.
|
||||||
|
Make cancelable if cancelabe parameter is true.
|
||||||
|
(fhandler_dev_tape::raw_read): Call _lock with true argument.
|
||||||
|
(fhandler_dev_tape::raw_write): Ditto.
|
||||||
|
|
||||||
2011-05-04 Corinna Vinschen <corinna@vinschen.de>
|
2011-05-04 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add fh member.
|
* fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add fh member.
|
||||||
|
@ -751,7 +751,7 @@ class fhandler_dev_tape: public fhandler_dev_raw
|
|||||||
unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; }
|
unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; }
|
||||||
void drive_init ();
|
void drive_init ();
|
||||||
|
|
||||||
inline bool _lock ();
|
inline bool _lock (bool);
|
||||||
inline int unlock (int ret = 0);
|
inline int unlock (int ret = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
classes.
|
classes.
|
||||||
|
|
||||||
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||||
2008, 2010 Red Hat, Inc.
|
2008, 2010, 2011 Red Hat, Inc.
|
||||||
|
|
||||||
This file is part of Cygwin.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
@ -1136,19 +1136,38 @@ mtinfo::initialize ()
|
|||||||
|
|
||||||
#define mt (cygwin_shared->mt)
|
#define mt (cygwin_shared->mt)
|
||||||
|
|
||||||
#define lock(err_ret_val) if (!_lock ()) return err_ret_val;
|
#define lock(err_ret_val) if (!_lock (false)) return (err_ret_val);
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
fhandler_dev_tape::_lock ()
|
fhandler_dev_tape::_lock (bool cancelable)
|
||||||
{
|
{
|
||||||
HANDLE obj[2] = { mt_mtx, signal_arrived };
|
HANDLE w4[3] = { mt_mtx, signal_arrived, NULL };
|
||||||
BOOL ret = WaitForMultipleObjects (2, obj, FALSE, INFINITE) == WAIT_OBJECT_0;
|
DWORD cnt = 2;
|
||||||
if (!ret)
|
if (cancelable && (w4[2] = pthread::get_cancel_event ()) != NULL)
|
||||||
|
cnt = 3;
|
||||||
|
/* O_NONBLOCK is only valid in a read or write call. Only those are
|
||||||
|
cancelable. */
|
||||||
|
DWORD timeout = cancelable && is_nonblocking () ? 0 : INFINITE;
|
||||||
|
restart:
|
||||||
|
switch (WaitForMultipleObjects (cnt, w4, FALSE, timeout))
|
||||||
{
|
{
|
||||||
debug_printf ("signal_arrived"); \
|
case WAIT_OBJECT_0:
|
||||||
|
return true;
|
||||||
|
case WAIT_OBJECT_0 + 1:
|
||||||
|
if (_my_tls.call_signal_handler ())
|
||||||
|
goto restart;
|
||||||
set_errno (EINTR);
|
set_errno (EINTR);
|
||||||
|
return false;
|
||||||
|
case WAIT_OBJECT_0 + 2:
|
||||||
|
pthread::static_cancel_self ();
|
||||||
|
/*NOTREACHED*/
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
set_errno (EAGAIN);
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
__seterrno ();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
@ -1248,7 +1267,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
|
|||||||
ulen = 0;
|
ulen = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!_lock ())
|
if (!_lock (true))
|
||||||
{
|
{
|
||||||
ulen = (size_t) -1;
|
ulen = (size_t) -1;
|
||||||
return;
|
return;
|
||||||
@ -1336,7 +1355,8 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
|
|||||||
ssize_t __stdcall
|
ssize_t __stdcall
|
||||||
fhandler_dev_tape::raw_write (const void *ptr, size_t len)
|
fhandler_dev_tape::raw_write (const void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
lock (-1);
|
if (!_lock (true))
|
||||||
|
return -1;
|
||||||
if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
|
if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
|
||||||
debug_printf ("Creating event failed, %E");
|
debug_printf ("Creating event failed, %E");
|
||||||
int ret = mt.drive (driveno ())->write (get_handle (), mt_evt, ptr, len);
|
int ret = mt.drive (driveno ())->write (get_handle (), mt_evt, ptr, len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user