예제 #1
0
파일: sessn_gc.c 프로젝트: rohsaini/mkunity
Event
initSessionCollector(
    Map		m,
    int		interval,
    void	(*destructor)(XObj s),
    Path	p,
    char	*msg)
{
    CollectInfo *c;
    Event	ev;

    xTrace2(sessngc, 3,
	    "session garbage collector initialized for map %x (%s)",
	    m, msg ? msg : "");
    if ( ! (c = pathAlloc(p, sizeof(CollectInfo))) ) {
	return 0;
    }
    if ( ! (ev = evAlloc(p)) ) {
	pathFree(c);
	return 0;
    }
    c->map = m;
    c->interval = interval;
    c->destroy = destructor;
    c->msg = msg ? msg : "";
    evSchedule( ev, sessnCollect, c, c->interval );
    return ev;
}
예제 #2
0
void
dgramtesttrigger(
		 void)
{
    PState	*ps = (PState *)dgramtestprotocol->state;
    if ( x_server ) {
	xError("Starting server");
	evDetach(evSchedule(evAlloc(dgramtestprotocol->path), server, dgramtestprotocol, 0));
    } else
	if ( x_client ) {
	    d_area_s.prod = 0;
	    d_area_s.cons = 0;
#if MACH_KERNEL
	    (void)kmem_alloc(kernel_map, (vm_offset_t *)&d_area_s.addr, DUMP_AREA_SIZE);
#else   /* MACH_KERNEL */
	    d_area_s.addr = (char *)pathAlloc(dgramtestprotocol->path, DUMP_AREA_SIZE);
#endif  /* MACH_KERNEL */
	    if (!d_area_s.addr) {
		xError("dgramtest: couldn't allocate dump area\n");
		pathFree(ps);
		return;
	    }
	    xError("Starting client");
	    evDetach(evSchedule(evAlloc(dgramtestprotocol->path), client, dgramtestprotocol, 0));
	}
    else 
	printf("Pls. assert either x_client or x_server\n");
}
예제 #3
0
xkern_return_t
dgramtest_init( XObj self )
{
    static XObj	firstServer;
    PState	*ps;

    dgramtestprotocol = self;
    ps = pathAlloc(self->path, sizeof(PState));
    if (!ps) {
	xError("dgramtest: couldn't allocate PState\n");
	return XK_FAILURE;
    }
    self->state = ps;
    if ((ps->evdgram = evAlloc(self->path)) == 0) {
	pathFree(ps);
	return XK_FAILURE;
    }
    ps->mark = '.';
    ps->loop = LOOP_DEFAULT;
    ps->delay = 0;
    ps->dgramtest_priority = DGRAMTEST_PRIORITY;
    ps->groupsize = ALL_TOGETHER;
    bcopy((char *)&defaultServer, (char *)&ps->server, sizeof(IPhost));

    if ( findXObjRomOpts(self, dgramOpts,
		sizeof(dgramOpts)/sizeof(XObjRomOpt), ps) == XK_FAILURE ) {
	xError("dgramtest: romfile config errors, not running");
	return XK_FAILURE;
    }
    {
	/*
	 * Overload standard path with custom path
	 */
	
	Path                p;
	XkThreadPolicy_s    policy;
	int                 pri = ps->dgramtest_priority;
	xkern_return_t      xkr;

	p = pathCreate(31, "test path");
	policy.func = xkPolicyFixedFifo;
	policy.arg = &pri;
	policy.argLen = sizeof(int);
	xkr = pathEstablishPool(p, 10, 1, &policy, 0);
	if ( xkr != XK_SUCCESS ) {
	    xError("pathEstablishPool fails");
	}
	self->path = p;
    }
#if !DIPC_XKERN
    dgramtesttrigger();
#endif /* DIPC_XKERN */
    self->control = dgramtestControlProtl;

    return XK_SUCCESS;
}
예제 #4
0
void pathFreeList(struct path **pList)
/* Free a list of dynamically allocated path's */
{
struct path *el, *next;

for (el = *pList; el != NULL; el = next)
    {
    next = el->next;
    pathFree(&el);
    }
*pList = NULL;
}
예제 #5
0
// returns:
// - S_OK if there are files
// - S_FALSE if there are none
// - an error code otherwise
HRESULT startFindFile(WCHAR *path, struct findFile **out)
{
	struct findFile *ff;
	WCHAR *finddir;
	HRESULT hr;

	// initialize output parameters
	*out = NULL;

	ff = (struct findFile *) malloc(sizeof (struct findFile));
	if (ff == NULL)
		return E_OUTOFMEMORY;
	ZeroMemory(ff, sizeof (struct findFile));

	hr = pathJoin(path, L"*", &finddir);
	if (hr != S_OK) {
		free(ff);
		return hr;
	}

	// get the first file now
	// findFileNext() will see that ff->first is TRUE and return immediately; we can get that first file's info then
	ff->first = TRUE;
	ff->dir = FindFirstFileW(finddir, &(ff->entry));
	if (ff->dir == INVALID_HANDLE_VALUE)
		if (ffReallyNoMoreFiles(ff, ERROR_FILE_NOT_FOUND)) {
			// no files
			pathFree(finddir);
			free(ff);
			return S_FALSE;
		}

	pathFree(finddir);
	*out = ff;
	return S_OK;
}
예제 #6
0
파일: iproute.c 프로젝트: rohsaini/mkunity
xkern_return_t
rt_init( XObj self, IPhost *defGw )
{
    PState	*ps = (PState *)self->state;
    RouteTable	*tbl = &ps->rtTbl;
    Path	path = self->path;
    Event	ev;
    
    xTrace0(ipp, TR_GROSS_EVENTS, "IP rt_init()");
    tbl->valid = TRUE;
    tbl->defrt = 0;
    tbl->arr = (route **)pathAlloc(path, ROUTETABLESIZE * sizeof(route *));
    tbl->path = path;
    if ( ! tbl->arr ) {
	xTraceP0(self, TR_ERRORS, "allocation failure");
	return XK_FAILURE;
    }
    bzero((char *)tbl->arr, ROUTETABLESIZE * sizeof(route *));
    tbl->bpoolsize = BPSIZE;
    if ( ! (ev = evAlloc(path)) ) {
	pathFree(tbl->arr);
	xTraceP0(self, TR_ERRORS, "allocation failure");
	return XK_FAILURE;
    }
    if ( IP_EQUAL(*defGw, ipNull) ) {
	xTrace0(ipp, TR_GROSS_EVENTS,
		"IP routing -- default routing disabled");
    } else {
	if ( rt_add_def(ps, defGw) ) {
	    return XK_FAILURE;
	}
    }
    evSchedule(ev, rt_timer, tbl, RTTABLEUPDATE * 1000);
    xTrace0(ipp, TR_GROSS_EVENTS, "IP rt_init() done");
    return XK_SUCCESS;
}