Skip to content
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

dnsdist: Fix short IOs over TCP #7974

Merged
merged 4 commits into from Jun 27, 2019

Conversation

@rgacogne
Copy link
Member

commented Jun 24, 2019

Short description

TCPIOHandler::tryRead() and TCPIOHandler::tryWrite() are supposed to update the position and read/write the remaining number of bytes based on the initial total number minus the position, so that the caller can just pass the exact same parameters on short reads/writes until it succeeds or an exception is raised, without having to care about updating the position and number of bytes to read/write.
Untested yet.

Supersedes #7971.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@rgacogne rgacogne added this to the dnsdist-1.4.0 milestone Jun 24, 2019

@rgacogne

This comment has been minimized.

Copy link
Member Author

commented Jun 24, 2019

Added some checks suggested by @omoerbeek and fixed the existing one, which compared the size of the buffer to the requested size, not the requested size minus the existing position.

@rgacogne rgacogne requested a review from omoerbeek Jun 24, 2019

@Habbie

This comment has been minimized.

Copy link
Member

commented Jun 24, 2019

Untested yet.

It fixes the problem in my test environment!

@rgacogne

This comment has been minimized.

Copy link
Member Author

commented Jun 24, 2019

I forgot to update my comment but I actually tested it in the meantime! I reproduced the issues with short reads and short writes with master, and confirmed that this PR fixed them.
I'll try to write a test for these cases, since it's already the second time I manage to introduce a bug in that exact spot.

@omoerbeek

This comment has been minimized.

Copy link
Member

commented Jun 24, 2019

I approved this, but now it looks to me like not all cases of tryRead were covered.

@omoerbeek
Copy link
Member

left a comment

Seems a few calls to tryRead were missed when converting the 3rd arg. There are 4 calls here,
line 1045 got converted, 1067 looks right, but 936 and 946 need fixing.

@omoerbeek omoerbeek self-requested a review Jun 24, 2019

Show resolved Hide resolved pdns/tcpiohandler.hh Outdated
@rgacogne

This comment has been minimized.

Copy link
Member Author

commented Jun 24, 2019

Seems a few calls to tryRead were missed when converting the 3rd arg. There are 4 calls here,
line 1045 got converted, 1067 looks right, but 936 and 946 need fixing.

You are mistaking TCPIOHandler::tryRead() and a static function named tryRead(), which exists because we don't speak DoT toward backends atm and so have no need for the filters abstraction. I have a WIP branch unifying those two.

@omoerbeek

This comment has been minimized.

Copy link
Member

commented Jun 24, 2019

Seems a few calls to tryRead were missed when converting the 3rd arg. There are 4 calls here,
line 1045 got converted, 1067 looks right, but 936 and 946 need fixing.

You are mistaking TCPIOHandler::tryRead() and a static function named tryRead(), which exists because we don't speak DoT toward backends atm and so have no need for the filters abstraction. I have a WIP branch unifying those two.

Ah, right. Did not spot that and jumped to conclusions. Having two conventions for the third arg is confusing...

@omoerbeek
Copy link
Member

left a comment

A second read

@rgacogne

This comment has been minimized.

Copy link
Member Author

commented Jun 26, 2019

Now with regression tests.

@rgacogne rgacogne merged commit 346c2d1 into PowerDNS:master Jun 27, 2019

23 checks passed

ci/circleci: build-auth Your tests passed on CircleCI!
Details
ci/circleci: build-auth-docs Your tests passed on CircleCI!
Details
ci/circleci: build-dnsdist Your tests passed on CircleCI!
Details
ci/circleci: build-dnsdist-docs Your tests passed on CircleCI!
Details
ci/circleci: build-recursor Your tests passed on CircleCI!
Details
ci/circleci: build-recursor-docs Your tests passed on CircleCI!
Details
ci/circleci: test-auth-algorithms Your tests passed on CircleCI!
Details
ci/circleci: test-auth-api Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-bind Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-gmysql Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-gpgsql Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-gsqlite3 Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-ldap Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-lmdb Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-mydns Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-odbc-mssql Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-odbc-sqlite3 Your tests passed on CircleCI!
Details
ci/circleci: test-auth-regress-tinydns Your tests passed on CircleCI!
Details
ci/circleci: test-dnsdist-regression Your tests passed on CircleCI!
Details
ci/circleci: test-recursor-api Your tests passed on CircleCI!
Details
ci/circleci: test-recursor-bulk Your tests passed on CircleCI!
Details
ci/circleci: test-recursor-regression Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@rgacogne rgacogne deleted the rgacogne:ddist-tcp-short-writes branch Jun 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.