Fixed the dropped packet issue, head and tail were reversed in rx_pending().