Ejemplo n.º 1
0
void
np_tpool_select (Npreq *req)
{
	Npsrv *srv = req->conn->srv;
	Nptpool *tp;

	if ((srv->flags & SRV_FLAGS_TPOOL_SINGLE))
		return;
	if (!req->fid || !req->fid->aname || *req->fid->aname != '/')
		return;
	if (req->fid->tpool)
		return;

	xpthread_mutex_lock (&srv->lock);
	for (tp = srv->tpool; tp != NULL; tp = tp->next) {
		if (!strcmp (req->fid->aname, tp->name))
			break;
	}
	if (!tp) {
		tp = np_tpool_create(srv, req->fid->aname);
		if (tp) {
			assert (srv->tpool); /* default tpool */
			tp->next = srv->tpool->next;
			srv->tpool->next = tp;
		} else
			np_logerr (srv, "np_tpool_create %s", req->fid->aname);
	}
	if (tp) {
		np_tpool_incref (tp);
		req->fid->tpool = tp;
	}
	xpthread_mutex_unlock (&srv->lock);
}
Ejemplo n.º 2
0
Npsrv*
np_srv_create(int nwthread, int flags)
{
	Npsrv *srv = NULL;

	np_uerror (0);
	if (!(srv = malloc(sizeof(*srv)))) {
		np_uerror (ENOMEM);
		goto error;
	}
	memset (srv, 0, sizeof (*srv));
	pthread_mutex_init(&srv->lock, NULL);
	pthread_cond_init(&srv->conncountcond, NULL);

	srv->msize = 8216;
	srv->flags = flags;

	srv->netroot = np_net_make_root();
	if (srv->netroot == 0)
		goto error;

	if (np_usercache_create (srv) < 0)
		goto error;
	srv->nwthread = nwthread;
	if (!(srv->tpool = np_tpool_create (srv, "default")))
		goto error;
	np_tpool_incref (srv->tpool);
	np_assert_srv = srv;
	return srv;
error:
	if (srv)
		np_srv_destroy (srv);
	return NULL;
}
Ejemplo n.º 3
0
Npsrv*
np_srv_create(int nwthread, int flags)
{
	Npsrv *srv = NULL;

	np_uerror (0);
	if (!(srv = malloc(sizeof(*srv)))) {
		np_uerror (ENOMEM);
		goto error;
	}
	memset (srv, 0, sizeof (*srv));
	pthread_mutex_init(&srv->lock, NULL);
	pthread_cond_init(&srv->conncountcond, NULL);

	srv->msize = 8216;
	srv->flags = flags;

	if (np_ctl_initialize (srv) < 0)
		goto error;
	if (!np_ctl_addfile (srv->ctlroot, "version", _ctl_get_version, NULL))
		goto error;
	if (!np_ctl_addfile (srv->ctlroot, "connections",
			     _ctl_get_connections, srv))
		goto error;
	if (!np_ctl_addfile (srv->ctlroot, "tpools", _ctl_get_tpools, srv))
		goto error;
	if (!np_ctl_addfile (srv->ctlroot, "requests", _ctl_get_requests, srv))
		goto error;
	if (!np_ctl_addfile_proc (srv->ctlroot, "meminfo"))
		goto error;
	if (!np_ctl_addfile_proc (srv->ctlroot, "net.rpc.nfs"))
		goto error;
	if (np_usercache_create (srv) < 0)
		goto error;
	srv->nwthread = nwthread;
	if (!(srv->tpool = np_tpool_create (srv, "default")))
		goto error;
	np_tpool_incref_nolock (srv->tpool);
	return srv;
error:
	if (srv)
		np_srv_destroy (srv);
	return NULL;
}