Be more careful with memory ordering in ringbuffer.c

This is a proposed fix for libqb issue #64:
* use atomic ops for ringbuffer chunk magic and size, to make sure they're written and read in the right order
* put a barrier before qb_atomic_*_set, since their users expect it
* don't use atomic ops in socket, since it doesn't need them