testapp failure observed when linked against a newer OpenSSL (seen on OSX).

The fix though is not actually a library issue but just an issue with our send
code returning the wrong send length, we must return the SSL_write number,
not the send number (the send number will be bigger as SSL inflates the data
by some amount).

Change-Id: I93f33c9ec791f3f174f624afd8d8adaf6c5f5d48
Reviewed-on: http://review.couchbase.org/40532
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Merge remote-tracking branch 'membase/3.0'

* membase/3.0:
  testapp failure observed when linked against a newer OpenSSL (seen on OSX).

Change-Id: Ib9a6bbb9da92de1fd96272f21b96d302e9dcb9d6
MB-11066: Document mutable config tokens

Change-Id: I2a6d03225e17e3b88a33e327e153ed4cfeb3bf27
Reviewed-on: http://review.couchbase.org/40615
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MSVC does not support %zu

Change-Id: Iedc909a654137cd7b471dbc97edeaf6941d02ecb
Reviewed-on: http://review.couchbase.org/40652
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Merge remote-tracking branch 'membase/3.0'

* membase/3.0:
  MSVC does not support %zu

Change-Id: I6a0bf528ed56fc5ad5944130a1946344d41b2b92
MB-11968: Remove unused functionality

Remove the following unused functionality:
 * daemonize
 * lock memory pages into memory
 * Enable large memory pages
 * Support for creating a pid_file

Change-Id: Ic77e24d3719d149bad836ce7dc2ff867dc07f467
Reviewed-on: http://review.couchbase.org/40646
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11969 Remove detailed key stats

Change-Id: If4bf7359f5a5fad31e23174f192f0a99f94ab11b
Reviewed-on: http://review.couchbase.org/40649
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Zero dynamic_buffer.size when it is cleared

To assist in parsing 'connections' stats, also reset dynamic_buffer.size to
zero when we reset the buffer pointer.

Change-Id: I1c336f1723d2d52ba184053d1068ad51417d0a0a
Reviewed-on: http://review.couchbase.org/40369
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11066: Refactor config parsing code to allow parse at arbitrary time

Refactor the memcached config parsing code to prepare for changes to
allow dynamic config update. This patch does three main things:

* Changes all the error handling to pass back a true/false status code
  (and associated error message if false), instead of printing to
  stderr and exit()ing.

* Change the parsing code to pass in a {settings} struct to be
  populated. This allows a new config to be parsed while the current
  config is unchanged - for example to permit verification of a
  proposed config.

* Change the parsing code to move any "handling" of config changes
  (e.g. loading of specified extensions) from the parsing of the
  config. Again, this paves the way for being able to seperate config
  parsing from applying settings to the system.

Change-Id: I23d9c2c1bee33541f41c3c7d696b8dce1c1294c0
Reviewed-on: http://review.couchbase.org/40749
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11066: Unit tests for config_parse

Add unit test for config_parse functionality. Initially this is to
test the current config parsing.

Change-Id: I8ce6f6311b403336c8f9a041e9ca540fe0919df7
Reviewed-on: http://review.couchbase.org/40750
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fix clean build for config_parse on dtrace systems

Change-Id: I6eb572c9362ae229ec05221be3b73fe1777935d7
Reviewed-on: http://review.couchbase.org/40880
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Split the generated test suite into multiple units

Change-Id: I8528603961d106945ad65f97c589fa59903de993
Reviewed-on: http://review.couchbase.org/40877
Reviewed-by: Chris Hillery <ceej@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Added hack for ancient gcc compilers without proper C++11

Change-Id: I0ace99065432c4e9b90a727065ab4d842fa12fd8
Reviewed-on: http://review.couchbase.org/40899
Reviewed-by: Nimish Gupta <nimish@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Split the generated test suite into multiple units

Change-Id: I01c28cbc6dd6f193034d3c345e15a8702a7f1606
Reviewed-on: http://review.couchbase.org/40931
Reviewed-by: Chris Hillery <ceej@couchbase.com>
Tested-by: Chris Hillery <ceej@couchbase.com>
MB-11066: Add support for dynamically reloading memcached JSON config

Adds the ability for the memcached JSON config file to be reloaded
while memcached is running. Note that only a limited subset of
settings can be changed at runtime - see memcached.json man page for
details of these.

This is achived by adding two new binary protocol messages:
CONFIG_VALIDATE and CONFIG_RELOAD.

* PROTOCOL_BINARY_CMD_CONFIG_VALIDATE - Used to validate a proposed
  config change. Client sends the proposed JSON config file as the
  body of the request, and memcached will check if the changes are
  valid to apply to the running config. If so returns SUCCESS, if not
  EINVAL.

* PROTOCOL_BINARY_CMD_CONFIG_RELOAD - Instructs memcached to re-read
  the original config file specified at startup (i.e. the -C
  command-line option). If the config is valid applies all
  runtime-modifiable settings. Requires admin privileges.

At this stage there is no client support, other than in testapp.

Change-Id: If8c61cb4c083ffc68d2a700692a866f11c6dd318
Reviewed-on: http://review.couchbase.org/40751
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Merge remote-tracking branch 'membase/3.0'

* membase/3.0:
  Split the generated test suite into multiple units

Change-Id: I405806dc2746e894982ddd8ac70e4854355a1830
MB-11066: Temp: Change config change loglevel from INFO -> WARN

Config change log levels should conceptually be 'Info' level messages,
but we currently have the default level as 'WARN' (and the world logs
at that level - see MB-12035). For now go along with the rest of
memcached/ep-engine and use WARN.

Change-Id: I98f468ba7acb1d2908b842c1e75697ddc7e63661
Reviewed-on: http://review.couchbase.org/40754
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11859: 'connections' stats returns... JSONified

Restore the 'connections' stats removed by 7aaf80e, bringing back in
JSON format for richer formatting / ease of manipulation. Each
connection structure is returned as a 'stat' document, with the value
a JSON document describing that conneciton.

Example (for a single connection):

    {
      "aiostat": 0,
      "cas": "0x0",
      "cmd": 16,
      "conn": "0x10be9c900",
      "dynamic_buffer": {
        "buffer": "0x0",
        "offset": 0,
        "size": 0
      },
      "engine_storage": "0x10968a160",
      "ev_flags": 18,
      "ewouldblock": false,
      "iov": {
        "ptr": "0x10bce8080",
        "size": 10,
        "used": 0
      },
      "item": "0x0",
      "itemlist": {
        "curr": "0x0",
        "left": 0,
        "list": "0x0",
        "size": 0
      },
      "keylen": 11,
      "list_state": 0,
      "msglist": {
        "bytes": 0,
        "curr": 0,
        "list": "0x1041d21c0",
        "size": 5,
        "used": 1
      },
      "nevents": 20,
      "next": "0x0",
      "noreply": false,
      "opaque": "0xffffffffb46231bf",
      "protocol": "binary",
      "read": {
        "buf": "0x10423b000",
        "bytes": 0,
        "curr": "0x10423b023",
        "size": 2048
      },
      "refcount": 1,
      "registered_in_libevent": true,
      "ritem": "0x10423b023",
      "rlbytes": 0,
      "sbytes": 0,
      "socket": 47,
      "state": [
        "conn_nread",
        "bin_reading_packet"
      ],
      "store_op": 0,
      "tap_iterator": "0x0",
      "temp_alloc_list": {
        "curr": "0x107191720",
        "left": 0,
        "list": "0x107191720",
        "size": 20
      },
      "thread": "0x104216270",
      "transport": "TCP",
      "which": 2,
      "write": {
        "buf": "0x109980000",
        "bytes": 0,
        "curr": "0x109980000",
        "size": 2048
      },
      "write_and_free": "0x0",
      "write_and_go": "0x1032bc3d0"
    }

Change-Id: I8f955c550d6968846ed4919af1761e95b603537f
Reviewed-on: http://review.couchbase.org/40924
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fixup config_parse_test

The test failed on Linux due to the fact that the test
required TMP, TEMP or TMPDIR to be set in environment.
We can always use /tmp or /var/tmp if these directories
don't exist.

In addition the tests didn't flush the output buffer making
the "progress" invisible (and missing a newline at the end)

Change-Id: I3a7c463a38da4dde32472d64fb8aa70c0aa9bba1
Reviewed-on: http://review.couchbase.org/41013
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Remove unused field (reported by clion)

Change-Id: I4c032ad49c6ea3cc7d1ac65fd72bc86ef3e6a40e
Reviewed-on: http://review.couchbase.org/41137
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>