Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_tape.cc')
-rw-r--r--winsup/cygwin/fhandler_tape.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index 855fd5dfd..17d2685f1 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -2,7 +2,7 @@
classes.
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2010, 2011, 2012 Red Hat, Inc.
+ 2008, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@@ -15,12 +15,7 @@ details. */
#include <stdlib.h>
#include <sys/mtio.h>
#include <sys/param.h>
-#ifdef __MINGW64_VERSION_MAJOR
-#include <devioctl.h>
-#include <ntddstor.h>
-#else
#include <ddk/ntddstor.h>
-#endif
#include "security.h"
#include "path.h"
#include "fhandler.h"
@@ -1147,13 +1142,26 @@ mtinfo::initialize ()
inline bool
fhandler_dev_tape::_lock (bool cancelable)
{
+ HANDLE w4[3] = { mt_mtx, signal_arrived, NULL };
+ DWORD cnt = 2;
+ 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;
- switch (cancelable_wait (mt_mtx, timeout, cw_sig | cw_cancel | cw_cancel_self))
+restart:
+ switch (WaitForMultipleObjects (cnt, w4, FALSE, timeout))
{
case WAIT_OBJECT_0:
return true;
+ case WAIT_OBJECT_0 + 1:
+ if (_my_tls.call_signal_handler ())
+ goto restart;
+ set_errno (EINTR);
+ return false;
+ case WAIT_OBJECT_0 + 2:
+ pthread::static_cancel_self ();
+ /*NOTREACHED*/
case WAIT_TIMEOUT:
set_errno (EAGAIN);
return false;
@@ -1270,7 +1278,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
{
if (devbufend > devbufstart)
{
- bytes_to_read = MIN (len, devbufend - devbufstart);
+ bytes_to_read = min (len, devbufend - devbufstart);
debug_printf ("read %d bytes from buffer (rest %d)",
bytes_to_read, devbufend - devbufstart - bytes_to_read);
memcpy (buf, devbuf + devbufstart, bytes_to_read);