Commit f1376f56 authored by Josh Aas's avatar Josh Aas
Browse files

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

parent d0f78b35
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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;
+2 −3
Original line number Diff line number Diff line
@@ -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.