mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8317866: replace NET_SocketAvailable
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
6d6c9008d5
commit
424de295a6
4 changed files with 7 additions and 30 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue