Peter Memishian wrote:
> > I don't think either of the above is correct. Note that once the message
> > size reaches the threshold, mp should be the first one needs to be freed,
> > the the previous message should be set as dsp->ds_tx_list_tail.
>
> I'm not sure it really matters, but if you think so, then you can keep the
> pointer to the previous message. Just please don't unroll the first
> iteration of the loop -- that really made the code ugly.
>
Okay. I've changed the code to:
/* Calculate total size and count of the packet(s) */
cnt = msgcnt = 0;
for (prev = NULL, mp = dsp->ds_tx_list_head; mp != NULL;
prev = mp, mp = mp->b_next) {
size = mp_getsize(mp);
cnt += size;
msgcnt ++;
if ((cnt >= dld_max_q_count || msgcnt >= dld_max_q_count)) {
ASSERT(dsp->ds_tx_qbusy);
dsp->ds_tx_list_tail = prev;
if (prev == NULL)
dsp->ds_tx_list_head = NULL;
else
prev->b_next = NULL;
freemsgchain(mp);
cnt -= size;
msgcnt --;
break;
}
}