Common lib: fix buffered log write sync method, by changing number of write waiting threads before and after wait invocation. Fix  possible infinite loop in buffered log writer append method in the case where record size including the message header exceeds currently available space.