libcouchbase 0.0.7 → 0.0.8

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 (133) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libcouchbase/.gitignore +2 -0
  3. data/ext/libcouchbase/CMakeLists.txt +5 -7
  4. data/ext/libcouchbase/README.markdown +2 -2
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +49 -0
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
  7. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  10. data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
  11. data/ext/libcouchbase/cmake/defs.mk.in +0 -2
  12. data/ext/libcouchbase/cmake/source_files.cmake +34 -14
  13. data/ext/libcouchbase/configure.pl +1 -1
  14. data/ext/libcouchbase/contrib/genhash/genhash.h +6 -0
  15. data/ext/libcouchbase/include/libcouchbase/auth.h +10 -0
  16. data/ext/libcouchbase/include/libcouchbase/couchbase.h +10 -0
  17. data/ext/libcouchbase/include/libcouchbase/error.h +7 -0
  18. data/ext/libcouchbase/include/libcouchbase/n1ql.h +13 -1
  19. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
  20. data/ext/libcouchbase/include/libcouchbase/subdoc.h +9 -0
  21. data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
  22. data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
  23. data/ext/libcouchbase/include/memcached/protocol_binary.h +21 -1132
  24. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  25. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
  26. data/ext/libcouchbase/src/README.md +0 -2
  27. data/ext/libcouchbase/src/auth-priv.h +1 -0
  28. data/ext/libcouchbase/src/auth.cc +10 -0
  29. data/ext/libcouchbase/src/bootstrap.cc +216 -0
  30. data/ext/libcouchbase/src/bootstrap.h +50 -39
  31. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +455 -0
  32. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
  33. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +528 -0
  34. data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
  35. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +115 -0
  36. data/ext/libcouchbase/src/bucketconfig/clconfig.h +407 -386
  37. data/ext/libcouchbase/src/bucketconfig/confmon.cc +378 -0
  38. data/ext/libcouchbase/src/cbft.cc +22 -27
  39. data/ext/libcouchbase/src/cntl.cc +24 -24
  40. data/ext/libcouchbase/src/connspec.cc +30 -1
  41. data/ext/libcouchbase/src/connspec.h +17 -0
  42. data/ext/libcouchbase/src/dns-srv.cc +143 -0
  43. data/ext/libcouchbase/src/{dump.c → dump.cc} +8 -11
  44. data/ext/libcouchbase/src/getconfig.cc +73 -0
  45. data/ext/libcouchbase/src/handler.cc +84 -85
  46. data/ext/libcouchbase/src/hostlist.cc +0 -1
  47. data/ext/libcouchbase/src/hostlist.h +6 -1
  48. data/ext/libcouchbase/src/http/http-priv.h +125 -112
  49. data/ext/libcouchbase/src/http/http.cc +9 -29
  50. data/ext/libcouchbase/src/http/http.h +1 -34
  51. data/ext/libcouchbase/src/http/http_io.cc +22 -26
  52. data/ext/libcouchbase/src/instance.cc +102 -28
  53. data/ext/libcouchbase/src/internal.h +47 -29
  54. data/ext/libcouchbase/src/jsparse/parser.cc +146 -202
  55. data/ext/libcouchbase/src/jsparse/parser.h +91 -98
  56. data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
  57. data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
  58. data/ext/libcouchbase/src/lcbio/connect.cc +562 -0
  59. data/ext/libcouchbase/src/lcbio/connect.h +9 -2
  60. data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
  61. data/ext/libcouchbase/src/lcbio/iotable.h +61 -16
  62. data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
  63. data/ext/libcouchbase/src/lcbio/manager.c +2 -2
  64. data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
  65. data/ext/libcouchbase/src/mc/mcreq.h +9 -2
  66. data/ext/libcouchbase/src/mcserver/mcserver.cc +723 -0
  67. data/ext/libcouchbase/src/mcserver/mcserver.h +160 -70
  68. data/ext/libcouchbase/src/mcserver/negotiate.cc +118 -152
  69. data/ext/libcouchbase/src/mcserver/negotiate.h +85 -74
  70. data/ext/libcouchbase/src/mctx-helper.h +51 -0
  71. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
  72. data/ext/libcouchbase/src/n1ql/n1ql.cc +56 -32
  73. data/ext/libcouchbase/src/{newconfig.c → newconfig.cc} +42 -70
  74. data/ext/libcouchbase/src/nodeinfo.cc +4 -8
  75. data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
  76. data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
  77. data/ext/libcouchbase/src/operations/{durability-cas.c → durability-cas.cc} +92 -76
  78. data/ext/libcouchbase/src/operations/{durability-seqno.c → durability-seqno.cc} +55 -49
  79. data/ext/libcouchbase/src/operations/durability.cc +643 -0
  80. data/ext/libcouchbase/src/operations/durability_internal.h +212 -124
  81. data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
  82. data/ext/libcouchbase/src/operations/{observe-seqno.c → observe-seqno.cc} +5 -8
  83. data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +69 -94
  84. data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
  85. data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
  86. data/ext/libcouchbase/src/operations/{stats.c → stats.cc} +66 -78
  87. data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
  88. data/ext/libcouchbase/src/operations/subdoc.cc +38 -18
  89. data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
  90. data/ext/libcouchbase/src/packetutils.h +200 -137
  91. data/ext/libcouchbase/src/probes.d +1 -1
  92. data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +3 -4
  93. data/ext/libcouchbase/src/retryq.cc +394 -0
  94. data/ext/libcouchbase/src/retryq.h +116 -104
  95. data/ext/libcouchbase/src/settings.h +2 -1
  96. data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
  97. data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
  98. data/ext/libcouchbase/src/trace.h +8 -8
  99. data/ext/libcouchbase/src/vbucket/vbucket.c +0 -1
  100. data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
  101. data/ext/libcouchbase/src/views/docreq.h +24 -30
  102. data/ext/libcouchbase/src/views/viewreq.cc +318 -0
  103. data/ext/libcouchbase/src/views/viewreq.h +43 -13
  104. data/ext/libcouchbase/src/{wait.c → wait.cc} +12 -17
  105. data/ext/libcouchbase/tests/basic/t_connstr.cc +89 -50
  106. data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -78
  107. data/ext/libcouchbase/tests/basic/t_packet.cc +35 -42
  108. data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
  109. data/ext/libcouchbase/tests/iotests/t_confmon.cc +94 -111
  110. data/ext/libcouchbase/tests/iotests/t_sched.cc +1 -2
  111. data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
  112. data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
  113. data/lib/libcouchbase/version.rb +1 -1
  114. metadata +36 -39
  115. data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
  116. data/ext/libcouchbase/src/bootstrap.c +0 -269
  117. data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +0 -495
  118. data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
  119. data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
  120. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
  121. data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
  122. data/ext/libcouchbase/src/getconfig.c +0 -100
  123. data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
  124. data/ext/libcouchbase/src/lcbio/connect.c +0 -557
  125. data/ext/libcouchbase/src/mcserver/mcserver.c +0 -784
  126. data/ext/libcouchbase/src/operations/durability.c +0 -668
  127. data/ext/libcouchbase/src/packetutils.c +0 -60
  128. data/ext/libcouchbase/src/retryq.c +0 -424
  129. data/ext/libcouchbase/src/simplestring.c +0 -211
  130. data/ext/libcouchbase/src/simplestring.h +0 -228
  131. data/ext/libcouchbase/src/ssobuf.h +0 -82
  132. data/ext/libcouchbase/src/views/viewreq.c +0 -358
  133. data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
@@ -1,358 +0,0 @@
1
- #include "viewreq.h"
2
- #include "sllist-inl.h"
3
- #include "http/http.h"
4
- #include "internal.h"
5
-
6
- #define MAX_GET_URI_LENGTH 2048
7
-
8
- static void chunk_callback(lcb_t, int, const lcb_RESPBASE*);
9
- static void row_callback(lcbjsp_PARSER*, const lcbjsp_ROW*);
10
- static void invoke_row(lcbview_REQUEST *req, lcb_RESPVIEWQUERY *resp);
11
- static void unref_request(lcbview_REQUEST *req);
12
-
13
- #define IOV2PTRLEN(iov, ptr, len) do { \
14
- ptr = (iov)->iov_base; \
15
- len = (iov)->iov_len; \
16
- } while (0);
17
-
18
- /* Whether the request (from the user side) is still ongoing */
19
- #define CAN_CONTINUE(req) ((req)->callback != NULL)
20
- #define LOGARGS(instance, lvl) instance->settings, "views", LCB_LOG_##lvl, __FILE__, __LINE__
21
-
22
- static void
23
- invoke_last(lcbview_REQUEST *req, lcb_error_t err)
24
- {
25
- lcb_RESPVIEWQUERY resp = { 0 };
26
- if (req->callback == NULL) {
27
- return;
28
- }
29
- if (req->docq && lcbdocq_has_pending(req->docq)) {
30
- return;
31
- }
32
-
33
- resp.rc = err;
34
- resp.htresp = req->cur_htresp;
35
- resp.cookie = (void *)req->cookie;
36
- resp.rflags = LCB_RESP_F_FINAL;
37
- if (req->parser && req->parser->meta_complete) {
38
- resp.value = req->parser->meta_buf.base;
39
- resp.nvalue = req->parser->meta_buf.nused;
40
- } else {
41
- resp.rflags |= LCB_RESP_F_CLIENTGEN;
42
- }
43
- req->callback(req->instance, LCB_CALLBACK_VIEWQUERY, &resp);
44
- lcb_view_cancel(req->instance, req);
45
- }
46
-
47
- static void
48
- invoke_row(lcbview_REQUEST *req, lcb_RESPVIEWQUERY *resp)
49
- {
50
- if (req->callback == NULL) {
51
- return;
52
- }
53
- resp->htresp = req->cur_htresp;
54
- resp->cookie = (void *)req->cookie;
55
- req->callback(req->instance, LCB_CALLBACK_VIEWQUERY, resp);
56
- }
57
-
58
- static void
59
- chunk_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
60
- {
61
- const lcb_RESPHTTP *rh = (const lcb_RESPHTTP *)rb;
62
- lcbview_REQUEST *req = rh->cookie;
63
-
64
- (void)cbtype;
65
- req->cur_htresp = rh;
66
-
67
- if (rh->rc != LCB_SUCCESS || rh->htstatus != 200 || (rh->rflags & LCB_RESP_F_FINAL)) {
68
- if (req->lasterr == LCB_SUCCESS && rh->htstatus != 200) {
69
- if (rh->rc != LCB_SUCCESS) {
70
- req->lasterr = rh->rc;
71
- } else {
72
- lcb_log(LOGARGS(instance, DEBUG), "Got not ok http status %d", rh->htstatus);
73
- req->lasterr = LCB_HTTP_ERROR;
74
- }
75
- }
76
- req->refcount++;
77
- invoke_last(req, req->lasterr);
78
- if (rh->rflags & LCB_RESP_F_FINAL) {
79
- req->htreq = NULL;
80
- unref_request(req);
81
- }
82
- req->cur_htresp = NULL;
83
- unref_request(req);
84
- return;
85
- }
86
-
87
- if (!CAN_CONTINUE(req)) {
88
- return;
89
- }
90
-
91
- req->refcount++;
92
- lcbjsp_feed(req->parser, rh->body, rh->nbody);
93
- req->cur_htresp = NULL;
94
- unref_request(req);
95
- (void)instance;
96
- }
97
-
98
- static void
99
- do_copy_iov(char *dstbuf, lcb_IOV *dstiov, const lcb_IOV *srciov, size_t *off)
100
- {
101
- dstiov->iov_len = srciov->iov_len;
102
- dstiov->iov_base = dstbuf + *off;
103
- *off += dstiov->iov_len;
104
- memcpy(dstiov->iov_base, srciov->iov_base, srciov->iov_len);
105
- }
106
-
107
- static lcbview_DOCREQ *
108
- mk_docreq(const lcbjsp_ROW *datum)
109
- {
110
- size_t extra_alloc = 0;
111
- size_t cur_offset = 0;
112
- lcbview_DOCREQ *dreq;
113
-
114
- extra_alloc =
115
- datum->key.iov_len + datum->value.iov_len +
116
- datum->geo.iov_len + datum->docid.iov_len;
117
-
118
- dreq = calloc(1, sizeof(*dreq) + extra_alloc);
119
- do_copy_iov(dreq->rowbuf, &dreq->key, &datum->key, &cur_offset);
120
- do_copy_iov(dreq->rowbuf, &dreq->value, &datum->value, &cur_offset);
121
- do_copy_iov(dreq->rowbuf, &dreq->base.docid, &datum->docid, &cur_offset);
122
- do_copy_iov(dreq->rowbuf, &dreq->geo, &datum->geo, &cur_offset);
123
- return dreq;
124
- }
125
-
126
- static void
127
- row_callback(lcbjsp_PARSER *parser, const lcbjsp_ROW *datum)
128
- {
129
- lcbview_REQUEST *req = parser->data;
130
- if (datum->type == LCBJSP_TYPE_ROW) {
131
- if (!req->no_parse_rows) {
132
- lcbjsp_parse_viewrow(req->parser, (lcbjsp_ROW*)datum);
133
- }
134
-
135
- if (req->include_docs && datum->docid.iov_len && req->callback) {
136
- lcbview_DOCREQ *dreq = mk_docreq(datum);
137
- dreq->parent = req;
138
- lcbdocq_add(req->docq, &dreq->base);
139
- req->refcount++;
140
-
141
- } else {
142
- lcb_RESPVIEWQUERY resp = { 0 };
143
- if (req->no_parse_rows) {
144
- IOV2PTRLEN(&datum->row, resp.value, resp.nvalue);
145
- } else {
146
- IOV2PTRLEN(&datum->key, resp.key, resp.nkey);
147
- IOV2PTRLEN(&datum->docid, resp.docid, resp.ndocid);
148
- IOV2PTRLEN(&datum->value, resp.value, resp.nvalue);
149
- IOV2PTRLEN(&datum->geo, resp.geometry, resp.ngeometry);
150
- }
151
- resp.htresp = req->cur_htresp;
152
- invoke_row(req, &resp);
153
- }
154
- } else if (datum->type == LCBJSP_TYPE_ERROR) {
155
- invoke_last(req, LCB_PROTOCOL_ERROR);
156
- } else if (datum->type == LCBJSP_TYPE_COMPLETE) {
157
- /* nothing */
158
- }
159
- }
160
-
161
- static void
162
- cb_doc_ready(lcb_DOCQUEUE *q, lcb_DOCQREQ *req_base)
163
- {
164
- lcb_RESPVIEWQUERY resp = { 0 };
165
- lcbview_DOCREQ *dreq = (lcbview_DOCREQ*)req_base;
166
- resp.docresp = &dreq->base.docresp;
167
- IOV2PTRLEN(&dreq->key, resp.key, resp.nkey);
168
- IOV2PTRLEN(&dreq->value, resp.value, resp.nvalue);
169
- IOV2PTRLEN(&dreq->base.docid, resp.docid, resp.ndocid);
170
- IOV2PTRLEN(&dreq->geo, resp.geometry, resp.ngeometry);
171
-
172
- if (q->parent) {
173
- invoke_row(q->parent, &resp);
174
- }
175
-
176
- free(dreq);
177
-
178
- if (q->parent) {
179
- unref_request(q->parent);
180
- }
181
- }
182
-
183
- static void
184
- cb_docq_throttle(lcb_DOCQUEUE *q, int enabled)
185
- {
186
- lcbview_REQUEST *req = q->parent;
187
- if (req == NULL || req->htreq == NULL) {
188
- return;
189
- }
190
- if (enabled) {
191
- lcb_htreq_pause(req->htreq);
192
- } else {
193
- lcb_htreq_resume(req->htreq);
194
- }
195
- }
196
-
197
- static void
198
- destroy_request(lcbview_REQUEST *req)
199
- {
200
- invoke_last(req, req->lasterr);
201
-
202
- if (req->parser != NULL) {
203
- lcbjsp_free(req->parser);
204
- }
205
- if (req->htreq != NULL) {
206
- lcb_cancel_http_request(req->instance, req->htreq);
207
- }
208
- if (req->docq != NULL) {
209
- req->docq->parent = NULL;
210
- lcbdocq_unref(req->docq);
211
- }
212
- free(req);
213
- }
214
-
215
- static void
216
- unref_request(lcbview_REQUEST *req)
217
- {
218
- if (!--req->refcount) {
219
- destroy_request(req);
220
- }
221
- }
222
-
223
- LIBCOUCHBASE_API
224
- lcb_error_t
225
- lcb_view_query(lcb_t instance, const void *cookie, const lcb_CMDVIEWQUERY *cmd)
226
- {
227
- lcb_string path;
228
- lcb_CMDHTTP htcmd = { 0 };
229
- lcb_error_t rc;
230
- lcbview_REQUEST *req = NULL;
231
- int include_docs = 0;
232
- int no_parse_rows = 0;
233
- const char *vpstr = NULL;
234
-
235
- if (cmd->nddoc == 0 || cmd->nview == 0 || cmd->callback == NULL) {
236
- return LCB_EINVAL;
237
- }
238
-
239
- htcmd.method = LCB_HTTP_METHOD_GET;
240
- htcmd.type = LCB_HTTP_TYPE_VIEW;
241
- htcmd.cmdflags = LCB_CMDHTTP_F_STREAM;
242
-
243
- include_docs = cmd->cmdflags & LCB_CMDVIEWQUERY_F_INCLUDE_DOCS;
244
- no_parse_rows = cmd->cmdflags & LCB_CMDVIEWQUERY_F_NOROWPARSE;
245
-
246
- if (include_docs && no_parse_rows) {
247
- return LCB_OPTIONS_CONFLICT;
248
- }
249
-
250
- lcb_string_init(&path);
251
- if (cmd->cmdflags & LCB_CMDVIEWQUERY_F_SPATIAL) {
252
- vpstr = "/_spatial/";
253
- } else {
254
- vpstr = "/_view/";
255
- }
256
-
257
- if (lcb_string_appendv(&path,
258
- "_design/", (size_t)-1, cmd->ddoc, cmd->nddoc,
259
- vpstr, (size_t)-1, cmd->view, cmd->nview, NULL) != 0) {
260
-
261
- lcb_string_release(&path);
262
- return LCB_CLIENT_ENOMEM;
263
- }
264
-
265
- if (cmd->optstr) {
266
- if (cmd->noptstr > MAX_GET_URI_LENGTH) {
267
- return LCB_E2BIG;
268
- } else {
269
- if (lcb_string_appendv(&path,
270
- "?", (size_t)-1, cmd->optstr, cmd->noptstr, NULL) != 0) {
271
-
272
- lcb_string_release(&path);
273
- return LCB_CLIENT_ENOMEM;
274
- }
275
- }
276
- }
277
-
278
- if (cmd->npostdata) {
279
- htcmd.method = LCB_HTTP_METHOD_POST;
280
- htcmd.body = cmd->postdata;
281
- htcmd.nbody = cmd->npostdata;
282
- htcmd.content_type = "application/json";
283
- }
284
-
285
- if ( (req = calloc(1, sizeof(*req))) == NULL ||
286
- (req->parser = lcbjsp_create(LCBJSP_MODE_VIEWS)) == NULL) {
287
- free(req);
288
- lcb_string_release(&path);
289
- return LCB_CLIENT_ENOMEM;
290
- }
291
-
292
- req->instance = instance;
293
- req->cookie = cookie;
294
- req->include_docs = include_docs;
295
- req->no_parse_rows = no_parse_rows;
296
- req->callback = cmd->callback;
297
- req->parser->callback = row_callback;
298
- req->parser->data = req;
299
-
300
- LCB_CMD_SET_KEY(&htcmd, path.base, path.nused);
301
- htcmd.reqhandle = &req->htreq;
302
-
303
- rc = lcb_http3(instance, req, &htcmd);
304
- lcb_string_release(&path);
305
-
306
- if (rc == LCB_SUCCESS) {
307
- lcb_htreq_setcb(req->htreq, chunk_callback);
308
- req->refcount++;
309
- if (cmd->handle) {
310
- *cmd->handle = req;
311
- }
312
- if (include_docs) {
313
- req->docq = lcbdocq_create(instance);
314
- req->docq->parent = req;
315
- req->docq->cb_ready = cb_doc_ready;
316
- req->docq->cb_throttle = cb_docq_throttle;
317
- if (cmd->docs_concurrent_max) {
318
- req->docq->max_pending_response = cmd->docs_concurrent_max;
319
- }
320
- }
321
- lcb_aspend_add(&instance->pendops, LCB_PENDTYPE_COUNTER, NULL);
322
- } else {
323
- req->callback = NULL;
324
- destroy_request(req);
325
- }
326
- return rc;
327
- }
328
-
329
- LIBCOUCHBASE_API
330
- void
331
- lcb_view_query_initcmd(lcb_CMDVIEWQUERY *vq,
332
- const char *design, const char *view, const char *options,
333
- lcb_VIEWQUERYCALLBACK callback)
334
- {
335
- vq->view = view;
336
- vq->nview = strlen(view);
337
- vq->ddoc = design;
338
- vq->nddoc = strlen(design);
339
- if (options != NULL) {
340
- vq->optstr = options;
341
- vq->noptstr = strlen(options);
342
- }
343
- vq->callback = callback;
344
- }
345
-
346
- LIBCOUCHBASE_API
347
- void
348
- lcb_view_cancel(lcb_t instance, lcb_VIEWHANDLE handle)
349
- {
350
- if (handle->callback) {
351
- handle->callback = NULL;
352
- lcb_aspend_del(&instance->pendops, LCB_PENDTYPE_COUNTER, NULL);
353
- if (handle->docq) {
354
- lcbdocq_cancel(handle->docq);
355
- }
356
- }
357
- (void)instance;
358
- }
@@ -1,112 +0,0 @@
1
- /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright 2012 Couchbase, Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- #include "config.h"
19
- #include <gtest/gtest.h>
20
- #include <libcouchbase/couchbase.h>
21
- #include "simplestring.h"
22
-
23
- class String : public ::testing::Test
24
- {
25
- };
26
-
27
- TEST_F(String, testBasic)
28
- {
29
- int rv;
30
- lcb_string str;
31
- rv = lcb_string_init(&str);
32
- ASSERT_EQ(0, rv);
33
- ASSERT_EQ(NULL, str.base);
34
- ASSERT_EQ(0, str.nalloc);
35
- ASSERT_EQ(0, str.nused);
36
-
37
- rv = lcb_string_append(&str, "Hello", 5);
38
- ASSERT_EQ(0, rv);
39
-
40
- rv = lcb_string_append(&str, "blah", -1);
41
- ASSERT_EQ(-1, rv);
42
-
43
- rv = lcb_string_appendz(&str, "blah");
44
- ASSERT_EQ(0, rv);
45
-
46
- ASSERT_EQ(0, strcmp("Helloblah", str.base));
47
-
48
- lcb_string_erase_beginning(&str, 5);
49
- ASSERT_EQ(0, strcmp("blah", str.base));
50
-
51
- lcb_string_erase_end(&str, 4);
52
- ASSERT_EQ(0, strcmp("", str.base));
53
-
54
- lcb_string_clear(&str);
55
- ASSERT_TRUE(str.base != NULL);
56
-
57
- lcb_string_release(&str);
58
- ASSERT_EQ(NULL, str.base);
59
- }
60
-
61
- TEST_F(String, testAdvance)
62
- {
63
- int rv;
64
- lcb_string str;
65
- rv = lcb_string_init(&str);
66
- ASSERT_EQ(0, rv);
67
-
68
- rv = lcb_string_reserve(&str, 30);
69
- ASSERT_EQ(0, rv);
70
- ASSERT_TRUE(str.nalloc >= 30);
71
- ASSERT_EQ(0, str.nused);
72
-
73
- memcpy(lcb_string_tail(&str), "Hello", 5);
74
- lcb_string_added(&str, 5);
75
- ASSERT_EQ(5, str.nused);
76
- ASSERT_EQ(0, strcmp(str.base, "Hello"));
77
- lcb_string_release(&str);
78
- }
79
-
80
-
81
- TEST_F(String, testRbCopy)
82
- {
83
- int rv;
84
- ringbuffer_t rb;
85
- rv = ringbuffer_initialize(&rb, 10);
86
- ASSERT_TRUE(rv != 0);
87
-
88
- lcb_string str;
89
- rv = lcb_string_init(&str);
90
- ASSERT_EQ(0, rv);
91
-
92
- const char *txt = "The quick brown fox jumped over the lazy dog";
93
- const int ntxt = strlen(txt);
94
- ringbuffer_ensure_capacity(&rb, ntxt);
95
-
96
- ASSERT_EQ(ntxt, ringbuffer_write(&rb, txt, ntxt));
97
- ASSERT_EQ(ntxt, rb.nbytes);
98
-
99
- rv = lcb_string_rbappend(&str, &rb, 0);
100
- ASSERT_EQ(0, rv);
101
-
102
- ASSERT_EQ(0, strcmp(txt, str.base));
103
- ASSERT_EQ(ntxt, str.nused);
104
-
105
- lcb_string_clear(&str);
106
- lcb_string_rbappend(&str, &rb, 1);
107
- ASSERT_EQ(0, rb.nbytes);
108
- ASSERT_EQ(0, strcmp(txt, str.base));
109
-
110
- ringbuffer_destruct(&rb);
111
- lcb_string_release(&str);
112
- }