Skip to content

Commit

Permalink
Fix a number of issues with the KQueue TFO support
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Aug 11, 2021
1 parent f253779 commit aeec6fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions transport-native-kqueue/src/main/c/netty_kqueue_bsdsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
Expand Down Expand Up @@ -83,7 +84,7 @@ static jlong netty_kqueue_bsdsocket_sendFile(JNIEnv* env, jclass clazz, jint soc
return res < 0 ? -err : 0;
}

static jint netty_kqueue_bsdsocket_connectx(JNIEnv* env,
static jint netty_kqueue_bsdsocket_connectx(JNIEnv* env, jclass clazz,
jint socketFd,
jint socketInterface,
jboolean sourceIPv6, jbyteArray sourceAddress, jint sourceScopeId, jint sourcePort,
Expand Down Expand Up @@ -114,7 +115,7 @@ static jint netty_kqueue_bsdsocket_connectx(JNIEnv* env,
endpoints.sae_srcaddrlen = srcaddrlen;
}

assert destinationAddress != NULL; // Java side will ensure destination is never null.
assert(destinationAddress != NULL); // Java side will ensure destination is never null.
if (-1 == netty_unix_socket_initSockaddr(env,
destinationIPv6, destinationAddress, destinationScopeId, destinationPort, &dstaddr, &dstaddrlen)) {
netty_unix_errors_throwIOException(env, "Destination address could not be converted to sockaddr.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private int connectx(InetSocketAddress source, InetSocketAddress destination, Io
destinationScopeId = 0;
destinationAddress = ipv4MappedIpv6Address(destinationInetAddress.getAddress());
}
int destinationPort = source.getPort();
int destinationPort = destination.getPort();

long iovAddress;
int iovCount;
Expand All @@ -162,7 +162,7 @@ private int connectx(InetSocketAddress source, InetSocketAddress destination, Io
destinationIPv6, destinationAddress, destinationScopeId, destinationPort,
flags, iovAddress, iovCount, iovDataLength);
if (result < 0) {
return ioResult("connectx", -result);
return ioResult("connectx", result);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public void run() {
static final short EVFILT_SOCK = evfiltSock();

// Flags for connectx(2)
static final int CONNECT_RESUME_ON_READ_WRITE = connectResumeOnReadWrite();
static final int CONNECT_DATA_IDEMPOTENT = connectDataIdempotent();
private static final int CONNECT_RESUME_ON_READ_WRITE = connectResumeOnReadWrite();
private static final int CONNECT_DATA_IDEMPOTENT = connectDataIdempotent();
static final int CONNECT_TCP_FASTOPEN = CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT;

static FileDescriptor newKQueue() {
Expand Down

0 comments on commit aeec6fa

Please sign in to comment.