libcouchbase 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +1 -1
- data/ext/libcouchbase/CMakeLists.txt +8 -6
- data/ext/libcouchbase/README.markdown +2 -2
- data/ext/libcouchbase/RELEASE_NOTES.markdown +0 -86
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +0 -11
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +0 -2
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +1 -2
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +0 -2
- data/ext/libcouchbase/cmake/defs.mk.in +2 -0
- data/ext/libcouchbase/cmake/source_files.cmake +5 -21
- data/ext/libcouchbase/include/libcouchbase/auth.h +0 -10
- data/ext/libcouchbase/include/libcouchbase/cntl.h +1 -27
- data/ext/libcouchbase/include/libcouchbase/error.h +1 -15
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +1 -13
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +0 -9
- data/ext/libcouchbase/include/libcouchbase/views.h +1 -7
- data/ext/libcouchbase/include/libcouchbase/visibility.h +0 -1
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1131 -29
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +2 -3
- data/ext/libcouchbase/src/README.md +2 -0
- data/ext/libcouchbase/src/auth-priv.h +0 -1
- data/ext/libcouchbase/src/auth.cc +4 -10
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +39 -50
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +117 -84
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +25 -50
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +386 -407
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/cbft.cc +27 -22
- data/ext/libcouchbase/src/cntl.cc +19 -30
- data/ext/libcouchbase/src/connspec.cc +1 -48
- data/ext/libcouchbase/src/connspec.h +0 -27
- data/ext/libcouchbase/src/dump.cc +2 -2
- data/ext/libcouchbase/src/getconfig.cc +33 -7
- data/ext/libcouchbase/src/handler.cc +2 -0
- data/ext/libcouchbase/src/hostlist.cc +36 -0
- data/ext/libcouchbase/src/hostlist.h +62 -41
- data/ext/libcouchbase/src/http/http-priv.h +112 -125
- data/ext/libcouchbase/src/http/http.cc +30 -15
- data/ext/libcouchbase/src/http/http.h +34 -1
- data/ext/libcouchbase/src/http/http_io.cc +26 -22
- data/ext/libcouchbase/src/instance.cc +23 -94
- data/ext/libcouchbase/src/internal.h +26 -52
- data/ext/libcouchbase/src/jsparse/parser.cc +202 -146
- data/ext/libcouchbase/src/jsparse/parser.h +98 -91
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +163 -174
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +2 -9
- data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
- data/ext/libcouchbase/src/lcbio/iotable.h +16 -61
- data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
- data/ext/libcouchbase/src/lcbio/manager.c +2 -2
- data/ext/libcouchbase/src/mc/mcreq.h +2 -9
- data/ext/libcouchbase/src/mcserver/mcserver.cc +34 -143
- data/ext/libcouchbase/src/mcserver/mcserver.h +12 -7
- data/ext/libcouchbase/src/mcserver/negotiate.cc +38 -132
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
- data/ext/libcouchbase/src/n1ql/n1ql.cc +32 -56
- data/ext/libcouchbase/src/newconfig.cc +6 -6
- data/ext/libcouchbase/src/nodeinfo.cc +2 -2
- data/ext/libcouchbase/src/operations/{cbflush.cc → cbflush.c} +15 -7
- data/ext/libcouchbase/src/operations/{counter.cc → counter.c} +0 -0
- data/ext/libcouchbase/src/operations/durability.cc +26 -6
- data/ext/libcouchbase/src/operations/durability_internal.h +3 -6
- data/ext/libcouchbase/src/operations/{get.cc → get.c} +26 -24
- data/ext/libcouchbase/src/operations/{observe.cc → observe.c} +93 -68
- data/ext/libcouchbase/src/operations/{pktfwd.cc → pktfwd.c} +0 -0
- data/ext/libcouchbase/src/operations/{remove.cc → remove.c} +0 -0
- data/ext/libcouchbase/src/operations/stats.cc +8 -3
- data/ext/libcouchbase/src/operations/{store.cc → store.c} +32 -27
- data/ext/libcouchbase/src/operations/subdoc.cc +18 -38
- data/ext/libcouchbase/src/operations/{touch.cc → touch.c} +0 -0
- data/ext/libcouchbase/src/packetutils.c +37 -0
- data/ext/libcouchbase/src/packetutils.h +2 -2
- data/ext/libcouchbase/src/probes.d +1 -1
- data/ext/libcouchbase/src/{retrychk.cc → retrychk.c} +3 -2
- data/ext/libcouchbase/src/retryq.cc +4 -4
- data/ext/libcouchbase/src/settings.c +0 -3
- data/ext/libcouchbase/src/settings.h +0 -5
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +0 -1
- data/ext/libcouchbase/src/ssl/ssl_common.c +0 -2
- data/ext/libcouchbase/src/ssl/ssl_e.c +1 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/trace.h +4 -4
- data/ext/libcouchbase/src/vbucket/vbucket.c +1 -0
- data/ext/libcouchbase/src/views/{docreq.cc → docreq.c} +54 -48
- data/ext/libcouchbase/src/views/docreq.h +30 -24
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +13 -43
- data/ext/libcouchbase/tests/basic/t_connstr.cc +50 -89
- data/ext/libcouchbase/tests/basic/t_host.cc +75 -67
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +78 -27
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +78 -58
- data/ext/libcouchbase/tests/iotests/mock-environment.h +1 -2
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +114 -96
- data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
- data/lib/libcouchbase/ext/tasks.rb +6 -2
- data/lib/libcouchbase/query_view.rb +1 -1
- data/lib/libcouchbase/results_fiber.rb +6 -6
- data/lib/libcouchbase/version.rb +1 -1
- metadata +26 -26
- data/ext/libcouchbase/src/bootstrap.cc +0 -216
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +0 -281
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +0 -528
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +0 -115
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +0 -378
- data/ext/libcouchbase/src/dns-srv.cc +0 -142
- data/ext/libcouchbase/src/errmap.cc +0 -107
- data/ext/libcouchbase/src/errmap.h +0 -113
- data/ext/libcouchbase/src/lcbht/lcbht.cc +0 -177
- data/ext/libcouchbase/src/lcbio/connect.cc +0 -562
- data/ext/libcouchbase/src/lcbio/timer-cxx.h +0 -87
- data/ext/libcouchbase/src/mctx-helper.h +0 -51
- data/ext/libcouchbase/src/views/viewreq.cc +0 -318
- data/ext/libcouchbase/tests/iotests/t_errmap.cc +0 -97
|
@@ -43,7 +43,7 @@ Request::decref()
|
|
|
43
43
|
close_io();
|
|
44
44
|
|
|
45
45
|
if (parser) {
|
|
46
|
-
|
|
46
|
+
lcbht_free(parser);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (timer) {
|
|
@@ -103,6 +103,7 @@ void
|
|
|
103
103
|
Request::maybe_refresh_config(lcb_error_t err)
|
|
104
104
|
{
|
|
105
105
|
int htstatus_ok;
|
|
106
|
+
lcbht_RESPONSE *resp;
|
|
106
107
|
if (!parser) {
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
@@ -111,25 +112,25 @@ Request::maybe_refresh_config(lcb_error_t err)
|
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
htstatus_ok = resp
|
|
115
|
+
resp = lcbht_get_response(parser);
|
|
116
|
+
htstatus_ok = resp->status >= 200 && resp->status < 299;
|
|
116
117
|
|
|
117
118
|
if (err != LCB_SUCCESS && (err == LCB_ESOCKSHUTDOWN && htstatus_ok) == 0) {
|
|
118
119
|
/* ignore graceful close */
|
|
119
|
-
instance
|
|
120
|
+
lcb_bootstrap_common(instance, LCB_BS_REFRESH_ALWAYS);
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
if (htstatus_ok) {
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
|
-
instance
|
|
127
|
+
lcb_bootstrap_common(instance, LCB_BS_REFRESH_ALWAYS);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
void
|
|
130
131
|
Request::init_resp(lcb_RESPHTTP *res)
|
|
131
132
|
{
|
|
132
|
-
const
|
|
133
|
+
const lcbht_RESPONSE *htres = lcbht_get_response(parser);
|
|
133
134
|
|
|
134
135
|
res->cookie = const_cast<void*>(command_cookie);
|
|
135
136
|
res->key = url.c_str() + url_info.field_data[UF_PATH].off;
|
|
@@ -138,7 +139,9 @@ Request::init_resp(lcb_RESPHTTP *res)
|
|
|
138
139
|
if (!response_headers.empty()) {
|
|
139
140
|
res->headers = &response_headers_clist[0];
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
+
if (htres) {
|
|
143
|
+
res->htstatus = htres->status;
|
|
144
|
+
}
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
void
|
|
@@ -251,9 +254,9 @@ Request::submit()
|
|
|
251
254
|
// Only wipe old parser/response information if current I/O request
|
|
252
255
|
// was a success
|
|
253
256
|
if (parser) {
|
|
254
|
-
parser
|
|
257
|
+
lcbht_reset(parser);
|
|
255
258
|
} else {
|
|
256
|
-
parser =
|
|
259
|
+
parser = lcbht_new(instance->settings);
|
|
257
260
|
}
|
|
258
261
|
response_headers.clear();
|
|
259
262
|
response_headers_clist.clear();
|
|
@@ -459,12 +462,7 @@ Request::setup_inputs(const lcb_CMDHTTP *cmd)
|
|
|
459
462
|
return rc;
|
|
460
463
|
}
|
|
461
464
|
|
|
462
|
-
|
|
463
|
-
if (instance->settings->client_string) {
|
|
464
|
-
ua.append(" ").append(instance->settings->client_string);
|
|
465
|
-
}
|
|
466
|
-
add_header("User-Agent", ua);
|
|
467
|
-
|
|
465
|
+
add_header("User-Agent", "libcouchbase/" LCB_VERSION_STRING);
|
|
468
466
|
if (instance->http_sockpool->maxidle == 0 || !is_data_request()) {
|
|
469
467
|
add_header("Connection", "close");
|
|
470
468
|
}
|
|
@@ -615,6 +613,23 @@ Request::cancel()
|
|
|
615
613
|
finish(LCB_SUCCESS);
|
|
616
614
|
}
|
|
617
615
|
|
|
616
|
+
// Wrappers
|
|
617
|
+
void lcb_htreq_setcb(lcb_http_request_t req, lcb_RESPCALLBACK callback) {
|
|
618
|
+
req->callback = callback;
|
|
619
|
+
}
|
|
620
|
+
void lcb_htreq_block_callback(lcb_http_request_t req) {
|
|
621
|
+
req->block_callback();
|
|
622
|
+
}
|
|
623
|
+
void lcb_htreq_pause(lcb_http_request_t req) {
|
|
624
|
+
req->pause();
|
|
625
|
+
}
|
|
626
|
+
void lcb_htreq_resume(lcb_http_request_t req) {
|
|
627
|
+
req->resume();
|
|
628
|
+
}
|
|
629
|
+
void lcb_htreq_finish(lcb_t, lcb_http_request_t req, lcb_error_t rc) {
|
|
630
|
+
req->finish(rc);
|
|
631
|
+
}
|
|
632
|
+
|
|
618
633
|
LIBCOUCHBASE_API
|
|
619
634
|
void
|
|
620
635
|
lcb_cancel_http_request(lcb_t, lcb_http_request_t req)
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
#ifndef LCB_HTTPAPI_H
|
|
2
|
+
#define LCB_HTTPAPI_H
|
|
3
|
+
|
|
4
|
+
/* This file contains the internal API for HTTP requests. This allows us to
|
|
5
|
+
* change the internals without exposing the object structure to the rest
|
|
6
|
+
* of the library
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifdef __cplusplus
|
|
10
|
+
extern "C" {
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
void
|
|
14
|
+
lcb_htreq_setcb(lcb_http_request_t, lcb_RESPCALLBACK);
|
|
15
|
+
|
|
16
|
+
void
|
|
17
|
+
lcb_htreq_pause(lcb_http_request_t);
|
|
18
|
+
|
|
19
|
+
void
|
|
20
|
+
lcb_htreq_resume(lcb_http_request_t);
|
|
21
|
+
|
|
22
|
+
void
|
|
23
|
+
lcb_htreq_finish(lcb_t, lcb_http_request_t, lcb_error_t);
|
|
24
|
+
|
|
25
|
+
/* Prevents the callback from being invoked. This is different than a full
|
|
26
|
+
* destruction of the object. This is only called in lcb_destroy() to
|
|
27
|
+
* prevent dereferencing the instance itself.
|
|
28
|
+
*/
|
|
29
|
+
void
|
|
30
|
+
lcb_htreq_block_callback(lcb_http_request_t);
|
|
31
|
+
#ifdef __cplusplus
|
|
32
|
+
}
|
|
33
|
+
#endif
|
|
34
|
+
#endif
|
|
@@ -30,13 +30,19 @@ using namespace lcb::http;
|
|
|
30
30
|
#define LOGARGS(req, lvl) req->instance->settings, "http-io", LCB_LOG_##lvl, __FILE__, __LINE__
|
|
31
31
|
|
|
32
32
|
void
|
|
33
|
-
Request::assign_response_headers(const
|
|
33
|
+
Request::assign_response_headers(const lcbht_RESPONSE *resp)
|
|
34
34
|
{
|
|
35
|
-
response_headers.
|
|
35
|
+
response_headers.clear();
|
|
36
36
|
response_headers_clist.clear();
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
sllist_node *curnode;
|
|
39
|
+
SLLIST_ITERBASIC(&resp->headers, curnode) {
|
|
40
|
+
lcbht_MIMEHDR *hdr = SLLIST_ITEM(curnode, lcbht_MIMEHDR, slnode);
|
|
41
|
+
response_headers.push_back(Header(hdr->key, hdr->value));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
std::vector<Header>::const_iterator ii = response_headers.begin();
|
|
45
|
+
for (; ii != response_headers.end(); ++ii) {
|
|
40
46
|
response_headers_clist.push_back(ii->key.c_str());
|
|
41
47
|
response_headers_clist.push_back(ii->value.c_str());
|
|
42
48
|
}
|
|
@@ -47,30 +53,29 @@ int
|
|
|
47
53
|
Request::handle_parse_chunked(const char *buf, unsigned nbuf)
|
|
48
54
|
{
|
|
49
55
|
int parse_state, oldstate, diff;
|
|
50
|
-
|
|
51
|
-
lcb::htparse::Response& res = parser->get_cur_response();
|
|
56
|
+
lcbht_RESPONSE *res = lcbht_get_response(parser);
|
|
52
57
|
|
|
53
58
|
do {
|
|
54
59
|
const char *rbody;
|
|
55
60
|
unsigned nused = -1, nbody = -1;
|
|
56
|
-
oldstate = res
|
|
61
|
+
oldstate = res->state;
|
|
57
62
|
|
|
58
|
-
parse_state = parser
|
|
63
|
+
parse_state = lcbht_parse_ex(parser, buf, nbuf, &nused, &nbody, &rbody);
|
|
59
64
|
diff = oldstate ^ parse_state;
|
|
60
65
|
|
|
61
66
|
/* Got headers now for the first time */
|
|
62
|
-
if (diff &
|
|
67
|
+
if (diff & LCBHT_S_HEADER) {
|
|
63
68
|
assign_response_headers(res);
|
|
64
|
-
if (res
|
|
65
|
-
const char *redir = res
|
|
69
|
+
if (res->status >= 300 && res->status <= 400) {
|
|
70
|
+
const char *redir = lcbht_get_resphdr(res, "Location");
|
|
66
71
|
if (redir != NULL) {
|
|
67
72
|
pending_redirect.assign(redir);
|
|
68
|
-
return
|
|
73
|
+
return LCBHT_S_DONE;
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
if (parse_state &
|
|
78
|
+
if (parse_state & LCBHT_S_ERROR) {
|
|
74
79
|
/* nothing to do here */
|
|
75
80
|
return parse_state;
|
|
76
81
|
}
|
|
@@ -86,22 +91,22 @@ Request::handle_parse_chunked(const char *buf, unsigned nbuf)
|
|
|
86
91
|
callback(instance, LCB_CALLBACK_HTTP, (const lcb_RESPBASE *)&htresp);
|
|
87
92
|
|
|
88
93
|
} else {
|
|
89
|
-
res
|
|
94
|
+
lcb_string_append(&res->body, rbody, nbody);
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
buf += nused;
|
|
94
99
|
nbuf -= nused;
|
|
95
|
-
} while ((parse_state &
|
|
100
|
+
} while ((parse_state & LCBHT_S_DONE) == 0 && is_ongoing() && nbuf);
|
|
96
101
|
|
|
97
|
-
if ( (parse_state &
|
|
102
|
+
if ( (parse_state & LCBHT_S_DONE) && is_ongoing()) {
|
|
98
103
|
lcb_RESPHTTP resp = { 0 };
|
|
99
104
|
if (chunked) {
|
|
100
105
|
buf = NULL;
|
|
101
106
|
nbuf = 0;
|
|
102
107
|
} else {
|
|
103
|
-
buf = res
|
|
104
|
-
nbuf = res
|
|
108
|
+
buf = res->body.base;
|
|
109
|
+
nbuf = res->body.nused;
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
init_resp(&resp);
|
|
@@ -138,8 +143,7 @@ io_read(lcbio_CTX *ctx, unsigned nr)
|
|
|
138
143
|
nbuf = lcbio_ctx_risize(&iter);
|
|
139
144
|
parse_state = req->handle_parse_chunked(buf, nbuf);
|
|
140
145
|
|
|
141
|
-
if ((parse_state &
|
|
142
|
-
req->has_pending_redirect()) {
|
|
146
|
+
if ((parse_state & LCBHT_S_ERROR) || req->has_pending_redirect()) {
|
|
143
147
|
rv = -1;
|
|
144
148
|
break;
|
|
145
149
|
} else if (!req->is_ongoing()) {
|
|
@@ -152,7 +156,7 @@ io_read(lcbio_CTX *ctx, unsigned nr)
|
|
|
152
156
|
// parse error or redirect
|
|
153
157
|
lcb_error_t err;
|
|
154
158
|
if (req->has_pending_redirect()) {
|
|
155
|
-
instance
|
|
159
|
+
lcb_bootstrap_common(instance, LCB_BS_REFRESH_THROTTLE);
|
|
156
160
|
// Transfer control to redirect function()
|
|
157
161
|
lcb_log(LOGARGS(req, DEBUG), LOGFMT "Attempting redirect to %s", LOGID(req), req->pending_redirect.c_str());
|
|
158
162
|
req->redirect();
|
|
@@ -293,7 +297,7 @@ Request::close_io()
|
|
|
293
297
|
int can_ka;
|
|
294
298
|
|
|
295
299
|
if (parser && is_data_request()) {
|
|
296
|
-
can_ka = parser
|
|
300
|
+
can_ka = lcbht_can_keepalive(parser);
|
|
297
301
|
} else {
|
|
298
302
|
can_ka = 0;
|
|
299
303
|
}
|
|
@@ -116,57 +116,17 @@ lcb_st::populate_nodes(const Connspec& spec)
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
lcb_error_t
|
|
120
|
-
lcb_st::process_dns_srv(Connspec& spec)
|
|
121
|
-
{
|
|
122
|
-
if (!spec.can_dnssrv()) {
|
|
123
|
-
return LCB_SUCCESS;
|
|
124
|
-
}
|
|
125
|
-
if (spec.hosts().empty()) {
|
|
126
|
-
lcb_log(LOGARGS(this, ERR), "Cannot use DNS SRV without a hostname");
|
|
127
|
-
return spec.is_explicit_dnssrv() ? LCB_EINVAL : LCB_SUCCESS;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const Spechost& host = spec.hosts().front();
|
|
131
|
-
lcb_error_t rc = LCB_ERROR;
|
|
132
|
-
Hostlist* hl = dnssrv_getbslist(host.hostname.c_str(), host.isSSL(), rc);
|
|
133
|
-
|
|
134
|
-
if (hl == NULL) {
|
|
135
|
-
lcb_log(LOGARGS(this, INFO), "DNS SRV lookup failed: %s. Ignore this if not relying on DNS SRV records", lcb_strerror(this, rc));
|
|
136
|
-
if (spec.is_explicit_dnssrv()) {
|
|
137
|
-
return rc;
|
|
138
|
-
} else {
|
|
139
|
-
return LCB_SUCCESS;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
spec.clear_hosts();
|
|
144
|
-
for (size_t ii = 0; ii < hl->size(); ++ii) {
|
|
145
|
-
const lcb_host_t& src = (*hl)[ii];
|
|
146
|
-
Spechost sh;
|
|
147
|
-
sh.hostname = src.host;
|
|
148
|
-
sh.port = std::atoi(src.port);
|
|
149
|
-
sh.type = spec.default_port();
|
|
150
|
-
spec.add_host(sh);
|
|
151
|
-
lcb_log(LOGARGS(this, INFO), "Found host %s:%d via DNS SRV", sh.hostname.c_str(), sh.port);
|
|
152
|
-
}
|
|
153
|
-
delete hl;
|
|
154
|
-
|
|
155
|
-
return LCB_SUCCESS;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
119
|
static lcb_error_t
|
|
159
120
|
init_providers(lcb_t obj, const Connspec &spec)
|
|
160
121
|
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
mcraw = obj->confmon->get_provider(CLCONFIG_MCRAW);
|
|
122
|
+
clconfig_provider *http, *cccp, *mcraw;
|
|
123
|
+
http = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_HTTP);
|
|
124
|
+
cccp = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_CCCP);
|
|
125
|
+
mcraw = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_MCRAW);
|
|
166
126
|
|
|
167
127
|
if (spec.default_port() == LCB_CONFIG_MCCOMPAT_PORT) {
|
|
168
|
-
obj->confmon
|
|
169
|
-
mcraw->configure_nodes(
|
|
128
|
+
lcb_confmon_set_provider_active(obj->confmon, LCB_CLCONFIG_MCRAW, 1);
|
|
129
|
+
mcraw->configure_nodes(mcraw, obj->mc_nodes);
|
|
170
130
|
return LCB_SUCCESS;
|
|
171
131
|
}
|
|
172
132
|
|
|
@@ -195,7 +155,7 @@ init_providers(lcb_t obj, const Connspec &spec)
|
|
|
195
155
|
if (spec.is_bs_file()) {
|
|
196
156
|
/* If the 'file_only' provider is set, just assume something else
|
|
197
157
|
* will provide us with the config, and forget about it. */
|
|
198
|
-
|
|
158
|
+
clconfig_provider *prov = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_FILE);
|
|
199
159
|
if (prov && prov->enabled) {
|
|
200
160
|
return LCB_SUCCESS;
|
|
201
161
|
}
|
|
@@ -204,17 +164,17 @@ init_providers(lcb_t obj, const Connspec &spec)
|
|
|
204
164
|
}
|
|
205
165
|
|
|
206
166
|
if (http_enabled) {
|
|
207
|
-
http
|
|
208
|
-
http
|
|
167
|
+
lcb_clconfig_http_enable(http);
|
|
168
|
+
lcb_clconfig_http_set_nodes(http, obj->ht_nodes);
|
|
209
169
|
} else {
|
|
210
|
-
obj->confmon
|
|
170
|
+
lcb_confmon_set_provider_active(obj->confmon, LCB_CLCONFIG_HTTP, 0);
|
|
211
171
|
}
|
|
212
172
|
|
|
213
173
|
if (cccp_enabled && obj->type != LCB_TYPE_CLUSTER) {
|
|
214
|
-
cccp
|
|
215
|
-
cccp
|
|
174
|
+
lcb_clconfig_cccp_enable(cccp, obj);
|
|
175
|
+
lcb_clconfig_cccp_set_nodes(cccp, obj->mc_nodes);
|
|
216
176
|
} else {
|
|
217
|
-
obj->confmon
|
|
177
|
+
lcb_confmon_set_provider_active(obj->confmon, LCB_CLCONFIG_CCCP, 0);
|
|
218
178
|
}
|
|
219
179
|
return LCB_SUCCESS;
|
|
220
180
|
}
|
|
@@ -419,7 +379,7 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
419
379
|
obj->memd_sockpool->tmoidle = 10000000;
|
|
420
380
|
obj->http_sockpool->maxidle = 1;
|
|
421
381
|
obj->http_sockpool->tmoidle = 10000000;
|
|
422
|
-
obj->confmon =
|
|
382
|
+
obj->confmon = lcb_confmon_create(settings, obj->iotable);
|
|
423
383
|
obj->ht_nodes = new Hostlist();
|
|
424
384
|
obj->mc_nodes = new Hostlist();
|
|
425
385
|
obj->retryq = new RetryQueue(&obj->cmdq, obj->iotable, obj->settings);
|
|
@@ -438,15 +398,8 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
438
398
|
goto GT_DONE;
|
|
439
399
|
}
|
|
440
400
|
|
|
441
|
-
if ((err = obj->process_dns_srv(spec)) != LCB_SUCCESS) {
|
|
442
|
-
goto GT_DONE;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
401
|
obj->populate_nodes(spec);
|
|
446
|
-
|
|
447
|
-
goto GT_DONE;
|
|
448
|
-
}
|
|
449
|
-
|
|
402
|
+
err = init_providers(obj, spec);
|
|
450
403
|
if (err != LCB_SUCCESS) {
|
|
451
404
|
lcb_destroy(obj);
|
|
452
405
|
return err;
|
|
@@ -493,12 +446,10 @@ void lcb_destroy(lcb_t instance)
|
|
|
493
446
|
lcb_ASPEND_SETTYPE::iterator it;
|
|
494
447
|
lcb_ASPEND_SETTYPE *pendq;
|
|
495
448
|
|
|
496
|
-
|
|
497
|
-
instance->cur_configinfo->decref();
|
|
498
|
-
instance->cur_configinfo = NULL;
|
|
499
|
-
}
|
|
449
|
+
DESTROY(lcb_clconfig_decref, cur_configinfo);
|
|
500
450
|
instance->cmdq.config = NULL;
|
|
501
|
-
|
|
451
|
+
|
|
452
|
+
lcb_bootstrap_destroy(instance);
|
|
502
453
|
DESTROY(delete, ht_nodes);
|
|
503
454
|
DESTROY(delete, mc_nodes);
|
|
504
455
|
|
|
@@ -522,14 +473,14 @@ void lcb_destroy(lcb_t instance)
|
|
|
522
473
|
|
|
523
474
|
if ((pendq = po->items[LCB_PENDTYPE_HTTP])) {
|
|
524
475
|
for (it = pendq->begin(); it != pendq->end(); ++it) {
|
|
525
|
-
|
|
526
|
-
htreq
|
|
527
|
-
htreq
|
|
476
|
+
lcb_http_request_t htreq = reinterpret_cast<lcb_http_request_t>(*it);
|
|
477
|
+
lcb_htreq_block_callback(htreq);
|
|
478
|
+
lcb_htreq_finish(instance, htreq, LCB_ERROR);
|
|
528
479
|
}
|
|
529
480
|
}
|
|
530
481
|
|
|
531
482
|
DESTROY(delete, retryq);
|
|
532
|
-
DESTROY(
|
|
483
|
+
DESTROY(lcb_confmon_destroy, confmon);
|
|
533
484
|
DESTROY(lcbio_mgr_destroy, memd_sockpool);
|
|
534
485
|
DESTROY(lcbio_mgr_destroy, http_sockpool);
|
|
535
486
|
DESTROY(lcb_vbguess_destroy, vbguess);
|
|
@@ -583,23 +534,10 @@ lcb_destroy_async(lcb_t instance, const void *arg)
|
|
|
583
534
|
lcbio_async_signal(instance->dtor_timer);
|
|
584
535
|
}
|
|
585
536
|
|
|
586
|
-
lcb::Server *
|
|
587
|
-
lcb_st::find_server(const lcb_host_t& host) const
|
|
588
|
-
{
|
|
589
|
-
unsigned ii;
|
|
590
|
-
for (ii = 0; ii < cmdq.npipelines; ii++) {
|
|
591
|
-
lcb::Server *server = static_cast<lcb::Server*>(cmdq.pipelines[ii]);
|
|
592
|
-
if (lcb_host_equals(&server->get_host(), &host)) {
|
|
593
|
-
return server;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
return NULL;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
537
|
LIBCOUCHBASE_API
|
|
600
538
|
lcb_error_t lcb_connect(lcb_t instance)
|
|
601
539
|
{
|
|
602
|
-
lcb_error_t err = instance
|
|
540
|
+
lcb_error_t err = lcb_bootstrap_common(instance, LCB_BS_REFRESH_INITIAL);
|
|
603
541
|
if (err == LCB_SUCCESS) {
|
|
604
542
|
SYNCMODE_INTERCEPT(instance);
|
|
605
543
|
} else {
|
|
@@ -780,15 +718,6 @@ const char *lcb_strerror(lcb_t instance, lcb_error_t error)
|
|
|
780
718
|
return "Unknown error";
|
|
781
719
|
}
|
|
782
720
|
|
|
783
|
-
LCB_INTERNAL_API
|
|
784
|
-
const char *lcb_strerror_short(lcb_error_t error)
|
|
785
|
-
{
|
|
786
|
-
#define X(c, v, t, s) if (error == c) { return #c " (" #v ")"; }
|
|
787
|
-
LCB_XERR(X)
|
|
788
|
-
#undef X
|
|
789
|
-
return "<FIXME: Not an LCB error>";
|
|
790
|
-
}
|
|
791
|
-
|
|
792
721
|
LIBCOUCHBASE_API
|
|
793
722
|
int lcb_get_errtype(lcb_error_t err)
|
|
794
723
|
{
|