Bug 766973: Don't allow synchronous DNS queries from the main thread. r=sworkman

This commit is contained in:
Josh Aas 2012-09-29 00:50:59 -04:00
parent 6174824ed2
commit 64654ac744
2 changed files with 11 additions and 3 deletions

View File

@ -687,6 +687,15 @@ nsDNSService::Resolve(const nsACString &hostname,
uint32_t flags,
nsIDNSRecord **result)
{
NS_WARNING("Do not use synchronous DNS resolution! This API may be removed soon.");
// We will not allow this to be called on the main thread. This is transitional
// and a bit of a test for removing the synchronous API entirely.
if (NS_IsMainThread()) {
NS_ERROR("Synchronous DNS resolve failing - not allowed on the main thread!");
return NS_ERROR_FAILURE;
}
// grab reference to global host resolver and IDN service. beware
// simultaneous shutdown!!
nsRefPtr<nsHostResolver> res;

View File

@ -59,9 +59,8 @@ interface nsIDNSService : nsISupports
in nsresult aReason);
/**
* called to synchronously resolve a hostname. warning this method may
* block the calling thread for a long period of time. it is extremely
* unwise to call this function on the UI thread of an application.
* Called to synchronously resolve a hostname. This method will fail
* if called from the main thread.
*
* @param aHostName
* the hostname or IP-address-literal to resolve.