forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dns: fix crash using dns.setServers after resolve4
The callback function in cares_query is synchronous and called before closed. So dns.setServers in the synchronous callback before closed will occur crashing. Fixes: nodejs#894 Refs: https://github.com/nodejs/node/blob/v6.9.4/deps/cares/src/ares_process.c#L1332-L1333 Refs: https://github.com/OpenSIPS/opensips/blob/2.3.0/proxy.c PR-URL: nodejs#13050 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
Showing
2 changed files
with
162 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/internet/test-dns-setserver-in-callback-of-resolve4.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
// We don't care about `err` in the callback function of `dns.resolve4`. We just | ||
// want to test whether `dns.setServers` that is run after `resolve4` will cause | ||
// a crash or not. If it doesn't crash, the test succeeded. | ||
|
||
const common = require('../common'); | ||
const dns = require('dns'); | ||
|
||
dns.resolve4('google.com', common.mustCall(function(/* err, nameServers */) { | ||
dns.setServers([ '8.8.8.8' ]); | ||
})); |