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.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +1 -1
  4. data/ext/libcouchbase/CMakeLists.txt +8 -6
  5. data/ext/libcouchbase/README.markdown +2 -2
  6. data/ext/libcouchbase/RELEASE_NOTES.markdown +0 -86
  7. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +0 -11
  8. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +0 -2
  9. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +1 -2
  10. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  11. data/ext/libcouchbase/cmake/config-cmake.h.in +0 -2
  12. data/ext/libcouchbase/cmake/defs.mk.in +2 -0
  13. data/ext/libcouchbase/cmake/source_files.cmake +5 -21
  14. data/ext/libcouchbase/include/libcouchbase/auth.h +0 -10
  15. data/ext/libcouchbase/include/libcouchbase/cntl.h +1 -27
  16. data/ext/libcouchbase/include/libcouchbase/error.h +1 -15
  17. data/ext/libcouchbase/include/libcouchbase/n1ql.h +1 -13
  18. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
  19. data/ext/libcouchbase/include/libcouchbase/subdoc.h +0 -9
  20. data/ext/libcouchbase/include/libcouchbase/views.h +1 -7
  21. data/ext/libcouchbase/include/libcouchbase/visibility.h +0 -1
  22. data/ext/libcouchbase/include/memcached/protocol_binary.h +1131 -29
  23. data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
  24. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  25. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +2 -3
  26. data/ext/libcouchbase/src/README.md +2 -0
  27. data/ext/libcouchbase/src/auth-priv.h +0 -1
  28. data/ext/libcouchbase/src/auth.cc +4 -10
  29. data/ext/libcouchbase/src/bootstrap.c +269 -0
  30. data/ext/libcouchbase/src/bootstrap.h +39 -50
  31. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +117 -84
  32. data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
  33. data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
  34. data/ext/libcouchbase/src/bucketconfig/bc_http.h +25 -50
  35. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
  36. data/ext/libcouchbase/src/bucketconfig/clconfig.h +386 -407
  37. data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
  38. data/ext/libcouchbase/src/cbft.cc +27 -22
  39. data/ext/libcouchbase/src/cntl.cc +19 -30
  40. data/ext/libcouchbase/src/connspec.cc +1 -48
  41. data/ext/libcouchbase/src/connspec.h +0 -27
  42. data/ext/libcouchbase/src/dump.cc +2 -2
  43. data/ext/libcouchbase/src/getconfig.cc +33 -7
  44. data/ext/libcouchbase/src/handler.cc +2 -0
  45. data/ext/libcouchbase/src/hostlist.cc +36 -0
  46. data/ext/libcouchbase/src/hostlist.h +62 -41
  47. data/ext/libcouchbase/src/http/http-priv.h +112 -125
  48. data/ext/libcouchbase/src/http/http.cc +30 -15
  49. data/ext/libcouchbase/src/http/http.h +34 -1
  50. data/ext/libcouchbase/src/http/http_io.cc +26 -22
  51. data/ext/libcouchbase/src/instance.cc +23 -94
  52. data/ext/libcouchbase/src/internal.h +26 -52
  53. data/ext/libcouchbase/src/jsparse/parser.cc +202 -146
  54. data/ext/libcouchbase/src/jsparse/parser.h +98 -91
  55. data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
  56. data/ext/libcouchbase/src/lcbht/lcbht.h +163 -174
  57. data/ext/libcouchbase/src/lcbio/connect.c +557 -0
  58. data/ext/libcouchbase/src/lcbio/connect.h +2 -9
  59. data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
  60. data/ext/libcouchbase/src/lcbio/iotable.h +16 -61
  61. data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
  62. data/ext/libcouchbase/src/lcbio/manager.c +2 -2
  63. data/ext/libcouchbase/src/mc/mcreq.h +2 -9
  64. data/ext/libcouchbase/src/mcserver/mcserver.cc +34 -143
  65. data/ext/libcouchbase/src/mcserver/mcserver.h +12 -7
  66. data/ext/libcouchbase/src/mcserver/negotiate.cc +38 -132
  67. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
  68. data/ext/libcouchbase/src/n1ql/n1ql.cc +32 -56
  69. data/ext/libcouchbase/src/newconfig.cc +6 -6
  70. data/ext/libcouchbase/src/nodeinfo.cc +2 -2
  71. data/ext/libcouchbase/src/operations/{cbflush.cc → cbflush.c} +15 -7
  72. data/ext/libcouchbase/src/operations/{counter.cc → counter.c} +0 -0
  73. data/ext/libcouchbase/src/operations/durability.cc +26 -6
  74. data/ext/libcouchbase/src/operations/durability_internal.h +3 -6
  75. data/ext/libcouchbase/src/operations/{get.cc → get.c} +26 -24
  76. data/ext/libcouchbase/src/operations/{observe.cc → observe.c} +93 -68
  77. data/ext/libcouchbase/src/operations/{pktfwd.cc → pktfwd.c} +0 -0
  78. data/ext/libcouchbase/src/operations/{remove.cc → remove.c} +0 -0
  79. data/ext/libcouchbase/src/operations/stats.cc +8 -3
  80. data/ext/libcouchbase/src/operations/{store.cc → store.c} +32 -27
  81. data/ext/libcouchbase/src/operations/subdoc.cc +18 -38
  82. data/ext/libcouchbase/src/operations/{touch.cc → touch.c} +0 -0
  83. data/ext/libcouchbase/src/packetutils.c +37 -0
  84. data/ext/libcouchbase/src/packetutils.h +2 -2
  85. data/ext/libcouchbase/src/probes.d +1 -1
  86. data/ext/libcouchbase/src/{retrychk.cc → retrychk.c} +3 -2
  87. data/ext/libcouchbase/src/retryq.cc +4 -4
  88. data/ext/libcouchbase/src/settings.c +0 -3
  89. data/ext/libcouchbase/src/settings.h +0 -5
  90. data/ext/libcouchbase/src/simplestring.c +211 -0
  91. data/ext/libcouchbase/src/simplestring.h +228 -0
  92. data/ext/libcouchbase/src/ssl/ssl_c.c +0 -1
  93. data/ext/libcouchbase/src/ssl/ssl_common.c +0 -2
  94. data/ext/libcouchbase/src/ssl/ssl_e.c +1 -0
  95. data/ext/libcouchbase/src/ssobuf.h +82 -0
  96. data/ext/libcouchbase/src/trace.h +4 -4
  97. data/ext/libcouchbase/src/vbucket/vbucket.c +1 -0
  98. data/ext/libcouchbase/src/views/{docreq.cc → docreq.c} +54 -48
  99. data/ext/libcouchbase/src/views/docreq.h +30 -24
  100. data/ext/libcouchbase/src/views/viewreq.c +358 -0
  101. data/ext/libcouchbase/src/views/viewreq.h +13 -43
  102. data/ext/libcouchbase/tests/basic/t_connstr.cc +50 -89
  103. data/ext/libcouchbase/tests/basic/t_host.cc +75 -67
  104. data/ext/libcouchbase/tests/basic/t_jsparse.cc +78 -27
  105. data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
  106. data/ext/libcouchbase/tests/htparse/t_basic.cc +78 -58
  107. data/ext/libcouchbase/tests/iotests/mock-environment.h +1 -2
  108. data/ext/libcouchbase/tests/iotests/t_confmon.cc +114 -96
  109. data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
  110. data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
  111. data/lib/libcouchbase/ext/tasks.rb +6 -2
  112. data/lib/libcouchbase/query_view.rb +1 -1
  113. data/lib/libcouchbase/results_fiber.rb +6 -6
  114. data/lib/libcouchbase/version.rb +1 -1
  115. metadata +26 -26
  116. data/ext/libcouchbase/src/bootstrap.cc +0 -216
  117. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +0 -281
  118. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +0 -528
  119. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +0 -115
  120. data/ext/libcouchbase/src/bucketconfig/confmon.cc +0 -378
  121. data/ext/libcouchbase/src/dns-srv.cc +0 -142
  122. data/ext/libcouchbase/src/errmap.cc +0 -107
  123. data/ext/libcouchbase/src/errmap.h +0 -113
  124. data/ext/libcouchbase/src/lcbht/lcbht.cc +0 -177
  125. data/ext/libcouchbase/src/lcbio/connect.cc +0 -562
  126. data/ext/libcouchbase/src/lcbio/timer-cxx.h +0 -87
  127. data/ext/libcouchbase/src/mctx-helper.h +0 -51
  128. data/ext/libcouchbase/src/views/viewreq.cc +0 -318
  129. 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
- delete parser;
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
- const lcb::htparse::Response& resp = parser->get_cur_response();
115
- htstatus_ok = resp.status >= 200 && resp.status < 299;
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->bootstrap(BS_REFRESH_ALWAYS);
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->bootstrap(BS_REFRESH_ALWAYS);
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 lcb::htparse::Response& htres = parser->get_cur_response();
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
- res->htstatus = htres.status;
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->reset();
257
+ lcbht_reset(parser);
255
258
  } else {
256
- parser = new lcb::htparse::Parser(instance->settings);
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
- std::string ua("libcouchbase/" LCB_VERSION_STRING);
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
- #include "http-priv.h"
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 lcb::htparse::Response& resp)
33
+ Request::assign_response_headers(const lcbht_RESPONSE *resp)
34
34
  {
35
- response_headers.assign(resp.headers.begin(), resp.headers.end());
35
+ response_headers.clear();
36
36
  response_headers_clist.clear();
37
37
 
38
- std::vector<lcb::htparse::MimeHeader>::const_iterator ii;
39
- for (ii = response_headers.begin(); ii != response_headers.end(); ++ii) {
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
- using lcb::htparse::Parser;
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.state;
61
+ oldstate = res->state;
57
62
 
58
- parse_state = parser->parse_ex(buf, nbuf, &nused, &nbody, &rbody);
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 & Parser::S_HEADER) {
67
+ if (diff & LCBHT_S_HEADER) {
63
68
  assign_response_headers(res);
64
- if (res.status >= 300 && res.status <= 400) {
65
- const char *redir = res.get_header_value("Location");
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 Parser::S_DONE;
73
+ return LCBHT_S_DONE;
69
74
  }
70
75
  }
71
76
  }
72
77
 
73
- if (parse_state & Parser::S_ERROR) {
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.body.append(rbody, nbody);
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 & Parser::S_DONE) == 0 && is_ongoing() && nbuf);
100
+ } while ((parse_state & LCBHT_S_DONE) == 0 && is_ongoing() && nbuf);
96
101
 
97
- if ( (parse_state & Parser::S_DONE) && is_ongoing()) {
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.body.c_str();
104
- nbuf = res.body.size();
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 & lcb::htparse::Parser::S_ERROR) ||
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->bootstrap(lcb::BS_REFRESH_THROTTLE);
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->can_keepalive();
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
- using namespace lcb::clconfig;
162
- Provider *http, *cccp, *mcraw;
163
- http = obj->confmon->get_provider(CLCONFIG_HTTP);
164
- cccp = obj->confmon->get_provider(CLCONFIG_CCCP);
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->set_active(CLCONFIG_MCRAW, true);
169
- mcraw->configure_nodes(*obj->mc_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
- Provider *prov = obj->confmon->get_provider(CLCONFIG_FILE);
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->enable();
208
- http->configure_nodes(*obj->ht_nodes);
167
+ lcb_clconfig_http_enable(http);
168
+ lcb_clconfig_http_set_nodes(http, obj->ht_nodes);
209
169
  } else {
210
- obj->confmon->set_active(CLCONFIG_HTTP, false);
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->enable(obj);
215
- cccp->configure_nodes(*obj->mc_nodes);
174
+ lcb_clconfig_cccp_enable(cccp, obj);
175
+ lcb_clconfig_cccp_set_nodes(cccp, obj->mc_nodes);
216
176
  } else {
217
- obj->confmon->set_active(CLCONFIG_CCCP, false);
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 = new clconfig::Confmon(settings, obj->iotable);
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
- if ((err = init_providers(obj, spec)) != LCB_SUCCESS) {
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
- if (instance->cur_configinfo) {
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
- DESTROY(delete, bs_state);
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
- http::Request *htreq = reinterpret_cast<http::Request*>(*it);
526
- htreq->block_callback();
527
- htreq->finish(LCB_ERROR);
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(delete, confmon);
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->bootstrap(BS_REFRESH_INITIAL);
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
  {