Made the random number generator thread-safe.

Changed the random number generator from rand() to std::mt19937.
Fixed bug in multi-chunk entries.

When saving multi-chunk entries right before flushing a file,
the ftruncate() and seek() were applied to newly opened file
instead of the one that was already opened.
Fixed bug in implementation of the memcache protocol.

When the ending \r\n is received in its own packet,
it must be ignored and not treated a zero chunk
for the storage engine.
Fixed bug in buffer swapping.

The live buffer would get stuck. Again a weird behavior of the
std::condition_variable that doesn't keep state of the received
messages.