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

Function alq_post_flags

freebsd/kern/kern_alq.c:826–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824}
825
826void
827alq_post_flags(struct alq *alq, struct ale *ale, int flags)
828{
829 int activate;
830 void *waitchan;
831
832 activate = 0;
833
834 if (ale->ae_bytesused > 0) {
835 if (!(alq->aq_flags & AQ_ACTIVE) &&
836 !(flags & ALQ_NOACTIVATE)) {
837 alq->aq_flags |= AQ_ACTIVE;
838 activate = 1;
839 }
840
841 alq->aq_writehead += ale->ae_bytesused;
842 alq->aq_freebytes -= ale->ae_bytesused;
843
844 /* Wrap aq_writehead if we filled to the end of the buffer. */
845 if (alq->aq_writehead == alq->aq_buflen)
846 alq->aq_writehead = 0;
847
848 KASSERT((alq->aq_writehead >= 0 &&
849 alq->aq_writehead < alq->aq_buflen),
850 ("%s: aq_writehead < 0 || aq_writehead >= aq_buflen",
851 __func__));
852
853 KASSERT((HAS_PENDING_DATA(alq)), ("%s: queue empty!", __func__));
854 }
855
856 /*
857 * If there are waiters, we need to signal the waiting threads after we
858 * complete our work. The alq ptr is used as a wait channel for threads
859 * requiring resources to be freed up. In the AQ_ORDERED case, threads
860 * are not allowed to concurrently compete for resources in the
861 * alq_getn() while loop, so we use a different wait channel in this case.
862 */
863 if (alq->aq_waiters > 0) {
864 if (alq->aq_flags & AQ_ORDERED)
865 waitchan = &alq->aq_waiters;
866 else
867 waitchan = alq;
868 } else
869 waitchan = NULL;
870
871 ALQ_UNLOCK(alq);
872
873 if (activate) {
874 ALD_LOCK();
875 ald_activate(alq);
876 ALD_UNLOCK();
877 }
878
879 /* NB: We rely on wakeup_one waking threads in a FIFO manner. */
880 if (waitchan != NULL)
881 wakeup_one(waitchan);
882}
883

Callers 2

siftr.cFile · 0.85
alq_postFunction · 0.85

Calls 2

ald_activateFunction · 0.85
wakeup_oneFunction · 0.70

Tested by

no test coverage detected