예제 #1
0
파일: layer.c 프로젝트: bringhurst/vbox
static PRFileDesc *PopLayer(PRFileDesc *stack)
{
    PRFileDesc *popped = PR_PopIOLayer(stack, identity);
    if (verbosity > quiet)
        PR_fprintf(logFile, "Popped layer(0x%x) from stack(0x%x)\n", popped, stack);
    popped->dtor(popped);
    
    return stack;
}  /* PopLayer */
예제 #2
0
/*
** Default methods that just call down to the next fd.
*/
static PRStatus PR_CALLBACK pl_TopClose (PRFileDesc *fd)
{
    PRFileDesc *top, *lower;
    PRStatus rv;

    PR_ASSERT(fd != NULL);
    PR_ASSERT(fd->lower != NULL);
    PR_ASSERT(fd->secret == NULL);
    PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);

    if (PR_IO_LAYER_HEAD == fd->identity) {
        /*
         * new style stack; close all the layers, before deleting the
         * stack head
         */
        rv = fd->lower->methods->close(fd->lower);
        _PR_DestroyIOLayer(fd);
        return rv;
    } else if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {
        /*
         * lower layers of new style stack
         */
        lower = fd->lower;
        /*
         * pop and cleanup current layer
         */
        top = PR_PopIOLayer(fd->higher, PR_TOP_IO_LAYER);
        top->dtor(top);
        /*
         * then call lower layer
         */
        return (lower->methods->close(lower));
    } else {
        /* old style stack */
        top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);
        top->dtor(top);
        return (fd->methods->close)(fd);
    }
}
예제 #3
0
static PRStatus
TcpUdpPRCloseLayerClose(PRFileDesc *aFd)
{
  if (!aFd) {
    return PR_FAILURE;
  }

  PRFileDesc* layer = PR_PopIOLayer(aFd, PR_TOP_IO_LAYER);
  MOZ_RELEASE_ASSERT(layer &&
                     layer->identity == sTcpUdpPRCloseLayerId,
                     "Closing Layer not on top of stack");

  ClosingLayerSecret *closingLayerSecret =
    reinterpret_cast<ClosingLayerSecret *>(layer->secret);

  PRStatus status = PR_SUCCESS;

  if (aFd) {
    // If this is called during shutdown do not call ..method->close(fd) and
    // let it leak.
    if (gIOService->IsShutdown()) {
      // If the ClosingService layer is the first layer above PR_NSPR_IO_LAYER
      // we are not going to leak anything, but the PR_Close will not be called.
      PR_Free(aFd);
    } else if (closingLayerSecret->mClosingService) {
      closingLayerSecret->mClosingService->PostRequest(aFd);
    } else {
      // Socket is created before closing service has been started or there was
      // a problem with starting it.
      PR_Close(aFd);
    }
  }

  layer->secret = nullptr;
  layer->dtor(layer);
  delete closingLayerSecret;
  return status;
}