On Sun, Sep 01, 2019 at 10:43:42PM +0800, Li Qiang wrote: > fangying <fangyi...@huawei.com> 于2019年9月1日周日 下午8:29写道: > > > Nice work, your patch does fix this issue in my test. > > > > I think we should make VncState.zlib to be a pointer type as well. > > > > Since we are going to use pointers instead of copy, we must make sure that > > there’s no race condition of pointer members between the local vs (vnc > > worker thread) and origin vs (main thread). > > > > > > Yes, there is a race between the main thread and vnc thread.
Where do you see a race? The main thread allocates the data structures before any job is started, cleans up after the jobs have been stopped and never accesses them otherwise. So unless I missed something the data structures are never accessed in parallel from multiple threads. > Maybe we should add a lock just like the 'vs->output_mutex'. output is a different story. The output buffer is accessed in parallel (job thread produces and main thread consumes), so we actually need a lock here for synchronization. cheers, Gerd