CCBC-213: Unify connection routines

The basic idea is to unify the structures for the connections used for
all our objects which depend on their own TCP connections.

The history here was largely borrowed from another rewrite

Change-Id: Iffa9e7b0d8787ae42731f2716d9dc4e9f8f8a314
Reviewed-on: http://review.couchbase.org/26462
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Abstract io notification requests

This basically wraps the update_event functions

Change-Id: I35f0b00ebf75e182cf4545a36f7b602ebf1b0cd2
Reviewed-on: http://review.couchbase.org/26473
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Unify read/write functions and refactor them from parsers

- Now our parsing code is sectioned out from our I/O functions. Parsers
  work with a ringbuffer (or similar) structure, and the I/O functions
  are unified in the 'io/readwrite.c' file.

Change-Id: I3e0c87372dc308b99f6aa2de3c96284cbf6b42f1
Reviewed-on: http://review.couchbase.org/26478
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Mark Nunberg <mnunberg@haskalah.org>
Make buffer structure owned by connection object

- These objects will be allocated pointers. This is needed for further
  changes, but also cleans things up a bit in terms of uniformity

Change-Id: I89c7a88669d8ab414adbbfe7c0acb7907a17b7d5
Reviewed-on: http://review.couchbase.org/26489
Reviewed-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Implement simple want-read/want-write semantics

This changes the internal way the library communicates with its event
model. Rather than scheduling read/write requests on demand from random
places in code, code sets 'want' flags (which are the same as the
LCB_READ/LCB_WRITE_EVENT flags). The events are actually scheduled when
the top level 'stack' function (i.e. the event handler) itself leaves.

Not only is this more efficient (i.e. not calling update_event() all the
time, but calling something far more lightweight), but it also
centralizes event scheduling in a single location.

Change-Id: I31ad9183d026f55ae139f4845d040b27759e7c22
Reviewed-on: http://review.couchbase.org/26548
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Handle read errors in bconf_io

Change-Id: I2c48c51052ae7dc8dc8fe7339a52a0a41f42f357
Reviewed-on: http://review.couchbase.org/26894
Reviewed-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>