-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Providing a more fair servicing of multiple clients by not picking lowest numbered socket in available() #4463
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
base: master
Are you sure you want to change the base?
Conversation
This change looks useful to me. AFAIU, it allows for a more fair servicing of multiple connections right? Perhaps the commit message could expand on this a bit more. |
Your new commit looks good to me, I think the code is fine as it is. Your new commit message is also very good (except for a few spelling errors :-p) Could you perhaps merge both commits into a single commit? That would lead to clearer history if this is merged. |
I modified `EthernetServer::available()` such that it will not always pick the socket with the lowest number that has data available. Instead when the method returned the client at socket i, it will check socket (i+1) % MAX_SOCK_NUM first when then method is called the next time. The problem with the previous implementation is that if there is a client connected to a socket with a low number (e.g. the first one with number 0) and the peer constantly sends data. In that case `EthernetServer::available()` always returns that client. The clients, which are connected to a socket with a higher number (e.g. 1, 2, or 3), can only be returned when the ones with lower numbers have no data available. This problem is fixed with this commit. This commit also implements the changes suggested by @matthijskooijman.
Ok. Well I have a few git related problems with that: |
You can use |
ok thanks. |
This comment has been minimized.
This comment has been minimized.
Sorry closed by mistake |
I modified
EthernetServer::available()
such that it will not always pick thelowest numbered socket by introducing an internal index
int _sock
which is incremented by one every timeavailable()
is called. (I suppose the previous comment XXX: don't always pick the lowest numbered socket. was to be understood as a TODO)