add timer to ensure buf cleaned
fix consumed_size overflow and add some null check