8217461: (ch) Add Net.available to return the number of bytes in the socket input buffer

Reviewed-by: clanger, michaelm
This commit is contained in:
Alan Bateman 2019-01-22 16:39:52 +00:00
parent aa5637f24e
commit 755872aa82
8 changed files with 52 additions and 17 deletions

View file

@ -123,12 +123,10 @@ int getDefaultScopeID(JNIEnv *env) {
} while((_result == -1) && (errno == EINTR)); \
} while(0)
int NET_SocketAvailable(int s, jint *pbytes) {
int NET_SocketAvailable(int s, int *pbytes) {
int result;
RESTARTABLE(ioctl(s, FIONREAD, pbytes), result);
// note: ioctl can return 0 when successful, NET_SocketAvailable
// is expected to return 0 on failure and 1 on success.
return (result == -1) ? 0 : 1;
return result;
}
#ifdef __solaris__