Use thread-specific storage for computing a snapshot.
We mustn't use a global variable since concurrent GTM threads might try to
compute a snapshot at the same time and may overwrite the information before a
thread can send the complete snapshot to the client. Chi Gao
<chi.gao@microfun.com> reported that this can cause infinite wait on the client
side because the client expects N bytes of data, but only receives (N - x)
bytes and it keeps waiting for remaining x bytes which the GTM never sends.
While we don't have a report, it's obvious that it can also go wrong in the
other direction.
We fix this by using a thread-specific storage which ensures that the snapshot
cannot be changed while it's being sent to the client.
Report, analysis and fix by Chi Gao <chi.gao@microfun.com>. Some minor
editorialisation by me.
Backpatched to XL9_5_STABLE