MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_snd_item

Function ng_snd_item

lib/ff_ng_base.c:2230–2370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2228 */
2229
2230int
2231ng_snd_item(item_p item, int flags)
2232{
2233 hook_p hook;
2234 node_p node;
2235#ifndef FSTACK
2236 int queue, rw;
2237 struct ng_queue *ngq;
2238#endif
2239 int error = 0;
2240
2241 /* We are sending item, so it must be present! */
2242 KASSERT(item != NULL, ("ng_snd_item: item is NULL"));
2243
2244#ifdef NETGRAPH_DEBUG
2245 _ngi_check(item, __FILE__, __LINE__);
2246#endif
2247
2248 /* Item was sent once more, postpone apply() call. */
2249 if (item->apply)
2250 refcount_acquire(&item->apply->refs);
2251
2252 node = NGI_NODE(item);
2253 /* Node is never optional. */
2254 KASSERT(node != NULL, ("ng_snd_item: node is NULL"));
2255
2256 hook = NGI_HOOK(item);
2257 /* Valid hook and mbuf are mandatory for data. */
2258 if ((item->el_flags & NGQF_TYPE) == NGQF_DATA) {
2259 KASSERT(hook != NULL, ("ng_snd_item: hook for data is NULL"));
2260 if (NGI_M(item) == NULL)
2261 ERROUT(EINVAL);
2262 CHECK_DATA_MBUF(NGI_M(item));
2263 }
2264
2265#ifndef FSTACK
2266 /*
2267 * If the item or the node specifies single threading, force
2268 * writer semantics. Similarly, the node may say one hook always
2269 * produces writers. These are overrides.
2270 */
2271 if (((item->el_flags & NGQF_RW) == NGQF_WRITER) ||
2272 (node->nd_flags & NGF_FORCE_WRITER) ||
2273 (hook && (hook->hk_flags & HK_FORCE_WRITER))) {
2274 rw = NGQRW_W;
2275 } else {
2276 rw = NGQRW_R;
2277 }
2278
2279 /*
2280 * If sender or receiver requests queued delivery, or call graph
2281 * loops back from outbound to inbound path, or stack usage
2282 * level is dangerous - enqueue message.
2283 */
2284 if ((flags & NG_QUEUE) || (hook && (hook->hk_flags & HK_QUEUE))) {
2285 queue = 1;
2286 } else if (hook && (hook->hk_flags & HK_TO_INBOUND) &&
2287 curthread->td_ng_outbound) {

Callers 3

ng_send_fn1Function · 0.70
ng_send_fn2Function · 0.70
ng_callout_trampolineFunction · 0.70

Calls 8

refcount_acquireFunction · 0.85
refcount_releaseFunction · 0.85
ng_queue_rwFunction · 0.70
ng_acquire_readFunction · 0.70
ng_acquire_writeFunction · 0.70
ng_apply_itemFunction · 0.70
ng_worklist_addFunction · 0.70
_ngi_checkFunction · 0.50

Tested by

no test coverage detected