MB-17045: Ensure that logfiles are not truncated when re-opening after EMFILE
MB-17045: Ensure that logfiles are not truncated when re-opening after EMFILE

In the error scenario where memcached has run out of file descriptors,
and then subsequently recovers (i.e. more FDs are made available), it
may incorrectly attempt to re-open the previous logfile, truncating it
in the process.

This is due to the search for the next file in open_logfile() starting
from the same position as previously, instead of one after the last
successful open.

Fix the search algorithm, and for additional paranoia always append to
any logfile we open.

This bug was introduced by commit 7d88d0b - MB-16689: Handle EMFILE on
file logger rotation.

Change-Id: I6cdadb8608ea84d5ab7e08ab6694e7006abf28df
Reviewed-on: http://review.couchbase.org/57721
Well-Formed: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>

couchbase/memcached,daverigby/memcached,daverigby/kv_engine,owendCB/memcached,daverigby/memcached,owendCB/memcached,daverigby/memcached,owendCB/memcached,couchbase/memcached,owendCB/memcached,daverigby/kv_engine,daverigby/kv_engine,daverigby/kv_engine,couchbase/memcached,daverigby/memcached,couchbase/memcached