Skip to content

Commit 5ca674f

Browse files
author
duke
committedOct 12, 2023
Automatic merge of jdk:master into master
2 parents 54ef676 + 424de29 commit 5ca674f

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
lines changed
 

‎src/java.base/share/native/libnet/net_util.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -161,9 +161,6 @@ int NET_IsZeroAddr(jbyte* caddr);
161161
* platform-specific pre/post processing of the arguments and/or results.
162162
*/
163163

164-
JNIEXPORT int JNICALL
165-
NET_SocketAvailable(int fd, int *pbytes);
166-
167164
JNIEXPORT int JNICALL
168165
NET_GetSockOpt(int fd, int level, int opt, void *result, int *len);
169166

‎src/java.base/unix/native/libnet/net_util_md.c

-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <netinet/tcp.h> // defines TCP_NODELAY
2929
#include <stdlib.h>
3030
#include <string.h>
31-
#include <sys/ioctl.h>
3231
#include <sys/time.h>
3332

3433
#if defined(__linux__)
@@ -51,18 +50,6 @@
5150
#define IPV6_FLOWINFO_SEND 33
5251
#endif
5352

54-
#define RESTARTABLE(_cmd, _result) do { \
55-
do { \
56-
_result = _cmd; \
57-
} while((_result == -1) && (errno == EINTR)); \
58-
} while(0)
59-
60-
int NET_SocketAvailable(int s, int *pbytes) {
61-
int result;
62-
RESTARTABLE(ioctl(s, FIONREAD, pbytes), result);
63-
return result;
64-
}
65-
6653
void
6754
NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
6855
const char *defaultDetail) {

‎src/java.base/unix/native/libnio/ch/Net.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525

2626
#include <poll.h>
27+
#include <sys/ioctl.h>
2728
#include <sys/types.h>
2829
#include <sys/socket.h>
2930
#include <string.h>
@@ -854,7 +855,10 @@ JNIEXPORT jint JNICALL
854855
Java_sun_nio_ch_Net_available(JNIEnv *env, jclass cl, jobject fdo)
855856
{
856857
int count = 0;
857-
if (NET_SocketAvailable(fdval(env, fdo), &count) != 0) {
858+
int result;
859+
RESTARTABLE(ioctl(fdval(env, fdo), FIONREAD, &count), result);
860+
861+
if (result != 0) {
858862
handleSocketError(env, errno);
859863
return IOS_THROWN;
860864
}

‎src/java.base/windows/native/libnet/net_util_md.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -392,19 +392,8 @@ NET_GetSockOpt(int s, int level, int optname, void *optval,
392392
return rv;
393393
}
394394

395-
JNIEXPORT int JNICALL
396-
NET_SocketAvailable(int s, int *pbytes) {
397-
u_long arg;
398-
if (ioctlsocket((SOCKET)s, FIONREAD, &arg) == SOCKET_ERROR) {
399-
return -1;
400-
} else {
401-
*pbytes = (int) arg;
402-
return 0;
403-
}
404-
}
405-
406395
/*
407-
* Sets SO_ECLUSIVEADDRUSE if SO_REUSEADDR is not already set.
396+
* Sets SO_EXCLUSIVEADDRUSE if SO_REUSEADDR is not already set.
408397
*/
409398
void setExclusiveBind(int fd) {
410399
int parg = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.