-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple Unix from Linux in Native Transport #4335
Conversation
@normanmaurer @nmittler @trustin - FYI |
super(parent, fd.intValue()); | ||
} | ||
|
||
/** | ||
* Creates a new {@link EpollDomainSocketChannel} from an existing {@link FileDescriptor} | ||
*/ | ||
public EpollDomainSocketChannel(FileDescriptor fd) { | ||
super(fd); | ||
public EpollDomainSocketChannel(Socket fd, boolean active) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@normanmaurer - I spent a bunch of time debugging an issue related to the socket was marked as active because getSoError()
returned 0
, but then SslHandler.handlerAdded initiated the handshake, which involved doing a write before the FD was actually connected. This results in a rather nebulous channel closed exception which was difficult to track down (the root cause was a 107 - Transport endpoint is not connected
as a result of writeAddress). I changed the API here just to discuss ... 1. do you have an example of a time when someone creates an FD and it is already active (as determined by getSoError)? 2. If so I will add another constructor which sets active based upon getSoError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@normanmaurer - I deprecated all the constructors that appear to be misleading and may get users into trouble.
6347e33
to
2eb786c
Compare
b153586
to
a2a6476
Compare
@normanmaurer - PTAL |
@Scottmitch took a cursory glance ... looks great! I'll defer to @normanmaurer for a detailed review :) |
@nmittler - Thanks :) Hopefully paves the way for broader unix support. |
a2a6476
to
9d2212e
Compare
@@ -0,0 +1,191 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Scottmitch love that this is now in an extra file 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄
private static final long serialVersionUID = 3094819287843178401L; | ||
|
||
// holds the amount of received bytes | ||
final int receivedAmount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@Scottmitch all in all I love this PR! Makes stuff a lot cleaner. Good work, just a few comments buddy! |
9d2212e
to
381912b
Compare
@Scottmitch let us release a new 4.0 and 4.1 before we pull this in so we have a bit more time to test this. WDYT ? |
@normanmaurer - I think that is a good idea. However I have PR #4336 based off of this PR right now which should prolly go in... |
@Scottmitch can you maybe refactor #4336 so we can pull it in on the "original" code ? |
this pr broke my build. #include <unistd.h> |
3 places to fix @Scottmitch and my build process is ok |
Yeah i guess missing #include <unistd.h>
|
381912b
to
6834851
Compare
@ninja- - Thanks for the comments. The issues you pointed out should be resolved now. |
@Scottmitch can your 2 epoll PRs be merged ? I am having a hard time rebasing on them every time |
@Scottmitch your pr still has build errors. somehow github wiped my on-line comments when I mentioned fix for the last 3 of them |
diff --git a/transport-native-epoll/src/main/c/io_netty_channel_unix_FileDescriptor.c b/transport-native-epoll/src/main/c/io_netty_channel_unix_FileDescriptor.c
index 9ad191c..abcc82b 100644
--- a/transport-native-epoll/src/main/c/io_netty_channel_unix_FileDescriptor.c
+++ b/transport-native-epoll/src/main/c/io_netty_channel_unix_FileDescriptor.c
@@ -17,6 +17,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/uio.h>
+#include <unistd.h>
#include "netty_unix_errors.h"
#include "netty_unix_filedescriptor.h"
diff --git a/transport-native-epoll/src/main/c/io_netty_channel_unix_Socket.c b/transport-native-epoll/src/main/c/io_netty_channel_unix_Socket.c
index de73777..2f39fce 100644
--- a/transport-native-epoll/src/main/c/io_netty_channel_unix_Socket.c
+++ b/transport-native-epoll/src/main/c/io_netty_channel_unix_Socket.c
@@ -23,8 +23,10 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <arpa/inet.h>
#include "netty_unix_socket.h"
+#include "netty_unix_errors.h"
#include "io_netty_channel_unix_Socket.h"
static jclass datagramSocketAddressClass = NULL;
diff --git a/transport-native-epoll/src/main/c/netty_unix_errors.h b/transport-native-epoll/src/main/c/netty_unix_errors.h
index ba3ad5d..e23f383 100644
--- a/transport-native-epoll/src/main/c/netty_unix_errors.h
+++ b/transport-native-epoll/src/main/c/netty_unix_errors.h
@@ -27,7 +27,7 @@ void netty_unix_errors_throwClosedChannelException(JNIEnv* env);
void netty_unix_errors_throwOutOfMemoryError(JNIEnv* env);
// JNI initialization hooks. Users of this file are responsible for calling these in the JNI_OnLoad and JNI_OnUnload methods.
-jint netty_unix_exceptions_JNI_OnLoad(JNIEnv* env);
-void netty_unix_exceptions_JNI_OnUnLoad(JNIEnv* env);
+jint netty_unix_errors_JNI_OnLoad(JNIEnv* env);
+void netty_unix_errors_JNI_OnUnLoad(JNIEnv* env);
#endif /* NETTY_UNIX_ERRORS_H_ */ |
@Scottmitch @ninja- actually I want to cut a release first (over the next days) and after that merge in as this is a massive change-set and I want to test it a bit more. |
@ninja- I think I already fixed the issues the first time around (checkout the "Files" in github on this PR) ... maybe you are looking at old code? |
@Scottmitch hm ok maybe I forgot to git fetch your branch |
6834851
to
1b9796c
Compare
@Scottmitch just cherry-pick it, so we can move on |
Motivation: transport-native-epoll is designed to be specific to Linux. However there is native code that can be extracted out and made to work on more Unix like distributions. There are a few steps to be completely decoupled but the first step is to extract out code that can run in a more general Unix environment from the Linux specific code base. Modifications: - Move all non-Linux specific stuff from Native.java into the io.netty.channel.unix package. - io.netty.channel.unix.FileDescriptor will inherit all the native methods that are specific to file descriptors. - io_netty_channel_epoll_Native.[c|h] will only have code that is specific to Linux. Result: Code is decoupled and design is streamlined in FileDescriptor.
1b9796c
to
b7b672e
Compare
Motivation:
transport-native-epoll is designed to be specific to Linux. However there is native code that can be extracted out and made to work on more Unix like distributions. There are a few steps to be completely decoupled but the first step is to extract out code that can run in a more general Unix environment from the Linux specific code base.
Modifications:
Result:
Code is decoupled and design is streamlined in FileDescriptor.