Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sauerburger
Copy link

I modified EthernetServer::available() such that it will not always pick the
lowest numbered socket by introducing an internal index int _sock which is incremented by one every time available() is called. (I suppose the previous comment XXX: don't always pick the lowest numbered socket. was to be understood as a TODO)

@matthijskooijman
Copy link
Collaborator

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.

@sauerburger sauerburger changed the title doesn't pick lowest numbered socket in available() Providing a more fair servicing of multiple clients by not picking lowest numbered socket in available() Jan 21, 2016
@matthijskooijman
Copy link
Collaborator

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.
@sauerburger
Copy link
Author

Ok. Well I have a few git related problems with that:
I merged the commits with git rebase, but as I expected I could not push them, so I pushed them to a new branch. Do you know if I can change the source branch of this merge request? If thats impossible should I create a new merge request?

@matthijskooijman
Copy link
Collaborator

You can use git push -f to force push and overwrite the existing branch. Github will then update the commits in this PR automatically.

@sauerburger
Copy link
Author

ok thanks.

@agdl

This comment has been minimized.

@agdl agdl closed this Jul 12, 2016
@agdl
Copy link
Member

agdl commented Jul 12, 2016

Sorry closed by mistake

@agdl agdl reopened this Jul 12, 2016
@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library: Ethernet The Ethernet Arduino library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants