buf should be initialized only in the producer filter.