Fix badmatch in couch_db:count_changes_since/2

The initial accumulator must be a binary, otherwise we badmatch
when fold reducing has no iterations.

Change-Id: I30bfad669819b5e867643623aeb77a7a319db005
Reviewed-on: http://review.couchbase.org/14518
Tested-by: Damien Katz <damien@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Use enif_is_number on OTP R15B or higher

The NIF API in OTP R15B introduced the enif_is_number function.
http://www.erlang.org/download/otp_src_R15B.readme (issue OTP-9629).

Change-Id: I13e46a1ad7b1b8b9609be1c9a8a763685bc04b34
Reviewed-on: http://review.couchbase.org/14497
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Minimize amount of time dbs are open by the index updater

Not only file descriptors are released sooner when database
compaction happens, but also increases the chances of the
indexer being able to do fast database reads.

Change-Id: I317c29deda106c5c8c701f468050fb3939635fe8
Reviewed-on: http://review.couchbase.org/14534
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Add missing flush call to test/etap/010-file-basics.t

Change-Id: I64d78f48f78591a887c0fd24cd9f11301cd3bd89
Reviewed-on: http://review.couchbase.org/14584
Tested-by: Damien Katz <damien@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Add lhttpc, a lightweight HTTP client library

Change-Id: I4a42e7d5c690b53a257e60bd804bb5a3a75caa20
Reviewed-on: http://review.couchbase.org/14576
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Replicator now uses lhttpc instead of ibrowse

Change-Id: I9c920c8b350c8d2234253103696eb4b16b981527
Reviewed-on: http://review.couchbase.org/14577
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Remove couch_httpd_proxy

This is not used for Couchbase Server, and would need
some work in order to make it use lhttpc instead of
ibrowse.

Change-Id: Ib83cdb45826ecc1afdddd328d6d5656c8dfc364e
Reviewed-on: http://review.couchbase.org/14578
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
View merger now uses lhttpc instead of ibrowse

Change-Id: I4bb37c520e2396b015901180a7ef15e3d937ff7c
Reviewed-on: http://review.couchbase.org/14591
Tested-by: buildbot <build@couchbase.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Ensure view merger reuses sockets more often

For the cases where the merger kills remote view folders (for e.g.
queries with ?limit=N), ensure that the folders pull out all data
from the connection socket so that it can be reused for future
requests/queries.

Change-Id: I7fca0503103de07fbdfe5fae612689a5f256ae1e
Reviewed-on: http://review.couchbase.org/14592
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Remove ibrowse library

This is not needed anymore, lhttpc is now used everywhere else.

Change-Id: I4cdd3a023a514e4495c8ce3cb7538e9b1fcb88ac
Reviewed-on: http://review.couchbase.org/14598
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Remove test test/etap/220-compaction-daemon.t

Not useful. Couchbase Server uses another compaction daemon
module which is part of ns_server component.

Change-Id: Ib7bd5d41c93d9add7fb0491ec43ecf761a9f0c1c
Reviewed-on: http://review.couchbase.org/14599
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Use os:timestamp/0 instead of erlang:now/0

It's faster and consumes less CPU. Learned from WhatsApp
scaling presentation.

Change-Id: I6d44da4cec0c0129a77cb267125e2e6bf7b27539
Reviewed-on: http://review.couchbase.org/14602
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
Add plugin dependencies to Erlang library path

If a plugin (like GeoCouch) has additional dependencies, they
are stored within a directory called "deps" within the directory
of the plugin. This "deps" directory gets added to the ERL_LIBS
environment variable in case it exists and the plugin is enabled.

Change-Id: Ifc463fd031ccd142410da9420e53e90d42418b0d
Reviewed-on: http://review.couchbase.org/9883
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>