if (fd->higher != NULL) { PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0); return PR_FAILURE; } top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER); top->dtor(top); return (fd->methods->close)(fd);
if (PR_IO_LAYER_HEAD == fd->identity) {  rv = fd->lower->methods->close(fd->lower); _PR_DestroyIOLayer(fd); return rv; } else if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {  lower = fd->lower;  top = PR_PopIOLayer(fd->higher, PR_TOP_IO_LAYER); top->dtor(top);  return (lower->methods->close(lower)); } else {  top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER); top->dtor(top); return (fd->methods->close)(fd); }
static PRStatus PR_CALLBACK pl_TopClose (PRFileDesc *fd){    PRFileDesc *top;    PR_ASSERT(fd != NULL);    PR_ASSERT(fd->lower != NULL);    PR_ASSERT(fd->secret == NULL);    PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);    if (fd->higher != NULL)    {        PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);        return PR_FAILURE;    }    top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);    top->dtor(top);    return (fd->methods->close)(fd);}