CCBC-159 Allow to handle large operation buffers

Function do_read_data() has internal limit for operations handled per
call and currently it is hardcoded as 1000. With conjuntion that
lcb_server_event_handler() might register itself for READ event
awaiting the data from the socket when output buffer is empty, it
leads to timeouts when the limit was reached _and_ output buffer is
empty.

This patch does the following:

* always setup RW event if either output or input buffers has the data
* check for pure write event first in the handler
* add alternative check for read event, it will be triggered either
  when READ event received or input buffer isn't empty

Change-Id: Ie62692e30b8f0c0bf00aff5b262fb2c99b609f3f
Reviewed-on: http://review.couchbase.org/23662
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
CCBC-150: Do a deep search to locate commands

Change-Id: Ic66ef44c129bbed64037b1fe09e0a152d54f035a
Reviewed-on: http://review.couchbase.org/23633
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
regression-unit-test.cc requires CouchbaseMock.jar

Change-Id: I63e4d4e116679f61ea0ae50fdde2f8bde0dbc244
Reviewed-on: http://review.couchbase.org/23666
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
CCBC-159 Fix MockUnitTest.testPurgedBody

Update socket timer only if there was real job done like reading or
writing data.

Fixes http://sdkbuilds.couchbase.com/job/libcouchbase/406

Change-Id: I6415b7c6d7ba64ef0fdeb722e92ecc98c4208ae7
Reviewed-on: http://review.couchbase.org/23668
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
CCBC-160 Fix incorrect reschedule of batched commands

* do not call lcb_server_event_handler() directly, but rather schedule it
* properly breakout the while loop in do_read_data()
* do not call recvv() when we are parsing input on WRITE event

Change-Id: Id11fd9d4b15b74aeb1c237f51ed55287685b386d
Reviewed-on: http://review.couchbase.org/23684
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
CCBC-163: Fix high CPU usage

This fixes high CPU usage introduced in
8cd34a405523fc144937d13bed68a59f1a75f813.

The cause of the spike was only adding extra events if there was more
data to read/write. The fix is to always reset the requested events and
update the events as needed.

Change-Id: I2b59cdae04c0e07cbbca100462fd513f32e1f35f
Reviewed-on: http://review.couchbase.org/23692
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>