ofproto/pinsched.c
/* Drop a packet from the longest queue in 'ps'. */
Drop a packet from the longest queue in 'ps'.
Drop a packet from the longest queue in ' ps ' .
static void
drop_packet(struct pinsched *ps)
{
    struct pinqueue *longest;   
    int n_longest = 0;          
    struct pinqueue *q;
    ps->n_queue_dropped++;
    longest = NULL;
    HMAP_FOR_EACH (q, node, &ps->queues) {
        if (!longest || longest->n < q->n) {
            longest = q;
            n_longest = 1;
        } else if (longest->n == q->n) {
            n_longest++;
            if (!random_range(n_longest)) {
                longest = q;
            }
        }
    }
    ofpbuf_delete(dequeue_packet(ps, longest));
    if (longest->n == 0) {
        pinqueue_destroy(ps, longest);
    }
}
static void drop_packet ( struct pinsched * ps ) { struct pinqueue * longest ; int n_longest = 0 ; struct pinqueue * q ; ps -> n_queue_dropped ++ ; longest = NULL ; HMAP_FOR_EACH ( q , node , & ps -> queues ) { if ( ! longest || longest -> n < q -> n ) { longest = q ; n_longest = 1 ; } else if ( longest -> n == q -> n ) { n_longest ++ ; if ( ! random_range ( n_longest ) ) { longest = q ; } } } ofpbuf_delete ( dequeue_packet ( ps , longest ) ) ; if ( longest -> n == 0 ) { pinqueue_destroy ( ps , longest ) ; } }
Drop a packet from the longest queue in 'ps'.
Drop a packet from the longest queue in ' ps ' .
/* Queue currently selected as longest. */ /* # of queues of same length as 'longest'. */ /* Randomly select one of the longest queues, with a uniform
             * distribution (Knuth algorithm 3.4.2R). */ /* FIXME: do we want to pop the tail instead? */