MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ng_apply_item

Function ng_apply_item

lib/ff_ng_base.c:2378–2523  ·  view source on GitHub ↗

* We have an item that was possibly queued somewhere. * It should contain all the information needed * to run it on the appropriate node/hook. * If there is apply pointer and we own the last reference, call apply(). */

Source from the content-addressed store, hash-verified

2376 * If there is apply pointer and we own the last reference, call apply().
2377 */
2378static int
2379ng_apply_item(node_p node, item_p item, int rw)
2380{
2381 hook_p hook;
2382 ng_rcvdata_t *rcvdata;
2383 ng_rcvmsg_t *rcvmsg;
2384 struct ng_apply_info *apply;
2385 int error = 0, depth;
2386
2387 /* Node and item are never optional. */
2388 KASSERT(node != NULL, ("ng_apply_item: node is NULL"));
2389 KASSERT(item != NULL, ("ng_apply_item: item is NULL"));
2390
2391 NGI_GET_HOOK(item, hook); /* clears stored hook */
2392#ifdef NETGRAPH_DEBUG
2393 _ngi_check(item, __FILE__, __LINE__);
2394#endif
2395
2396 apply = item->apply;
2397 depth = item->depth;
2398
2399 switch (item->el_flags & NGQF_TYPE) {
2400 case NGQF_DATA:
2401 /*
2402 * Check things are still ok as when we were queued.
2403 */
2404 KASSERT(hook != NULL, ("ng_apply_item: hook for data is NULL"));
2405 if (NG_HOOK_NOT_VALID(hook) ||
2406 NG_NODE_NOT_VALID(node)) {
2407 error = EIO;
2408 NG_FREE_ITEM(item);
2409 break;
2410 }
2411 /*
2412 * If no receive method, just silently drop it.
2413 * Give preference to the hook over-ride method.
2414 */
2415 if ((!(rcvdata = hook->hk_rcvdata)) &&
2416 (!(rcvdata = NG_HOOK_NODE(hook)->nd_type->rcvdata))) {
2417 error = 0;
2418 NG_FREE_ITEM(item);
2419 break;
2420 }
2421 error = (*rcvdata)(hook, item);
2422 break;
2423 case NGQF_MESG:
2424 if (hook && NG_HOOK_NOT_VALID(hook)) {
2425 /*
2426 * The hook has been zapped then we can't use it.
2427 * Immediately drop its reference.
2428 * The message may not need it.
2429 */
2430 NG_HOOK_UNREF(hook);
2431 hook = NULL;
2432 }
2433 /*
2434 * Similarly, if the node is a zombie there is
2435 * nothing we can do with it, drop everything.

Callers 3

ng_upgrade_writeFunction · 0.70
ng_snd_itemFunction · 0.70
ngthreadFunction · 0.70

Calls 5

refcount_releaseFunction · 0.85
ng_generic_msgFunction · 0.70
ng_leave_readFunction · 0.70
ng_leave_writeFunction · 0.70
_ngi_checkFunction · 0.50

Tested by

no test coverage detected