libev: Normalize timer handling

Fixes some bad memory access issues

Change-Id: I89ba77c95b2f5aa48c05841e4bf978e6b66e6eef
Reviewed-on: http://review.couchbase.org/32632
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
cast to unsigned long before printing hrtime

Change-Id: I3af250bfcca09bd76c49c8cf5b0868543e62d83f
Reviewed-on: http://review.couchbase.org/32751
Reviewed-by: Mark Nunberg <mnunberg@haskalah.org>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Move timer stuff over to its own header file

Change-Id: I6d99e887736eeb28747664d15fe4c63db40dd9c8
Reviewed-on: http://review.couchbase.org/32825
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Decouple lcb_connection_st structure

- Connection structure now owns the addrinfo stuff
- No timers in connection structure except for initial connect
- connection_start requires a hostname and a set of handlers
- extended timer API. No more 'update_timer' and 'delete_timer'
- Connection startup info dropped after successful connecton

Change-Id: I162e3a45ac22dccd876ca63a7c4623297215a3cf
Reviewed-on: http://review.couchbase.org/32836
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Connection Manager/Socket Pool

This introduces a connection manager with pooling options to allow for
better utilization and caching of sockets

Change-Id: Ia2b306f000d01a9443589b0cba2a45b5205a9319
Reviewed-on: http://review.couchbase.org/32789
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Fixup some build failures/warnings on win32

Change-Id: I21729495dc864f1737b7999aca1eabb143bad5c7
Reviewed-on: http://review.couchbase.org/32984
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
server_negotiate: always release ringbuffer

Otherwise, memory will leak

Change-Id: I5f1ae990c57cd9ed090f482ac44070ffd8036383
Reviewed-on: http://review.couchbase.org/32878
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Utilize connection pool for memcached sockets

This eliminates extra connections for memcached when using CCCP sockets.
In other words, CCCP no longer allocates its own "Private" socket, but
rather releases its private connection to the pool once it has completed
using it.

Additionally, cccp will now use existing memcached sockets for cluster
information (if so required) rather than creating new sockets from the
pool

Change-Id: I9c8fe908248d96103672915474f048720e1b9e3d
Reviewed-on: http://review.couchbase.org/32883
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Provide time-based threshold for resetting configuration

This provides a time-based threshold so that low-use modes can get
configuration refreshes fairly quickly

Change-Id: If1de2d8b380a4823e95ddb0c608c842d5e19f7be
Reviewed-on: http://review.couchbase.org/32893
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
bc_file: Check if buffer is empty

Change-Id: Ife945f74098f3f5ef2138c4e1f861394c20fb3a6
Reviewed-on: http://review.couchbase.org/32910
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
bootstrap: don't maintain config for TYPE_CLUSTER

We don't need it, and it causes some other assumptions and tests to
fail. In reality this is a hack, but other than making an entirely new
codepath for admin connections, this is the best we can do right now

Change-Id: If5ddd5c9e034e3ddecc681a86d0f6e8a749099d1
Reviewed-on: http://review.couchbase.org/32911
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
confmon: don't poison clconfig memory space

We already have an assertion at the top telling us that the refcount
must be > 0

Change-Id: Ie4a508072fadec6a33533314ad4397cfcd67d55a
Reviewed-on: http://review.couchbase.org/32912
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
readwrite-easy: Don't invoke error callback if bytes were read

This allows us to swallow the entire read buffer contents and only
complain if we've had a close WITHOUT data.

Change-Id: Ib7601d696e826af13ce35cdec5d9abf450a25303
TODO: Maybe place this inside sockrw_v0 read itself?
Reviewed-on: http://review.couchbase.org/32914
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Add environment variable to disable CCCP

In testing environments with either mock or cluster_run, port 11210 may
not exist, or worse, may be part of a different cluster than intended.

While in the unit tests in LCB we manually specify the memcached ports,
this may not be possible with wrapping SDKs, especially of older
versions

Change-Id: Ib1a5499ec08b698dbcf9139d7321628ba4d85d0c
Reviewed-on: http://review.couchbase.org/32915
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
clconfig: Allow more events for listener

This also allows us to terminate the loop early if no providers remain
rather than busy looping. This speeds up tests and most use cases as
well.

Change-Id: Icf123cfba071caa905e8f6602fed05551ac9630b
Reviewed-on: http://review.couchbase.org/32919
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
http: incref connection in io_read

Change-Id: I8667876c78105ffca8b8c9ab7a52e3de3eca9ea9
Reviewed-on: http://review.couchbase.org/32920
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Improved logging messages

Change-Id: Ic540db7650fc737cadb88fdb67e83c861513d3e6
Reviewed-on: http://review.couchbase.org/32928
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Fixup NMakefile

Change-Id: I6348415eac5ff8070ddfbc17de4f67fb409d21e1
Reviewed-on: http://review.couchbase.org/32931
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
confmon tests: Stop loop when maximum providers are reached

Change-Id: I0cb19224ee81895ba9dff48dddab18d91f119c6b
Reviewed-on: http://review.couchbase.org/32978
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
smoke-test: disable CCCP

We use the mock and thus won't be using CCCP unless we add support for
the extended "GET_MCPORTS" mock command.

Change-Id: I7771c3421839bb2758116c983506820d50f545bf
Reviewed-on: http://review.couchbase.org/32979
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>