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

Function ng_acquire_write

lib/ff_ng_base.c:2075–2094  ·  view source on GitHub ↗

Acquire writer lock on node. If node is busy, queue the packet. */

Source from the content-addressed store, hash-verified

2073
2074/* Acquire writer lock on node. If node is busy, queue the packet. */
2075static __inline item_p
2076ng_acquire_write(node_p node, item_p item)
2077{
2078 KASSERT(node != &ng_deadnode,
2079 ("%s: working on deadnode", __func__));
2080
2081 /* Writer needs completely idle node. */
2082 if (atomic_cmpset_acq_int(&node->nd_input_queue.q_flags, 0,
2083 WRITER_ACTIVE)) {
2084 /* Successfully grabbed node */
2085 CTR4(KTR_NET, "%20s: node [%x] (%p) acquired item %p",
2086 __func__, node->nd_ID, node, item);
2087 return (item);
2088 }
2089
2090 /* Queue the request for later. */
2091 ng_queue_rw(node, item, NGQRW_W);
2092
2093 return (NULL);
2094}
2095
2096#if 0
2097static __inline item_p

Callers 1

ng_snd_itemFunction · 0.70

Calls 1

ng_queue_rwFunction · 0.70

Tested by

no test coverage detected