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

Function ng_acquire_read

freebsd/netgraph/ng_base.c:2040–2065  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2038
2039/* Acquire reader lock on node. If node is busy, queue the packet. */
2040static __inline item_p
2041ng_acquire_read(node_p node, item_p item)
2042{
2043 KASSERT(node != &ng_deadnode,
2044 ("%s: working on deadnode", __func__));
2045
2046 /* Reader needs node without writer and pending items. */
2047 for (;;) {
2048 long t = node->nd_input_queue.q_flags;
2049 if (t & NGQ_RMASK)
2050 break; /* Node is not ready for reader. */
2051 if (atomic_cmpset_acq_int(&node->nd_input_queue.q_flags, t,
2052 t + READER_INCREMENT)) {
2053 /* Successfully grabbed node */
2054 CTR4(KTR_NET, "%20s: node [%x] (%p) acquired item %p",
2055 __func__, node->nd_ID, node, item);
2056 return (item);
2057 }
2058 cpu_spinwait();
2059 }
2060
2061 /* Queue the request for later. */
2062 ng_queue_rw(node, item, NGQRW_R);
2063
2064 return (NULL);
2065}
2066
2067/* Acquire writer lock on node. If node is busy, queue the packet. */
2068static __inline item_p

Callers 1

ng_snd_itemFunction · 0.70

Calls 1

ng_queue_rwFunction · 0.70

Tested by

no test coverage detected