Fix some segfaults caused when lots of DNS changes occur.

Unfortunately, I can't figure out how to add a reproducible test case
around this in this isolated environment, but these fixes seem to mostly
fix this.

However, while this seems to fix the majority of segfaults, there still
seems to be some more rare worker segfaults that can crop up when
keepalive is enabled and lots of DNS changes are happening under a high
request load. Still trying to figure out the best way to solve that.