Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
prpolevt.c File Reference
#include "prinit.h"
#include "prio.h"
#include "prmem.h"
#include "prerror.h"
#include "prlog.h"

Go to the source code of this file.

Classes

struct  PRFilePrivate

Defines

#define USE_TCP_SOCKETPAIR

Functions

PRIntn _PR_InvalidInt (void)
PRInt64 _PR_InvalidInt64 (void)
PRStatus _PR_InvalidStatus (void)
PRFileDesc_PR_InvalidDesc (void)
static PRStatus PR_CALLBACK _pr_PolEvtClose (PRFileDesc *fd)
static PRInt16 PR_CALLBACK _pr_PolEvtPoll (PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags)
static PRStatus PR_CALLBACK _pr_PolEvtInit (void)
 PR_IMPLEMENT (PRFileDesc *)
 PR_IMPLEMENT (PRStatus)

Variables

static PRIOMethods _pr_polevt_methods
static PRDescIdentity _pr_polevt_id
static PRCallOnceType _pr_polevt_once_control
static const char magicChar = '\x38'

Class Documentation

struct PRFilePrivate

Definition at line 1728 of file primpl.h.

Collaboration diagram for PRFilePrivate:
Class Members
PRBool appendMode
_PRTriStateBool inheritable
PRIntn lockCount
_MDFileDesc md
PRFileDesc * next
PRBool nonblocking
PRInt32 rcvinprogress
PRInt32 rcvreq
RcvState rcvstate
PRInt32 state
PRFileDesc * writeEnd
PRInt32 xmtinprogress
PRInt32 xmtreq
XmtState xmtstate

Define Documentation

Definition at line 410 of file prpolevt.c.


Function Documentation

Definition at line 122 of file priometh.c.

{
    PR_ASSERT(!"I/O method is invalid");
    PR_SetError(PR_INVALID_METHOD_ERROR, 0);
    return NULL;
}  /* _PR_InvalidDesc */
PRIntn _PR_InvalidInt ( void  )

Definition at line 84 of file priometh.c.

{
    PR_ASSERT(!"I/O method is invalid");
    PR_SetError(PR_INVALID_METHOD_ERROR, 0);
    return -1;
}  /* _PR_InvalidInt */

Definition at line 98 of file priometh.c.

{
    PRInt64 rv;
    LL_I2L(rv, -1);
    PR_ASSERT(!"I/O method is invalid");
    PR_SetError(PR_INVALID_METHOD_ERROR, 0);
    return rv;
}  /* _PR_InvalidInt */

Definition at line 111 of file priometh.c.

{
    PR_ASSERT(!"I/O method is invalid");
    PR_SetError(PR_INVALID_METHOD_ERROR, 0);
    return PR_FAILURE;
}  /* _PR_InvalidDesc */
static PRStatus PR_CALLBACK _pr_PolEvtClose ( PRFileDesc fd) [static]

Definition at line 476 of file prpolevt.c.

{
    PRFileDesc *event;

    event = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);
    PR_ASSERT(NULL == event->higher && NULL == event->lower);
    PR_Close(fd);
    PR_Close(event->secret->writeEnd);
    PR_DELETE(event->secret);
    event->dtor(event);
    return PR_SUCCESS;
}
static PRStatus PR_CALLBACK _pr_PolEvtInit ( void  ) [static]

Definition at line 400 of file prpolevt.c.

{
    _pr_polevt_id = PR_GetUniqueIdentity("NSPR pollable events");
    if (PR_INVALID_IO_LAYER == _pr_polevt_id) {
        return PR_FAILURE;
    }
    return PR_SUCCESS;
}

Here is the caller graph for this function:

static PRInt16 PR_CALLBACK _pr_PolEvtPoll ( PRFileDesc fd,
PRInt16  in_flags,
PRInt16 out_flags 
) [static]

Definition at line 394 of file prpolevt.c.

{
    return (fd->lower->methods->poll)(fd->lower, in_flags, out_flags);
}

Definition at line 413 of file prpolevt.c.

{
    PRFileDesc *event;
    PRFileDesc *fd[2]; /* fd[0] is the read end; fd[1] is the write end */
#ifdef USE_TCP_SOCKETPAIR
    PRSocketOptionData socket_opt;
    PRStatus rv;
#endif

    fd[0] = fd[1] = NULL;

    if (PR_CallOnce(&_pr_polevt_once_control, _pr_PolEvtInit) == PR_FAILURE) {
        return NULL;
    }

    event = PR_CreateIOLayerStub(_pr_polevt_id, &_pr_polevt_methods);
    if (NULL == event) {
        goto errorExit;
    } 
    event->secret = PR_NEW(PRFilePrivate);
    if (event->secret == NULL) {
        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
        goto errorExit;
    }

#ifndef USE_TCP_SOCKETPAIR
    if (PR_CreatePipe(&fd[0], &fd[1]) == PR_FAILURE) {
        fd[0] = fd[1] = NULL;
        goto errorExit;
    }
#else
    if (PR_NewTCPSocketPair(fd) == PR_FAILURE) {
        fd[0] = fd[1] = NULL;
        goto errorExit;
    }
       /*
        * set the TCP_NODELAY option to reduce notification latency
        */
    socket_opt.option = PR_SockOpt_NoDelay;
    socket_opt.value.no_delay = PR_TRUE;
    rv = PR_SetSocketOption(fd[1], &socket_opt);
    PR_ASSERT(PR_SUCCESS == rv);
#endif

    event->secret->writeEnd = fd[1];
    if (PR_PushIOLayer(fd[0], PR_TOP_IO_LAYER, event) == PR_FAILURE) {
        goto errorExit;
    }

    return fd[0];

errorExit:
    if (fd[0]) {
        PR_Close(fd[0]);
        PR_Close(fd[1]);
    }
    if (event) {
        PR_DELETE(event->secret);
        event->dtor(event);
    }
    return NULL;
}

Here is the call graph for this function:

Definition at line 489 of file prpolevt.c.

{
    return PR_Close(event);
}

Variable Documentation

Definition at line 390 of file prpolevt.c.

Definition at line 351 of file prpolevt.c.

Definition at line 391 of file prpolevt.c.

const char magicChar = '\x38' [static]

Definition at line 494 of file prpolevt.c.