-
Notifications
You must be signed in to change notification settings - Fork 781
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
[dv/dpi] tcpserver single connection and retry select on EINTR #23889
base: integrated_dev
Are you sure you want to change the base?
[dv/dpi] tcpserver single connection and retry select on EINTR #23889
Conversation
Instead of asserting in `client_tryaccept` when a client is already attached, reject the new connection by accepting and immediately closing. Signed-off-by: Kip Walker <[email protected]>
heads up @sameo |
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.
Sorry for the very slow review. This looks sensible, but I think the second commit could be tweaked slightly.
// On interrupt we want to retry; according to the man page | ||
// the timeout is now undefined. | ||
timeout.tv_sec = 0; |
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.
I'm not completely sure about this bit. If I understand the man page correctly, it is just saying that the function might have trashed timeout (see the section called "The timeout").
So I don't think we need to do this change, but we should probably set all of timeout
every time, so just need to move the write to tv_sec
inside the loop.
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.
Duh. I've just re-read your change and now I understand what you're doing! I think it would still be much simpler to move this line to appear just before the write to tv_usec
. I think the existing code is a bit silly (because timeout.tv_sec
might get trashed even if the select
call succeeds), but the fix is very easy.
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.
Thanks for the feedback, I pushed an update.
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.
(oops, pushed again to remove the now-extraneous initial init of tv_sec
).
f93234f
to
26454af
Compare
When select returns -1 and errno is EINTR, the select should just be retried instead of treating it as an error and disconnecting the client. Also move the timeout initialization into the loop right before calling select, since it can get trashed. Signed-off-by: Kip Walker <[email protected]>
26454af
to
c60bfe7
Compare
Two small patches to the
tcp_server
code, used by other transactors such asjtagdpi
anddmidpi
. These improve the usability of the transactors in a shared, remote environment such as an emulator.Without this change, an interrupted select() call is treated as a connection error and the client is dropped. This makes connections very unstable.