retryq: never fail missing node items during config refresh

If a configuration is being fetched currently then there is a good
chance that the item will end up with a node to service it. This allows
a sane behavior of not keeping the command 'aimlessly' in the queue if
there is no configuration to be retrieved, while on the other hand
allowing the item to wait until the configuration is finally fetched.

To accomodate this change, a new bootstrap internal API was added that
allows to request a new config purely based on the last-refresh interval
rather than also taking the 'error count' into consideration. We'd like
to refactor the internal bootstrap APIs as well but now is not the time
:)

In light of these changes, this fix also modifies the default behavior
to "Fail Fast" on items missing nodes, since the item will wait
appropriately for a new config if one is indeed being requested.

Change-Id: I0cdae86aae45178203917a1a9ec5561b142e239e
Reviewed-on: http://review.couchbase.org/39956
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Refactor all bootstrap entry points into a single function

These small functions are now defined as macros specified the relevant
flags to modify when the configuration is refreshed. Moving all the
logic into a single (not so big) function makes it much easier to follow
and understand.

Change-Id: I80102f12d1e23dd13684c44166180259c24d6c7b
Reviewed-on: http://review.couchbase.org/39957
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
CCBC-482: Don't throttle based on file-based initial config

This quickens recovery time based on a stale config.

This commit also changes the behavior so that the last_refresh timestamp
is always updated when a valid new config is received (which is not
file-based)

Change-Id: I1fa3376ec002d2d05ea559a68262b01199629a68
Reviewed-on: http://review.couchbase.org/39973
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Specify ctor options (i.e. k=v&k=v) as volatile

Change-Id: I49b9f542ec4634b09f5bf644c8de3b0f450c7ba3
Reviewed-on: http://review.couchbase.org/39972
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-483: don't use nmv payload if CCCP is disabled

If certain bugs are discovered with the CCCP payload then we can rely on
a pure HTTP config.

Change-Id: Ie113bc79ccd9ee7aff2c583104b95f04c04375cc
Reviewed-on: http://review.couchbase.org/39974
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Rewrite minimal example for clarity

Change-Id: I92b5c1b9e5ba605859f1a7285ac707d2e58fac99
Reviewed-on: http://review.couchbase.org/39986
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Fix internal doc formatting per Doxygen warnings

This fixes minor typos and mishaps within internal documentation (make
doc-internal)

Change-Id: Ic6a481a8f68316a5cc267f553de25f03fffe37fc
Reviewed-on: http://review.couchbase.org/40013
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
fix up compiler warnings (-Wextra)

Remove trailing comma from enum list

- examples/observe/observe.c: remove unused variable and fix sign comparison
- include/libcouchbase/api3.h: Remove trailing comma from enum list

Note that some other warnings still remain; this commit fixes those
warnings while not reducing clarity (for example, excessive casting in
examples)

Change-Id: I18c97cc4de20753297c1dedf9acba4e4425d69ac
Reviewed-on: http://review.couchbase.org/39985
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Intercept syncmode for HTTP

Change-Id: I61aaf793f8aff3f846ae983bc5660c3482d42962
Reviewed-on: http://review.couchbase.org/40032
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Change lcb_http_callback to lcb_http_res_callback

Otherwise it conflicts with a symbol defined in the php ext with the
same name.

Change-Id: Ic0d0d1bfc75fecd03831e3c6401d52eaecaf944e
Reviewed-on: http://review.couchbase.org/40033
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
CCBC-484: Patch ruby IOPS for creation

This patch resolves an issue which would otherwise break the ruby client
implementation. This is because the SDK assumes niov will be 2 for all
I/O functions, but this is no longer true.

This patch surgically replaces the default send/recv I/O related
functions if it's detected (heuristically) that Ruby is being used.

Change-Id: Ieef83b4b7b92d9728c614c1e6d725d41183c734b
Reviewed-on: http://review.couchbase.org/40030
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Update release metadata for 2.4.0 GA

Change-Id: I8158659af39b5664a9afed1b3092019d81ea53f1
Reviewed-on: http://review.couchbase.org/40015
Reviewed-by: Brett Lawson <brett19@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-485: Undocument 'ssl' and 'ca_path' from cntl_string

These two settings are no longer modifiable as of the 2.4 beta version

Change-Id: I7c79fdfc9a4cc1fc23022be51f55a38f164b5a0f
Reviewed-on: http://review.couchbase.org/40055
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Subhashni Balakrishnan <b.subhashni@gmail.com>
CCBC-486: Implement mcflush

This restores the old memcached flush command under the alias 'mcflush'.

This also fixes a bug with the verbosity command, and makes the two use
a common callback function.

This also adds a new entry into the release notes with different
formatting (including the priority and issue number)

Change-Id: I088f5418a58542ac0d7f17f9d696eafa85d2eac9
Reviewed-on: http://review.couchbase.org/40064
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-488: Fix incorrect bounds check in lcbvb_vbreplica

Change-Id: I0b57c4c806db2fa24dbbee53970920421312791d
Reviewed-on: http://review.couchbase.org/40082
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-489, CCBC-490: Get-With-Replica fixes

This commit fixes numerous issues with the lcb_rget3()/lcb_get_replica
API calls as outlined in the issues above. In summary, this commit:

- Ensures the H_getreplica handler in handlers.c properly invokes the
  customized callback (i.e. rget_callback in operations/get.c)
- Pre-validates the status of the replicas for rget3(), preventing
  memory leaks in the face of insufficient replicas for the API call.
- Adds tests for the common use cases of get-with-replica

Change-Id: I38c794a11bf6093c6fb523aeb299698d76387b91
Reviewed-on: http://review.couchbase.org/40083
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
CCBC-474: Fix memory leaks for extended commands in sched_fail

This adds a new field in the mc_REQDATAEX structure containing an
optional pointer to a destructor function which is called on each packet
that has been failed out. This may be used to decrement a reference
counter and/or free the extended cookie.

Change-Id: If6470d7370a31eb06e3e6ebd0c8f982f17b32124
Reviewed-on: http://review.couchbase.org/40128
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Provide lcb_dump() to output internal state

Currently this function is considered volatile. It will dump the
relevant state information of the library to a `FILE*` pointer passed to
it.

This patch touches some other areas of the code, mainly so that existing
dump functions accept a `FILE*`, and that the relevant information is
output.

Another (undocumented) argument (--dump) has been added to cbc, mainly
to test lcb_dump()'s rudimentary functionality.

Change-Id: If58fc74088feb017ce6c776f8edf7accee9779aa
Reviewed-on: http://review.couchbase.org/40070
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Clarify bootstrap API layout

This removes all the helper macro entry points into
lcb_bootstrap_common() and replaces them with direct calls. Additionally
it creates a new file called bootstrap.h which contains a more detailed
description of how bootstrap actually works, and is now indexed by
Doxygen via `make doc-internal`.

Change-Id: Ice53f3b34524ffb41ee0cb58897098ceaefc5206
Reviewed-on: http://review.couchbase.org/40014
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
cbc: allow `pillowfight` as pseudo-subcommand

Some users are familiar with the older form of `cbc pillowfight`. Let's
allow this use case if possible.

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