Skip to content

Commit 967156a

Browse files
committed
shifting logic around
1 parent 3abdf5a commit 967156a

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/main/java/org/scalasbt/ipcsocket/JNIUnixDomainSocketLibraryProvider.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,24 @@ public int shutdown(int fd, int how) throws NativeErrorException {
4646

4747
public int available(int fd) throws NativeErrorException {
4848
int result = availableNative(fd);
49-
if (result < 0) {
50-
if (pollRead(fd, 0)) {
51-
return 1;
52-
} else {
53-
return 0;
54-
}
49+
if (result >= 0) {
50+
return result;
51+
} else if (pollRead(fd, 0)) {
52+
return 1;
5553
} else {
56-
return returnOrThrow(result, 0);
54+
return 0;
5755
}
5856
}
5957

6058
public boolean pollRead(int fd, int timeout) throws NativeErrorException {
6159
int result = pollReadNative(fd, timeout);
62-
if (result < 0) {
63-
returnOrThrow(result, 0);
64-
return false;
65-
}
6660
if (result == 0) {
6761
return false;
68-
} else {
62+
} else if (result > 0) {
6963
return true;
64+
} else {
65+
returnOrThrow(result, 0);
66+
return false;
7067
}
7168
}
7269

0 commit comments

Comments
 (0)