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

Function mainloop

freebsd/netpfil/ipfw/test/main.c:201–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201static int
202mainloop(struct cfg_s *c)
203{
204 int i;
205 struct mbuf *m;
206
207 for (i=0; i < c->loops; i++) {
208 /* implement histeresis */
209 controller(c);
210 DX(3, "loop %d enq %d send %p rx %d",
211 i, c->_enqueue, c->tosend, c->can_dequeue);
212 if ( (m = c->tosend) ) {
213 int ret;
214 struct dn_queue *q = FI2Q(c, m->flow_id);
215 c->_enqueue++;
216 ret = c->enq(c->si, q, m);
217 if (ret) {
218 drop(c, m);
219 D("loop %d enqueue fail", i );
220 /*
221 * XXX do not insist; rather, try dequeue
222 */
223 goto do_dequeue;
224 } else {
225 ND("enqueue ok");
226 c->pending++;
227 gnet_stats_enq(c, m);
228 }
229 } else if (c->can_dequeue) {
230do_dequeue:
231 c->dequeue++;
232 m = c->deq(c->si);
233 if (m) {
234 c->pending--;
235 drop(c, m);
236 c->drop--; /* compensate */
237 gnet_stats_deq(c, m);
238 } else {
239 D("--- ouch, cannot operate on iteration %d, pending %d", i, c->pending);
240 break;
241 }
242 }
243 }
244 DX(1, "mainloop ends %d", i);
245 return 0;
246}
247
248int
249dump(struct cfg_s *c)

Callers 1

mainFunction · 0.85

Calls 4

controllerFunction · 0.85
dropFunction · 0.85
gnet_stats_enqFunction · 0.85
gnet_stats_deqFunction · 0.85

Tested by

no test coverage detected