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: Improve const-correctness of Lua bindings #9721

Merged
merged 1 commit into from Nov 13, 2020

Conversation

georgeto
Copy link
Contributor

Short description

Since LuaWrapper enforces const-correctness, a const (shared) pointer
to an object can only read members and call const methods.
Therefore we have to take care to use the const qualifier during
registration of constant lambda Lua function bindings.

An example where the absence of the const qualifier was problematic is
LuaRule, which invokes its user provided match function with a constant
DNSQuestion object. Because the functions of DNSQuestion lacked
the const qualifier (e.g. getTag()), it was not possible to call them
from within the LuaRule match function.

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)
  • checked that this code was merged to master

Since LuaWrapper enforces const-correctness, a const (shared) pointer
to an object can only read members and call const methods.
Therefore we have to take care to use the const qualifier during
registration of constant lambda Lua function bindings.

An example where the absence of the const qualifier was problematic is
LuaRule, which invokes its user provided match function with a constant
DNSQuestion object. Because the functions of DNSQuestion lacked
the const qualifier (e.g. getTag()), it was not possible to call them
from within the LuaRule match function.
@Habbie Habbie added the dnsdist label Nov 13, 2020
Copy link
Member

@rgacogne rgacogne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That PR looks great, thanks a lot!

@rgacogne rgacogne added this to the dnsdist-1.6.0 milestone Nov 13, 2020
@rgacogne rgacogne merged commit fa0fafa into PowerDNS:master Nov 13, 2020
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants