Fix thread locks in zlib module may go wrong in rare case. (#22126)

Setting `next_in` before acquiring the thread lock may mix up compress/decompress state in other threads.
2 files changed