LOGERROR(("PR_PushIOLayer() failed. rv = %x.", rv));
nsSOCKSIOLayerAddToSocket(const char *host,                           PRInt32 port,                          const char *proxyHost,                          PRInt32 proxyPort,                          PRFileDesc *fd,                           nsISupports** info){    if (firstTime)    {        nsSOCKSIOLayerIdentity		= PR_GetUniqueIdentity("SOCKS layer");        nsSOCKSIOLayerMethods		= *PR_GetDefaultIOMethods();                nsSOCKSIOLayerMethods.connect	= nsSOCKSIOLayerConnect;        nsSOCKSIOLayerMethods.bind	= nsSOCKSIOLayerBind;        nsSOCKSIOLayerMethods.acceptread = nsSOCKSIOLayerAcceptRead;        nsSOCKSIOLayerMethods.getsockname = nsSOCKSIOLayerGetName;        nsSOCKSIOLayerMethods.getpeername = nsSOCKSIOLayerGetPeerName;        nsSOCKSIOLayerMethods.accept	= nsSOCKSIOLayerAccept;        nsSOCKSIOLayerMethods.listen	= nsSOCKSIOLayerListen;        nsSOCKSIOLayerMethods.close	= nsSOCKSIOLayerClose;                firstTime			= PR_FALSE;    }            PRFileDesc *	layer;    PRStatus	rv;        layer = PR_CreateIOLayerStub(nsSOCKSIOLayerIdentity, &nsSOCKSIOLayerMethods);    if (! layer)    {        return NS_ERROR_FAILURE;    }        nsSOCKSSocketInfo * infoObject = new nsSOCKSSocketInfo();    if (!infoObject)    {        // clean up IOLayerStub        PR_DELETE(layer);        return NS_ERROR_FAILURE;    }        NS_ADDREF(infoObject);    infoObject->SetProxyHost(proxyHost);    infoObject->SetProxyPort(proxyPort);    layer->secret = (PRFilePrivate*) infoObject;    rv = PR_PushIOLayer(fd, PR_GetLayersIdentity(fd), layer);        if (NS_FAILED(rv))    {        NS_RELEASE(infoObject);        PR_DELETE(layer);        return NS_ERROR_FAILURE;    }        *info = infoObject;    NS_ADDREF(*info);    return NS_OK;}