src/share/classes/sun/nio/ch/FileChannelImpl.java
Print this page
@@ -126,13 +126,14 @@
ensureOpen();
if (!readable)
throw new NonReadableChannelException();
synchronized (positionLock) {
int n = 0;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return 0;
do {
n = IOUtil.read(fd, dst, -1, nd, positionLock);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -149,13 +150,14 @@
ensureOpen();
if (!readable)
throw new NonReadableChannelException();
synchronized (positionLock) {
long n = 0;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return 0;
do {
n = IOUtil.read(fd, dsts, nd);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -181,13 +183,14 @@
ensureOpen();
if (!writable)
throw new NonWritableChannelException();
synchronized (positionLock) {
int n = 0;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return 0;
do {
n = IOUtil.write(fd, src, -1, nd, positionLock);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -204,13 +207,14 @@
ensureOpen();
if (!writable)
throw new NonWritableChannelException();
synchronized (positionLock) {
long n = 0;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return 0;
do {
n = IOUtil.write(fd, srcs, nd);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -237,13 +241,14 @@
public long position() throws IOException {
ensureOpen();
synchronized (positionLock) {
long p = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return 0;
do {
p = position0(fd, -1);
} while ((p == IOStatus.INTERRUPTED) && isOpen());
@@ -260,13 +265,14 @@
ensureOpen();
if (newPosition < 0)
throw new IllegalArgumentException();
synchronized (positionLock) {
long p = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return null;
do {
p = position0(fd, newPosition);
} while ((p == IOStatus.INTERRUPTED) && isOpen());
@@ -281,13 +287,14 @@
public long size() throws IOException {
ensureOpen();
synchronized (positionLock) {
long s = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return -1;
do {
s = nd.size(fd);
} while ((s == IOStatus.INTERRUPTED) && isOpen());
@@ -309,13 +316,14 @@
if (!writable)
throw new NonWritableChannelException();
synchronized (positionLock) {
int rv = -1;
long p = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return null;
// get current position
do {
@@ -348,13 +356,14 @@
}
public void force(boolean metaData) throws IOException {
ensureOpen();
int rv = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return;
do {
rv = nd.force(fd, metaData);
} while ((rv == IOStatus.INTERRUPTED) && isOpen());
@@ -404,13 +413,14 @@
int targetFDVal = IOUtil.fdVal(targetFD);
if (thisFDVal == targetFDVal) // Not supported on some configurations
return IOStatus.UNSUPPORTED;
long n = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return -1;
do {
n = transferTo0(thisFDVal, position, icount, targetFDVal);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -610,13 +620,14 @@
throw new IllegalArgumentException("Negative position");
if (!readable)
throw new NonReadableChannelException();
ensureOpen();
int n = 0;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return -1;
do {
n = IOUtil.read(fd, dst, position, nd, positionLock);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -635,13 +646,14 @@
throw new IllegalArgumentException("Negative position");
if (!writable)
throw new NonWritableChannelException();
ensureOpen();
int n = 0;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return -1;
do {
n = IOUtil.write(fd, src, position, nd, positionLock);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
@@ -729,13 +741,14 @@
throw new NonWritableChannelException();
if (!readable)
throw new NonReadableChannelException();
long addr = -1;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return null;
if (size() < position + size) { // Extend file size
if (!writable) {
throw new IOException("Channel not open for writing " +
@@ -898,13 +911,14 @@
throw new NonWritableChannelException();
FileLockImpl fli = new FileLockImpl(this, position, size, shared);
FileLockTable flt = fileLockTable();
flt.add(fli);
boolean i = true;
- int ti = threads.add();
+ int ti = -1;
try {
begin();
+ ti = threads.add();
if (!isOpen())
return null;
int result = nd.lock(fd, true, position, size, shared);
if (result == FileDispatcher.RET_EX_LOCK) {
assert shared;