Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

SimpleLogSink shouldn't perform DNS lookups #39

Closed
osi opened this Issue · 3 comments

2 participants

@osi
Collaborator

SimpleLogSink performs a DNS when formatting log entries.

If the examples are following, using a LogginHandler with a SimpleLogSink, all of a sudden there's a blocking DNS request occurring on the main I/O thread.

By default, SimpleLogSink should not perform DNS resolution when logging remote addresses.

@KushalP
Collaborator

@osi just for context, are you referring to this: https://github.com/joewalnes/webbit/blob/8698b98d9491d710a8b0022b19d9568481e647d9/src/main/java/org/webbitserver/handler/logging/SimpleLogSink.java#L194 ?

A hacky way around it could be to launch a separate thread which calls getHostName() and then returns the value it finds (or doesn't after timeout). The problem with this ends up being the wait time, which will affect how logs are ordered if there is any significant delay.

I'm not a networking expert, so I'm open to hearing/learning about better alternatives to this.

@osi
Collaborator

it should just return address.toString() always. logs can be post-processed for DNS resolution later.

@KushalP
Collaborator

I guess as SocketAddress is an abstract class it's safe to assume we'll be getting some sub-class of it.

Putting in a change now.

@KushalP KushalP closed this issue from a commit
@KushalP KushalP Stop blocking SimpleLogSink with InetSocketAddress.getHostName(). Clo…
…ses #39.


Rather than casting (if instance of InetSocketAddress) directly give back SocketAddress.toString() rather than blocking. This way the casting can be handled in post-processing of logs. An alternative would be to ship this off to another thread, but then logs wouldn't be deterministic.
b17cb8f
@KushalP KushalP closed this in b17cb8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.