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

out of order handling of tcp queries #646

Closed
miekg opened this issue Mar 17, 2018 · 5 comments
Closed

out of order handling of tcp queries #646

miekg opened this issue Mar 17, 2018 · 5 comments

Comments

@miekg
Copy link
Owner

miekg commented Mar 17, 2018

Right now this is serial because: https://github.com/miekg/dns/blob/master/server.go#L567
If we put go in front of that it is out of order.

However I'm not fully convinced the response.Writer deals ok with this; should there be a mutex there?

@miekg
Copy link
Owner Author

miekg commented Mar 17, 2018

A simple diff works:

diff --git a/server.go b/server.go
index 685753f..8248508 100644
--- a/server.go
+++ b/server.go
@@ -564,7 +564,7 @@ Redo:
                        w.tsigRequestMAC = req.Extra[len(req.Extra)-1].(*TSIG).MAC
                }
        }
-       h.ServeDNS(w, req) // Writes back to the client
+       go h.ServeDNS(w, req) // Writes back to the client
 
 Exit:
        if w.tcp == nil {
@@ -712,7 +712,6 @@ func (w *response) Close() error {
        // Can't close the udp conn, as that is actually the listener.
        if w.tcp != nil {
                e := w.tcp.Close()
-               w.tcp = nil
                return e
        }
        return nil

but shows up in a test failure in CoreDNS (data-race on axfr), on setting specific dns.ResponseWriter fields; so that thing would indeed need a mutex, also for writing the reply back to the client.

Now this only comes up when using TCP and DNS over TLS and responding to out-of-order request, for UDP we dont' care.

@tmthrgd
Copy link
Collaborator

tmthrgd commented Mar 18, 2018

@miekg This change is far more complex than adding a go and a mutex. I can take a closer look in the morning.

(Has this come up as a bottleneck somewhere?)

@miekg
Copy link
Owner Author

miekg commented Mar 18, 2018 via email

@tmthrgd
Copy link
Collaborator

tmthrgd commented Mar 19, 2018

@miekg I took a look at rewriting the serve method with the intention of allowing this change.

It's looking like it's impossible to make this work with the Hijack method. I'm not sure how useful the Hijack method is in general, or what the intention behind it was, but I doubt it's possible to remove it while keeping it backward compatible.

@miekg
Copy link
Owner Author

miekg commented Nov 28, 2018

Can't be done in current architecture; also DoT is quite bad for performance etc. etc.

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants