mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8231259: (dc) DatagramChannel::disconnect re-binds socket to the wildcard address (macOS)
Reviewed-by: dfuchs, chegar
This commit is contained in:
parent
62d6862485
commit
7e42642939
11 changed files with 494 additions and 146 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2019, 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
|
||||
|
@ -25,16 +25,16 @@
|
|||
|
||||
package sun.nio.ch;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Allows different platforms to call different native methods
|
||||
* for read and write operations.
|
||||
*/
|
||||
|
||||
class DatagramDispatcher extends NativeDispatcher
|
||||
{
|
||||
class DatagramDispatcher extends NativeDispatcher {
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
|
@ -63,6 +63,10 @@ class DatagramDispatcher extends NativeDispatcher
|
|||
FileDispatcherImpl.preClose0(fd);
|
||||
}
|
||||
|
||||
void dup(FileDescriptor fd1, FileDescriptor fd2) throws IOException {
|
||||
FileDispatcherImpl.dup0(fd1, fd2);
|
||||
}
|
||||
|
||||
static native int read0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, 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
|
||||
|
@ -108,6 +108,10 @@ class FileDispatcherImpl extends FileDispatcher {
|
|||
preClose0(fd);
|
||||
}
|
||||
|
||||
void dup(FileDescriptor fd1, FileDescriptor fd2) throws IOException {
|
||||
dup0(fd1, fd2);
|
||||
}
|
||||
|
||||
FileDescriptor duplicateForMapping(FileDescriptor fd) {
|
||||
// file descriptor not required for mapping operations; okay
|
||||
// to return invalid file descriptor.
|
||||
|
@ -176,6 +180,8 @@ class FileDispatcherImpl extends FileDispatcher {
|
|||
|
||||
static native void preClose0(FileDescriptor fd) throws IOException;
|
||||
|
||||
static native void dup0(FileDescriptor fd1, FileDescriptor fd2) throws IOException;
|
||||
|
||||
static native void closeIntFD(int fd) throws IOException;
|
||||
|
||||
static native int setDirect0(FileDescriptor fd) throws IOException;
|
||||
|
|
|
@ -311,6 +311,14 @@ Java_sun_nio_ch_FileDispatcherImpl_preClose0(JNIEnv *env, jclass clazz, jobject
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_nio_ch_FileDispatcherImpl_dup0(JNIEnv *env, jobject this, jobject fdo1, jobject fdo2)
|
||||
{
|
||||
if (dup2(fdval(env, fdo1), fdval(env, fdo2)) < 0) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_nio_ch_FileDispatcherImpl_closeIntFD(JNIEnv *env, jclass clazz, jint fd)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue