rpc_as.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1993,1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* Taken from 4.1.3 ypserv resolver code. */
#include "rpc_as.h"
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <poll.h>
#include <string.h>
extern void cleanup(int);
#define POLLFD_EXTEND 512
static rpc_as **rpc_as_handles;
static pollfd_t *rpc_as_pollset;
static int rpc_as_max_pollfd = -1;
static int rpc_as_pollfd_allocd = 0;
pollfd_t *
{
return (rpc_as_pollset);
}
int
{
return (rpc_as_max_pollfd);
}
static bool_t rpc_as_init()
{
int i;
if (rpc_as_handles != NULL)
return (TRUE);
rpc_as_handles = (rpc_as **)
if (rpc_as_handles == NULL) {
return (FALSE);
}
if (rpc_as_pollset == NULL) {
return (FALSE);
}
for (i = 0; i < rpc_as_pollfd_allocd; i++) {
rpc_as_pollset[i].events = 0;
rpc_as_pollset[i].revents = 0;
rpc_as_handles[i] = NULL;
}
return (TRUE);
}
/*
* Activate a asynchronous handle.
*/
int
{
return (-1);
return (-1); /* can't register less than zero */
/*
* If the descriptor is bigger than the pollset and handles
* array, grow it by POLLFD_EXTEND until it is large enough.
*/
int i = rpc_as_pollfd_allocd;
do {
sizeof (pollfd_t) * rpc_as_pollfd_allocd);
rpc_as_pollfd_allocd = i;
return (-1);
}
sizeof (rpc_as *) * rpc_as_pollfd_allocd);
rpc_as_pollfd_allocd = i;
return (-1);
}
/*
* Initialize the new elements
*/
for (; i < rpc_as_pollfd_allocd; i++) {
rpc_as_pollset[i].events = 0;
rpc_as_pollset[i].revents = 0;
rpc_as_handles[i] = NULL;
}
}
return (0);
}
static void
remove_pollfd(int fd)
{
return;
/*
* Don't shrink handles, pollset, or rpc_as_max_pollfd for now
*/
}
/*
* De-activate an asynchronous handle.
*/
int
{
return (-1);
return (-1); /* can't unregister less than zero */
return (0);
}
return (-1);
}
/*
* Check through each element of the poll set looking for returned
* events, if found and it corresponds to an active xprt, call as_recv
* and decrement pollretval so a later svc_getreq_poll can
* be called.
*/
void
{
int i;
return;
for (i = 0; i <= rpc_as_max_pollfd; i++) {
if (p->revents) {
/* fd has input waiting */
remove_pollfd(p->fd);
*pollretval -= 1;
continue;
}
if (xprt) {
else
(void) rpc_as_unregister(xprt);
/*
* Clear the event
*/
p->revents = 0;
*pollretval -= 1;
}
}
}
}
struct timeval
{
int tsecs;
int tusecs;
int sock;
return (ans);
/* Calculate elapsed time */
} else {
tsecs = 0;
tusecs = 0;
}
while (tusecs < 0) {
tusecs += 1000000;
tsecs--;
}
if (tsecs < 0)
tsecs = 0;
continue;
}
}
< /*EMPTY*/))
}
}
return (ans);
}
void
{
int sock;
/* ppid only set when using transient from parent (nisd) */
cleanup(0);
return;
continue;
< /*EMPTY*/)) ||
== /*EMPTY*/))) {
else
}
}
}
}