Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsSocketTransport2.cpp File Reference
#include "nsSocketTransport2.h"
#include "nsIOService.h"
#include "nsStreamUtils.h"
#include "nsNetSegmentUtils.h"
#include "nsTransportUtils.h"
#include "nsProxyInfo.h"
#include "nsNetCID.h"
#include "nsAutoLock.h"
#include "nsCOMPtr.h"
#include "netCore.h"
#include "nsInt64.h"
#include "prmem.h"
#include "pratom.h"
#include "plstr.h"
#include "prnetdb.h"
#include "prerror.h"
#include "prerr.h"
#include "nsIServiceManager.h"
#include "nsIProxyObjectManager.h"
#include "nsISocketProviderService.h"
#include "nsISocketProvider.h"
#include "nsISSLSocketControl.h"
#include "nsIPipe.h"

Go to the source code of this file.

Classes

class  nsSocketEvent

Functions

static NS_DEFINE_CID (kSocketProviderServiceCID, NS_SOCKETPROVIDERSERVICE_CID)
static NS_DEFINE_CID (kDNSServiceCID, NS_DNSSERVICE_CID)
static nsresult ErrorAccordingToNSPR (PRErrorCode errorCode)
 NS_IMPL_QUERY_INTERFACE2 (nsSocketInputStream, nsIInputStream, nsIAsyncInputStream) nsSocketInputStream
 NS_IMPL_QUERY_INTERFACE2 (nsSocketOutputStream, nsIOutputStream, nsIAsyncOutputStream) nsSocketOutputStream
 NS_IMPL_THREADSAFE_ISUPPORTS3 (nsSocketTransport, nsISocketTransport, nsITransport, nsIDNSListener) NS_IMETHODIMP nsSocketTransport

Function Documentation

static nsresult ErrorAccordingToNSPR ( PRErrorCode  errorCode) [static]

Definition at line 159 of file nsSocketTransport2.cpp.

{
    nsresult rv;
    switch (errorCode) {
    case PR_WOULD_BLOCK_ERROR:
        rv = NS_BASE_STREAM_WOULD_BLOCK;
        break;
    case PR_CONNECT_ABORTED_ERROR:
    case PR_CONNECT_RESET_ERROR:
        rv = NS_ERROR_NET_RESET;
        break;
    case PR_END_OF_FILE_ERROR: // XXX document this correlation
        rv = NS_ERROR_NET_INTERRUPT;
        break;
    case PR_CONNECT_REFUSED_ERROR:
    case PR_NETWORK_UNREACHABLE_ERROR: // XXX need new nsresult for this!
    case PR_HOST_UNREACHABLE_ERROR:    // XXX and this!
    case PR_ADDRESS_NOT_AVAILABLE_ERROR:
    // Treat EACCES as a soft error since (at least on Linux) connect() returns
    // EACCES when an IPv6 connection is blocked by a firewall. See bug 270784.
    case PR_ADDRESS_NOT_SUPPORTED_ERROR:
    case PR_NO_ACCESS_RIGHTS_ERROR:
        rv = NS_ERROR_CONNECTION_REFUSED;
        break;
    case PR_IO_TIMEOUT_ERROR:
    case PR_CONNECT_TIMEOUT_ERROR:
        rv = NS_ERROR_NET_TIMEOUT;
        break;
    default:
        rv = NS_ERROR_FAILURE;
    }
    LOG(("ErrorAccordingToNSPR [in=%d out=%x]\n", errorCode, rv));
    return rv;
}

Here is the caller graph for this function:

static NS_DEFINE_CID ( kSocketProviderServiceCID  ,
NS_SOCKETPROVIDERSERVICE_CID   
) [static]
static NS_DEFINE_CID ( kDNSServiceCID  ,
NS_DNSSERVICE_CID   
) [static]

Definition at line 244 of file nsSocketTransport2.cpp.

{
    PR_AtomicIncrement((PRInt32*)&mReaderRefCnt);
    return mTransport->AddRef();
}

Here is the call graph for this function:

Definition at line 492 of file nsSocketTransport2.cpp.

{
    PR_AtomicIncrement((PRInt32*)&mWriterRefCnt);
    return mTransport->AddRef();
}

Here is the call graph for this function:

Definition at line 1580 of file nsSocketTransport2.cpp.

{
    LOG(("nsSocketTransport::OpenInputStream [this=%x flags=%x]\n",
        this, flags));

    NS_ENSURE_TRUE(!mInput.IsReferenced(), NS_ERROR_UNEXPECTED);

    nsresult rv;
    nsCOMPtr<nsIAsyncInputStream> pipeIn;

    if (!(flags & OPEN_UNBUFFERED) || (flags & OPEN_BLOCKING)) {
        // XXX if the caller wants blocking, then the caller also gets buffered!
        //PRBool openBuffered = !(flags & OPEN_UNBUFFERED);
        PRBool openBlocking =  (flags & OPEN_BLOCKING);

        net_ResolveSegmentParams(segsize, segcount);
        nsIMemory *segalloc = net_GetSegmentAlloc(segsize);

        // create a pipe
        nsCOMPtr<nsIAsyncOutputStream> pipeOut;
        rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut),
                         !openBlocking, PR_TRUE, segsize, segcount, segalloc);
        if (NS_FAILED(rv)) return rv;

        // async copy from socket to pipe
        rv = NS_AsyncCopy(&mInput, pipeOut, gSocketTransportService,
                          NS_ASYNCCOPY_VIA_WRITESEGMENTS, segsize);
        if (NS_FAILED(rv)) return rv;

        *result = pipeIn;
    }
    else
        *result = &mInput;

    // flag input stream as open
    mInputClosed = PR_FALSE;

    rv = PostEvent(MSG_ENSURE_CONNECT);
    if (NS_FAILED(rv)) return rv;

    NS_ADDREF(*result);
    return NS_OK;
}

Here is the call graph for this function: