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>