Exemplo n.º 1
0
SVCXPRT *
svc_raw_create()
{
	struct svc_raw_private *srp;
/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */

	mutex_lock(&svcraw_lock);
	srp = svc_raw_private;
	if (srp == NULL) {
		srp = calloc(1, sizeof(*srp));
		if (srp == NULL)
			goto out;
		if (__rpc_rawcombuf == NULL)
			__rpc_rawcombuf = malloc(UDPMSGSIZE);
		if (__rpc_rawcombuf == NULL)
			goto out;
		srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */
		svc_raw_private = srp;
	}
	srp->server.xp_fd = FD_SETSIZE;
	srp->server.xp_port = 0;
	srp->server.xp_p3 = NULL;
	svc_raw_ops(&srp->server);
	srp->server.xp_verf.oa_base = srp->verf_body;
	xdrmem_create(&srp->xdr_stream, srp->raw_buf, UDPMSGSIZE, XDR_DECODE);
	xprt_register(&srp->server);
	mutex_unlock(&svcraw_lock);
	return (&srp->server);
out:
	if (srp != NULL)
		free(srp);
	mutex_unlock(&svcraw_lock);
	return (NULL);
}
Exemplo n.º 2
0
SVCXPRT *
svc_raw_ncreate(void)
{
	struct svc_raw_private *srp;

	/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */
	mutex_lock(&svcraw_lock);
	srp = svc_raw_private;
	if (srp == NULL) {
		srp = (struct svc_raw_private *)mem_alloc(sizeof(*srp));
		if (__rpc_rawcombuf == NULL)
			__rpc_rawcombuf = mem_alloc(UDPMSGSIZE * sizeof(char));
		srp->raw_buf = __rpc_rawcombuf;	/* Share it with the client */
		svc_raw_private = srp;
	}
	srp->server.xp_fd = FD_SETSIZE;
	srp->server.xp_port = 0;
	srp->server.xp_p3 = NULL;
	svc_raw_ops(&srp->server);
/* XXX check and or fixme */
#if 0
	srp->server.xp_verf.oa_base = srp->verf_body;
#endif
	xdrmem_create(&srp->xdr_stream, srp->raw_buf, UDPMSGSIZE, XDR_DECODE);
	xprt_register(&srp->server);
	mutex_unlock(&svcraw_lock);

	return (&srp->server);
}
Exemplo n.º 3
0
SVCXPRT *
svc_raw_create(void)
{
	struct svc_raw_private *srp;
	bool_t flag1 = FALSE, flag2 = FALSE;

/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */
	(void) mutex_lock(&svcraw_lock);
	srp = svc_raw_private;
	if (srp == NULL) {
		srp = calloc(1, sizeof (*srp));
		if (srp == NULL) {
			syslog(LOG_ERR, "svc_raw_create: out of memory");
			(void) mutex_unlock(&svcraw_lock);
			return (NULL);
		}
		flag1 = TRUE;
		if (_rawcombuf == NULL) {
			_rawcombuf = calloc(UDPMSGSIZE, sizeof (char));
			if (_rawcombuf == NULL) {
				free(srp);
				syslog(LOG_ERR, "svc_raw_create: "
					"out of memory");
				(void) mutex_unlock(&svcraw_lock);
				return (NULL);
			}
			flag2 = TRUE;
		}
		srp->raw_buf = _rawcombuf; /* Share it with the client */
		svc_raw_private = srp;
	}
	if ((srp->server = svc_xprt_alloc()) == NULL) {
		if (flag2)
			free(svc_raw_private->raw_buf);
		if (flag1)
			free(svc_raw_private);
		(void) mutex_unlock(&svcraw_lock);
		return (NULL);
	}
	/*
	 * By convention, using FD_SETSIZE as the psuedo file descriptor
	 */
	srp->server->xp_fd = FD_SETSIZE;
	srp->server->xp_port = 0;
	srp->server->xp_ops = svc_raw_ops();
	srp->server->xp_verf.oa_base = srp->verf_body;
	xdrmem_create(&srp->xdr_stream, srp->raw_buf, UDPMSGSIZE, XDR_DECODE);
	xprt_register(srp->server);
	(void) mutex_unlock(&svcraw_lock);
	return (srp->server);
}
Exemplo n.º 4
0
SVCXPRT *
svc_raw_create()
{
	struct svc_raw_private *srp;
/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */

	mutex_lock(&svcraw_lock);
	srp = svc_raw_private;
	if (srp == NULL) {
		srp = (struct svc_raw_private *)calloc(1, sizeof (*srp));
		if (srp == NULL) {
			mutex_unlock(&svcraw_lock);
			return (NULL);
		}
		if (__rpc_rawcombuf == NULL) {
			__rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char));
			if (__rpc_rawcombuf == NULL) {
				free(srp);
				mutex_unlock(&svcraw_lock);
				return (NULL);
			}
		}
		srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */
		srp->server = svc_xprt_alloc();
		if (srp->server == NULL) {
			free(__rpc_rawcombuf);
			free(srp);
			mutex_unlock(&svcraw_lock);
			return (NULL);
		}
		svc_raw_private = srp;
	}
	srp->server->xp_fd = FD_SETSIZE;
	srp->server->xp_port = 0;
	svc_raw_ops(srp->server);
	srp->server->xp_verf.oa_base = srp->verf_body;
	xdrmem_create(&srp->xdr_stream, srp->raw_buf, UDPMSGSIZE, XDR_DECODE);
	xprt_register(srp->server);
	mutex_unlock(&svcraw_lock);
	return (srp->server);
}