[server]: Don't scan output buffer if NULL

Change-Id: I88226b3c25f4a44b57a5a8060d19e08639f46323
Reviewed-on: http://review.couchbase.org/28280
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[iocp] various fixes

- Properly handle send_error:
    Set proper code and socket structure for its overlapped field

- Handle SO_UPDATE_CONNECT_CONTEXT failures:
    We sometimes get WSAENOTSOCK on this one

- Add WSAENOTSOCK to error list for w32err_2errno

- Fix socket leakage for each socket created (ouch!)

Change-Id: Ice2f451dad1e862fd6800df669b4af9b8c13a81b
Reviewed-on: http://review.couchbase.org/28281
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[connect timers]: Check if timer was active

Before cancelling it :)

Change-Id: I2ba119b7e32cddc5255b52ae4d012ea223ea3b13
Reviewed-on: http://review.couchbase.org/28282
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Don't check output if NULL

Change-Id: I774a906142f0668ac42f4b8246c562a8898064be
Reviewed-on: http://review.couchbase.org/28283
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[bconf] Overhaul

This cleans up the bucketconfig code; breakouts and error propagation
are done from the I/O handlers rather than the parsing handlers. This
allows the I/O handlers to more easily cancel the timeouts if necessary.

Among the additions:

- New lcb_cntl operation for a configuration timeout (5 seconds by
  default)
- 'bconf_provider' module, where most of the bucket config updating is
  done
- Move stuff from bconf_parse over to bconf_io where it affects instance
  state and likewise.

Change-Id: I1a31d990b7333e1691855eb311bbec48b71b8a21
Reviewed-on: http://review.couchbase.org/28284
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[http] Don't treat graceful close as an error

Now that we're sending Connection: close, it's perfectly fine (and in
fact, anticipated) that the server should close the connection when it's
ready. In this case, we need to consider it a success iff the parser has
finished too.

- Added LCB_SOCKRW_SHUTDOWN (technically, 0 means one of the two streams
  has been closed, so it's not technically a close in TCP parlance)

Change-Id: I126565c50cf3dbe9bc2ba79445bc8fd80e85962c
Reviewed-on: http://review.couchbase.org/28285
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Always include lcbuv source code in dist

Change-Id: I449fa1a0548ebf67992db7feb695823f791cc7ab
Reviewed-on: http://review.couchbase.org/28286
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[connect] don't set timeout handler to null after firing

Change-Id: Ie474b0d66cf8c9dcf921913a1c1ee476f21117fe
Reviewed-on: http://review.couchbase.org/28288
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[test-failover]: make dummy timer for iocp

We can't just run the event loop as the IOCP plugin will complain about
a timeout not being set. Let's make a dummy lcb_timer_t so it won't
complain

Change-Id: Ic624c1c48552a537f1c0cef9d8663f62f737de1b
Reviewed-on: http://review.couchbase.org/28289
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>