8317866: replace NET_SocketAvailable
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
6d6c9008d5
commit
424de295a6
src/java.base
share/native/libnet
unix/native
windows/native/libnet
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -161,9 +161,6 @@ int NET_IsZeroAddr(jbyte* caddr);
|
||||
* platform-specific pre/post processing of the arguments and/or results.
|
||||
*/
|
||||
|
||||
JNIEXPORT int JNICALL
|
||||
NET_SocketAvailable(int fd, int *pbytes);
|
||||
|
||||
JNIEXPORT int JNICALL
|
||||
NET_GetSockOpt(int fd, int level, int opt, void *result, int *len);
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <netinet/tcp.h> // defines TCP_NODELAY
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
@ -51,18 +50,6 @@
|
||||
#define IPV6_FLOWINFO_SEND 33
|
||||
#endif
|
||||
|
||||
#define RESTARTABLE(_cmd, _result) do { \
|
||||
do { \
|
||||
_result = _cmd; \
|
||||
} while((_result == -1) && (errno == EINTR)); \
|
||||
} while(0)
|
||||
|
||||
int NET_SocketAvailable(int s, int *pbytes) {
|
||||
int result;
|
||||
RESTARTABLE(ioctl(s, FIONREAD, pbytes), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
|
||||
const char *defaultDetail) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string.h>
|
||||
@ -854,7 +855,10 @@ JNIEXPORT jint JNICALL
|
||||
Java_sun_nio_ch_Net_available(JNIEnv *env, jclass cl, jobject fdo)
|
||||
{
|
||||
int count = 0;
|
||||
if (NET_SocketAvailable(fdval(env, fdo), &count) != 0) {
|
||||
int result;
|
||||
RESTARTABLE(ioctl(fdval(env, fdo), FIONREAD, &count), result);
|
||||
|
||||
if (result != 0) {
|
||||
handleSocketError(env, errno);
|
||||
return IOS_THROWN;
|
||||
}
|
||||
|
@ -392,19 +392,8 @@ NET_GetSockOpt(int s, int level, int optname, void *optval,
|
||||
return rv;
|
||||
}
|
||||
|
||||
JNIEXPORT int JNICALL
|
||||
NET_SocketAvailable(int s, int *pbytes) {
|
||||
u_long arg;
|
||||
if (ioctlsocket((SOCKET)s, FIONREAD, &arg) == SOCKET_ERROR) {
|
||||
return -1;
|
||||
} else {
|
||||
*pbytes = (int) arg;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets SO_ECLUSIVEADDRUSE if SO_REUSEADDR is not already set.
|
||||
* Sets SO_EXCLUSIVEADDRUSE if SO_REUSEADDR is not already set.
|
||||
*/
|
||||
void setExclusiveBind(int fd) {
|
||||
int parg = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user