Log server changes

Change-Id: I75e0ae462ca12b364f326729e3bc9352d4afe16f
Reviewed-on: http://review.couchbase.org/33004
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Clear event watchers before invoking connection callback

This lets a socket remain "Idle" without receiving readability events.
Useful for an immediately-released connmgr socket

Change-Id: If57d6ac4adc3da48a0ac2b35f9cfe1c15eb07087
Reviewed-on: http://review.couchbase.org/33007
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Provide API to disable specific providers

- The environment variables LCB_NO_HTTP and LCB_NO_CCCP may also be used
  to control these settings from the environment

Change-Id: I1b869510645b0b8854406f07d33542083d238b88
Reviewed-on: http://review.couchbase.org/33041
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
cbc: add switch --config-transport to choose HTTP/CCCP

Change-Id: I4ddc2ac37d23ca84fddba0f28e8047879dfeb548
Reviewed-on: http://review.couchbase.org/33042
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-234 Add lcb_cntl command to determine source of configuration

Change-Id: I2ead6c25cc6011ab5b5334ad707dd47ff0d20eb4
Reviewed-on: http://review.couchbase.org/33044
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
http: Check for empty path and use "/"

Otherwise we end up with malloc(0) and all sorts of odd stuff happens

Change-Id: I5f3cac958d5d179dc5dbe08ad60928b59c7af5b5
Reviewed-on: http://review.couchbase.org/33105
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
http: also refresh config on non-successful HTTP status

Change-Id: Ida0e4768bd300a4f11a09c8c66a2dbb062f7ff01
Reviewed-on: http://review.couchbase.org/33106
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
http: free hdr->key and hdr->value

Fixes memleak

Change-Id: Ia384389a5ea45e5098102aa3c0e1d26329e635c3
Reviewed-on: http://review.couchbase.org/33107
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
select: fixup timers

This commit adapts a timer model similar to what is used in IOCP

Previously, select would not order timers which would break some
other assumptions made in the code about timer ordering. This ensures
timeouts are ordered within the list.

Change-Id: Ia5fcc3237990806c18c5fb359c2b5a1af1ce78fc
Reviewed-on: http://review.couchbase.org/33108
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
select: don't embed fd_set inside iops structure

we only use it inside the loop, so this can be a loop-local variable

Change-Id: Ibcf728333751d8c00a4bc8951dbe961875734b0c
Reviewed-on: http://review.couchbase.org/33109
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Add 'counted' list which maintains size

This makes it easier to track the number of items within a list without
maintaining an external counter

In the future, we'd like to consolidate this into a uniform
implementation of list/node types. See CCBC-317

Change-Id: I449c52c3b91e9d13230a5576f71ba4be54cf4c5a
Reviewed-on: http://review.couchbase.org/33110
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
transfer_socket: Don't perform checks if to==from

We should return when we detect the connections are idential, as the
assertions are only for actual transfers

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

- Replace list+explicit counter with new 'clist'
- Replace timer_create/destroy with rearm/disarm
- Added dump function to print pool state to stderr
- Added 'lcb_async_signal' and 'lcb_async_cancel' to timer.h

Change-Id: Ibd2eaee63dbd4be24f5c1096b3c45d3edc265d0f
Reviewed-on: http://review.couchbase.org/33112
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Increase efficiency for connection pools

This commit attempts to be a bit more judicious about how sockets are
released back to the pool. This is important in rebalance scenarios
where the configuration changes frequently and server structures are
created and destroyed.

The notable changes are:

- Don't use apply_want for READ_EVENT if we have nothing to read
- Fix up some bugs in the CCCP provider which cause it to stall, release
  a bad socket, or not acquire a proper socket
- Fix up bugs in server_io.c where it would release a timed-out socket

Change-Id: Ifa3353ae05f34175680ef2ae2db7df6666dd917d
Reviewed-on: http://review.couchbase.org/33113
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Add time conversion macros

Change-Id: Idc5dfb08c5c54d96fe92a45ed10fd7c8cb0faf74
Reviewed-on: http://review.couchbase.org/33116
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Actually refresh on bootstrap_incr when count gets high enoguh

Change-Id: If618cfb98afa00ce40e5f9779a45c46280260336
Reviewed-on: http://review.couchbase.org/33115
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-316: Provide per-node config timeout

This provides a more "Semantic" bootstrap timeout by ensuring we don't
wait too long for any particular node. Useful for weeding out offline
nodes.

Behavior/API Modifications:

- Adding new lcb_cntl for this setting
- Changing timers in bucketconfig to use config_node_timeout rather than
  config_timeout
- config_node_timeout is set to 2 seconds by default

Change-Id: I12326d67934047d40bd9519e322c01685564834c
Reviewed-on: http://review.couchbase.org/33130
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Re-organize CMakeLists

The goal here is to make our code and build system more modular, with
the ultimate aim of being able to -theoretically- ship some components
as being standalone.

The first step is trying to untangle the build process - where multiple
modules can be built independently into shared or static archives and
then linked ultimately into their resultant objects.

The second step is to eliminate the NMakefile

Currently supported:

- Plugin builds (libev, libuv, libevent)
- Tools (cbc, pillowfight)
- Tests (unit-test, smoke-test, check-all)
- SOVERSION
- DLL Version information
- config.h generation
- Fat binary builds (OS X)
- Maintainer mode

TODO:

- Make things completely out of tree. Currently the configuration.h
  header is still being generated inside the tree
- Better facilities for downloading the mock server
- Create source tarballs
- Create windows zipfiles and/or installers

Change-Id: I8402f8e8e0821af2e87ca425c985017de630b0e7
Reviewed-on: http://review.couchbase.org/32466
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-297: UV: Handle read_cb with no data and EAGAIN

Change-Id: I278816806fbb285aebd5ad319c3853e515e5803c
Reviewed-on: http://review.couchbase.org/33192
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Enhance version generation on win32

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