You have some data corruption bugs here.  The reader and writer for this data are in separate threads.  It is not a good idea to rely on reads being atomic.

Make a structure with all the data in it, and protect that with a lock.  Grab the lock, make a tmp structure, release the lock, and return the structure.  Much safer.