File: | home/avsej/code/libcouchbase/src/handler.cc |
Warning: | line 221, column 22 The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage |
1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | |||
2 | /* | |||
3 | * Copyright 2014 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 "internal.h" | |||
19 | #include "packetutils.h" | |||
20 | #include "mc/mcreq.h" | |||
21 | #include "mc/compress.h" | |||
22 | #include "trace.h" | |||
23 | ||||
24 | #define LOGARGS(obj, lvl)(obj)->settings, "handler", LCB_LOG_lvl, "/home/avsej/code/libcouchbase/src/handler.cc" , 24 (obj)->settings, "handler", LCB_LOG_##lvl, __FILE__"/home/avsej/code/libcouchbase/src/handler.cc", __LINE__24 | |||
25 | ||||
26 | using lcb::MemcachedResponse; | |||
27 | ||||
28 | template <typename T> | |||
29 | class ResponsePack { | |||
30 | public: | |||
31 | T resp; | |||
32 | lcb_MUTATION_TOKEN mt; | |||
33 | const char *value; | |||
34 | lcb_SIZE nvalue; | |||
35 | char *err_ref; | |||
36 | char *err_ctx; | |||
37 | ||||
38 | ~ResponsePack() { | |||
39 | free(err_ref); | |||
40 | free(err_ctx); | |||
41 | } | |||
42 | ||||
43 | static const lcb_MUTATION_TOKEN* | |||
44 | get_mt(const lcb_RESPBASE *rb) { | |||
45 | const ResponsePack *rp = reinterpret_cast<const ResponsePack*>(rb); | |||
46 | return &rp->mt; | |||
47 | } | |||
48 | ||||
49 | static const char* | |||
50 | get_err_ctx(const lcb_RESPBASE *rb) { | |||
51 | const ResponsePack *rp = reinterpret_cast<const ResponsePack*>(rb); | |||
52 | if (rp->resp.rflags & LCB_RESP_F_ERRINFO) { | |||
53 | if (rp->err_ctx) { | |||
54 | return rp->err_ctx; | |||
55 | } else { | |||
56 | parse_enhanced_error(rp); | |||
57 | return rp->err_ctx; | |||
58 | } | |||
59 | } | |||
60 | return NULL__null; | |||
61 | } | |||
62 | ||||
63 | static const char* | |||
64 | get_err_ref(const lcb_RESPBASE *rb) { | |||
65 | const ResponsePack *rp = reinterpret_cast<const ResponsePack*>(rb); | |||
66 | if (rp->resp.rflags & LCB_RESP_F_ERRINFO) { | |||
67 | if (rp->err_ref) { | |||
68 | return rp->err_ref; | |||
69 | } else { | |||
70 | parse_enhanced_error(rp); | |||
71 | return rp->err_ref; | |||
72 | } | |||
73 | } | |||
74 | return NULL__null; | |||
75 | } | |||
76 | ||||
77 | private: | |||
78 | ||||
79 | static void | |||
80 | parse_enhanced_error(const ResponsePack *rp) { | |||
81 | ResponsePack *mrp = const_cast<ResponsePack *>(rp); | |||
82 | lcb_error_t rc = MemcachedResponse::parse_enhanced_error(mrp->value, mrp->nvalue, &mrp->err_ref, &mrp->err_ctx); | |||
83 | if (rc != LCB_SUCCESS) { | |||
84 | mrp->resp.rflags &= ~LCB_RESP_F_ERRINFO; | |||
85 | } | |||
86 | } | |||
87 | }; | |||
88 | ||||
89 | LIBCOUCHBASE_API__attribute__ ((visibility("default"))) | |||
90 | lcb_error_t | |||
91 | lcb_errmap_default(lcb_t instance, lcb_uint16_t in) | |||
92 | { | |||
93 | switch (in) { | |||
94 | case PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET: | |||
95 | return LCB_ETIMEDOUT; | |||
96 | case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE: | |||
97 | return LCB_AUTH_CONTINUE; | |||
98 | case PROTOCOL_BINARY_RESPONSE_EBUSY: | |||
99 | return LCB_EBUSY; | |||
100 | case PROTOCOL_BINARY_RESPONSE_ETMPFAIL: | |||
101 | return LCB_ETMPFAIL; | |||
102 | ||||
103 | case PROTOCOL_BINARY_RESPONSE_EINTERNAL: | |||
104 | default: | |||
105 | if (instance) { | |||
106 | lcb_log(LOGARGS(instance, ERROR)(instance)->settings, "handler", LCB_LOG_ERROR, "/home/avsej/code/libcouchbase/src/handler.cc" , 106, "Got unhandled memcached error 0x%X", in); | |||
107 | } else { | |||
108 | fprintf(stderrstderr, "COUCHBASE: Unhandled memcached status=0x%x\n", in); | |||
109 | } | |||
110 | return LCB_UNKNOWN_MEMCACHED_ERROR; | |||
111 | } | |||
112 | } | |||
113 | ||||
114 | static lcb_error_t | |||
115 | map_error(lcb_t instance, int in) | |||
116 | { | |||
117 | switch (in) { | |||
118 | case PROTOCOL_BINARY_RESPONSE_SUCCESS: | |||
119 | return LCB_SUCCESS; | |||
120 | case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: | |||
121 | return LCB_KEY_ENOENT; | |||
122 | case PROTOCOL_BINARY_RESPONSE_E2BIG: | |||
123 | return LCB_E2BIG; | |||
124 | case PROTOCOL_BINARY_RESPONSE_ENOMEM: | |||
125 | return LCB_ENOMEM; | |||
126 | case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: | |||
127 | return LCB_KEY_EEXISTS; | |||
128 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_ENOENT: | |||
129 | return LCB_SUBDOC_PATH_ENOENT; | |||
130 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_MISMATCH: | |||
131 | return LCB_SUBDOC_PATH_MISMATCH; | |||
132 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_EINVAL: | |||
133 | return LCB_SUBDOC_PATH_EINVAL; | |||
134 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_E2BIG: | |||
135 | return LCB_SUBDOC_PATH_E2BIG; | |||
136 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_DOC_E2DEEP: | |||
137 | return LCB_SUBDOC_DOC_E2DEEP; | |||
138 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_VALUE_ETOODEEP: | |||
139 | return LCB_SUBDOC_VALUE_E2DEEP; | |||
140 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_VALUE_CANTINSERT: | |||
141 | return LCB_SUBDOC_VALUE_CANTINSERT; | |||
142 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_DOC_NOTJSON: | |||
143 | return LCB_SUBDOC_DOC_NOTJSON; | |||
144 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_NUM_ERANGE: | |||
145 | return LCB_SUBDOC_NUM_ERANGE; | |||
146 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_DELTA_ERANGE: | |||
147 | return LCB_SUBDOC_BAD_DELTA; | |||
148 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_EEXISTS: | |||
149 | return LCB_SUBDOC_PATH_EEXISTS; | |||
150 | case PROTOCOL_BINARY_RESPONSE_SUBDOC_MULTI_PATH_FAILURE: | |||
151 | return LCB_SUBDOC_MULTI_FAILURE; | |||
152 | case PROTOCOL_BINARY_RESPONSE_EINVAL: | |||
153 | return LCB_EINVAL_MCD; | |||
154 | case PROTOCOL_BINARY_RESPONSE_NOT_STORED: | |||
155 | return LCB_NOT_STORED; | |||
156 | case PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL: | |||
157 | return LCB_DELTA_BADVAL; | |||
158 | case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR: | |||
159 | return LCB_AUTH_ERROR; | |||
160 | case PROTOCOL_BINARY_RESPONSE_ERANGE: | |||
161 | return LCB_ERANGE; | |||
162 | case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND: | |||
163 | return LCB_UNKNOWN_COMMAND; | |||
164 | case PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED: | |||
165 | return LCB_NOT_SUPPORTED; | |||
166 | case PROTOCOL_BINARY_RESPONSE_EACCESS: | |||
167 | return LCB_NOT_AUTHORIZED; | |||
168 | default: | |||
169 | if (instance != NULL__null) { | |||
170 | return instance->callbacks.errmap(instance, in); | |||
171 | } else { | |||
172 | return lcb_errmap_default(NULL__null, in); | |||
173 | } | |||
174 | } | |||
175 | } | |||
176 | ||||
177 | static lcb_RESPCALLBACK | |||
178 | find_callback(lcb_t instance, lcb_CALLBACKTYPE type) | |||
179 | { | |||
180 | lcb_RESPCALLBACK cb = instance->callbacks.v3callbacks[type]; | |||
181 | if (!cb) { | |||
182 | cb = lcb_find_callback(instance, type); | |||
183 | } | |||
184 | return cb; | |||
185 | } | |||
186 | ||||
187 | ||||
188 | /** | |||
189 | * This file contains the mapping of various protocol response codes for | |||
190 | * a given command. Each handler receives the following parameters: | |||
191 | * | |||
192 | * @param pipeline the pipeline (or "Server") upon which the request was sent | |||
193 | * (and response was received) | |||
194 | * | |||
195 | * @param request the original request (including associated data). The request | |||
196 | * may be used to determine additional information about it, such as the | |||
197 | * user-defined "Cookie", number of related requests remaining, and more. | |||
198 | * | |||
199 | * @param response the response which was received. This is an opaque | |||
200 | * representation of a memcached response packet | |||
201 | * | |||
202 | * @param immerr in the case of an abnormal failure (i.e. network failure) the | |||
203 | * handler will be invoked with this callback set to a non-success value. The | |||
204 | * 'info' structure will still contain a valid (albeit empty and cryptic) | |||
205 | * header. If the user depends on special data being found in the payload then | |||
206 | * the handler must check that this variable is set to LCB_SUCCESS before | |||
207 | * continuing. Also note that a negative reply may also be present within | |||
208 | * the response itself; however this is not the purpose of this parameter. | |||
209 | * | |||
210 | * @return request status | |||
211 | * The return value should indicate whether outstanding responses remain | |||
212 | * to be received for this request, or if this request is deemed to be | |||
213 | * satisfied. | |||
214 | */ | |||
215 | ||||
216 | template <typename T> | |||
217 | void make_error(lcb_t instance, T* resp, | |||
218 | const MemcachedResponse *response, lcb_error_t imm) { | |||
219 | if (imm) { | |||
220 | resp->rc = imm; | |||
221 | resp->rflags |= LCB_RESP_F_CLIENTGEN; | |||
| ||||
222 | } else if (response->status() == PROTOCOL_BINARY_RESPONSE_SUCCESS) { | |||
223 | resp->rc = LCB_SUCCESS; | |||
224 | } else { | |||
225 | resp->rc = map_error(instance, response->status()); | |||
226 | } | |||
227 | } | |||
228 | ||||
229 | template <typename T> | |||
230 | void handle_error_info(const MemcachedResponse* mc_resp, ResponsePack<T>* rp) | |||
231 | { | |||
232 | if (mc_resp->status() != PROTOCOL_BINARY_RESPONSE_SUCCESS | |||
233 | && mc_resp->datatype() & PROTOCOL_BINARY_DATATYPE_JSON | |||
234 | && mc_resp->vallen() > 0) { | |||
235 | rp->resp.rflags |= LCB_RESP_F_ERRINFO; | |||
236 | rp->value = mc_resp->value(); | |||
237 | rp->nvalue = mc_resp->vallen(); | |||
238 | } | |||
239 | } | |||
240 | ||||
241 | template <typename T> | |||
242 | void init_resp(lcb_t instance, const MemcachedResponse* mc_resp, | |||
243 | const mc_PACKET *req, lcb_error_t immerr, T *resp) { | |||
244 | make_error(instance, resp, mc_resp, immerr); | |||
245 | resp->cas = mc_resp->cas(); | |||
246 | resp->cookie = const_cast<void*>(MCREQ_PKT_COOKIE(req)(((req)->flags & MCREQ_F_REQEXT) ? ((mc_REQDATA *)(req )->u_rdata.exdata) : (&(req)->u_rdata.reqdata))-> cookie); | |||
247 | mcreq_get_key(req, &resp->key, &resp->nkey); | |||
248 | } | |||
249 | ||||
250 | /** | |||
251 | * Handles the propagation and population of the 'mutation token' information. | |||
252 | * @param mc_resp The response packet | |||
253 | * @param req The request packet (used to get the vBucket) | |||
254 | * @param tgt Pointer to mutation token which should be populated. | |||
255 | */ | |||
256 | static void | |||
257 | handle_mutation_token(lcb_t instance, const MemcachedResponse *mc_resp, | |||
258 | const mc_PACKET *req, lcb_MUTATION_TOKEN *stok) | |||
259 | { | |||
260 | const char *sbuf; | |||
261 | uint16_t vbid; | |||
262 | if (mc_resp->extlen() == 0) { | |||
263 | return; /* No extras */ | |||
264 | } | |||
265 | ||||
266 | if (!instance->dcpinfo && LCBT_SETTING(instance, dur_mutation_tokens)(instance)->settings->dur_mutation_tokens) { | |||
267 | size_t nvb = LCBT_VBCONFIG(instance)(instance)->cmdq.config->nvb; | |||
268 | if (nvb) { | |||
269 | instance->dcpinfo = new lcb_MUTATION_TOKEN[nvb]; | |||
270 | memset(instance->dcpinfo, 0, sizeof(*instance->dcpinfo) * nvb); | |||
271 | } | |||
272 | } | |||
273 | ||||
274 | sbuf = mc_resp->body<const char*>(); | |||
275 | vbid = mcreq_get_vbucket(req); | |||
276 | stok->vbid_ = vbid; | |||
277 | memcpy(&stok->uuid_, sbuf, 8); | |||
278 | memcpy(&stok->seqno_, sbuf + 8, 8); | |||
279 | ||||
280 | stok->uuid_ = lcb_ntohll(stok->uuid_)lcb_byteswap64(stok->uuid_); | |||
281 | stok->seqno_ = lcb_ntohll(stok->seqno_)lcb_byteswap64(stok->seqno_); | |||
282 | ||||
283 | if (instance->dcpinfo) { | |||
284 | instance->dcpinfo[vbid] = *stok; | |||
285 | } | |||
286 | } | |||
287 | ||||
288 | static lcb_t get_instance(mc_PIPELINE *pipeline) { | |||
289 | return reinterpret_cast<lcb_t>(pipeline->parent->cqdata); | |||
290 | } | |||
291 | ||||
292 | template <typename T> | |||
293 | void invoke_callback(const mc_PACKET *pkt, | |||
294 | lcb_t instance, T* resp, lcb_CALLBACKTYPE cbtype) | |||
295 | { | |||
296 | if (!(pkt->flags & MCREQ_F_INVOKED)) { | |||
297 | resp->cookie = const_cast<void*>(MCREQ_PKT_COOKIE(pkt)(((pkt)->flags & MCREQ_F_REQEXT) ? ((mc_REQDATA *)(pkt )->u_rdata.exdata) : (&(pkt)->u_rdata.reqdata))-> cookie); | |||
298 | const lcb_RESPBASE *base = reinterpret_cast<const lcb_RESPBASE*>(resp); | |||
299 | if ((pkt->flags & MCREQ_F_PRIVCALLBACK) == 0) { | |||
300 | find_callback(instance, cbtype)(instance, cbtype, base); | |||
301 | } else { | |||
302 | (*(lcb_RESPCALLBACK*)resp->cookie)(instance, cbtype, base); | |||
303 | } | |||
304 | } | |||
305 | } | |||
306 | ||||
307 | template <typename T> | |||
308 | void invoke_callback(const mc_PACKET *pkt, mc_PIPELINE *pipeline, T *resp, | |||
309 | lcb_CALLBACKTYPE cbtype) | |||
310 | { | |||
311 | invoke_callback(pkt, get_instance(pipeline), cbtype, resp); | |||
312 | } | |||
313 | ||||
314 | /** | |||
315 | * Optionally decompress an incoming payload. | |||
316 | * @param o The instance | |||
317 | * @param resp The response received | |||
318 | * @param[out] bytes pointer to the final payload | |||
319 | * @param[out] nbytes pointer to the size of the final payload | |||
320 | * @param[out] freeptr pointer to free. This should be initialized to `NULL`. | |||
321 | * If temporary dynamic storage is required this will be set to the allocated | |||
322 | * pointer upon return. Otherwise it will be set to NULL. In any case it must | |||
323 | */ | |||
324 | static void | |||
325 | maybe_decompress(lcb_t o, | |||
326 | const MemcachedResponse* respkt, lcb_RESPGET *rescmd, void **freeptr) | |||
327 | { | |||
328 | lcb_U8 dtype = 0; | |||
329 | if (!respkt->vallen()) { | |||
330 | return; | |||
331 | } | |||
332 | ||||
333 | if (respkt->datatype() & PROTOCOL_BINARY_DATATYPE_JSON) { | |||
334 | dtype = LCB_VALUE_F_JSON; | |||
335 | } | |||
336 | ||||
337 | if (respkt->datatype() & PROTOCOL_BINARY_DATATYPE_COMPRESSED) { | |||
338 | if (LCBT_SETTING(o, compressopts)(o)->settings->compressopts & LCB_COMPRESS_IN) { | |||
339 | /* if we inflate, we don't set the flag */ | |||
340 | mcreq_inflate_value( | |||
341 | respkt->value(), respkt->vallen(), | |||
342 | &rescmd->value, &rescmd->nvalue, freeptr); | |||
343 | ||||
344 | } else { | |||
345 | /* user doesn't want inflation. signal it's compressed */ | |||
346 | dtype |= LCB_VALUE_F_SNAPPYCOMP; | |||
347 | } | |||
348 | } | |||
349 | rescmd->datatype = dtype; | |||
350 | } | |||
351 | ||||
352 | static void | |||
353 | H_get(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse* response, | |||
354 | lcb_error_t immerr) | |||
355 | { | |||
356 | ResponsePack<lcb_RESPGET> w = {{ 0 }}; | |||
357 | lcb_RESPGET& resp = w.resp; | |||
358 | ||||
359 | lcb_t o = get_instance(pipeline); | |||
360 | init_resp(o, response, request, immerr, &resp); | |||
361 | handle_error_info(response, &w); | |||
362 | resp.rflags |= LCB_RESP_F_FINAL; | |||
363 | ||||
364 | if (resp.rc == LCB_SUCCESS) { | |||
365 | const protocol_binary_response_get *get = | |||
366 | reinterpret_cast<const protocol_binary_response_get*>( | |||
367 | response->ephemeral_start()); | |||
368 | resp.datatype = response->datatype(); | |||
369 | resp.itmflags = ntohl(get->message.body.flags); | |||
370 | resp.value = response->value(); | |||
371 | resp.nvalue = response->vallen(); | |||
372 | resp.bufh = response->bufseg(); | |||
373 | } | |||
374 | ||||
375 | void *freeptr = NULL__null; | |||
376 | maybe_decompress(o, response, &resp, &freeptr); | |||
377 | TRACE_GET_END(response, &resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_get_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"get_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6] %n[_SDT_S7]@%[_SDT_A7] %n[_SDT_S8]@%[_SDT_A8] %n[_SDT_S9]@%[_SDT_A9] %n[_SDT_S10]@%[_SDT_A10] %n[_SDT_S11]@%[_SDT_A11]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&resp)->rc ) == 14 || __builtin_classify_type ((&resp)->rc) == 5) && __sdt_type<__typeof ((&resp)->rc)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((& resp)->rc) == 14 || __builtin_classify_type ((&resp)-> rc) == 5) ? sizeof (void *) : sizeof ((&resp)->rc))), [ _SDT_A4] "nor" (((&resp)->rc)), [_SDT_S5] "n" (((!(__builtin_classify_type ((const char *)(&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) && __sdt_type <__typeof ((const char *)(&resp)->key)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *) (&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&resp)->key))), [_SDT_A5] "nor" (((const char *)(&resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) && __sdt_type<__typeof ((& resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&resp) ->nkey))), [_SDT_A6] "nor" (((&resp)->nkey)), [_SDT_S7 ] "n" (((!(__builtin_classify_type ((const char*)(&resp)-> value) == 14 || __builtin_classify_type ((const char*)(&resp )->value) == 5) && __sdt_type<__typeof ((const char *)(&resp)->value)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((const char*)(&resp)->value ) == 14 || __builtin_classify_type ((const char*)(&resp)-> value) == 5) ? sizeof (void *) : sizeof ((const char*)(&resp )->value))), [_SDT_A7] "nor" (((const char*)(&resp)-> value)), [_SDT_S8] "n" (((!(__builtin_classify_type ((&resp )->nvalue) == 14 || __builtin_classify_type ((&resp)-> nvalue) == 5) && __sdt_type<__typeof ((&resp)-> nvalue)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->nvalue) == 14 || __builtin_classify_type (( &resp)->nvalue) == 5) ? sizeof (void *) : sizeof ((& resp)->nvalue))), [_SDT_A8] "nor" (((&resp)->nvalue )), [_SDT_S9] "n" (((!(__builtin_classify_type ((&resp)-> itmflags) == 14 || __builtin_classify_type ((&resp)->itmflags ) == 5) && __sdt_type<__typeof ((&resp)->itmflags )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->itmflags) == 14 || __builtin_classify_type ( (&resp)->itmflags) == 5) ? sizeof (void *) : sizeof (( &resp)->itmflags))), [_SDT_A9] "nor" (((&resp)-> itmflags)), [_SDT_S10] "n" (((!(__builtin_classify_type ((& resp)->cas) == 14 || __builtin_classify_type ((&resp)-> cas) == 5) && __sdt_type<__typeof ((&resp)-> cas)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->cas) == 14 || __builtin_classify_type ((& resp)->cas) == 5) ? sizeof (void *) : sizeof ((&resp)-> cas))), [_SDT_A10] "nor" (((&resp)->cas)), [_SDT_S11] "n" (((!(__builtin_classify_type (response->datatype()) == 14 || __builtin_classify_type (response->datatype()) == 5) && __sdt_type<__typeof (response->datatype())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->datatype ()) == 14 || __builtin_classify_type (response->datatype() ) == 5) ? sizeof (void *) : sizeof (response->datatype())) ), [_SDT_A11] "nor" ((response->datatype()))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
378 | invoke_callback(request, o, &resp, LCB_CALLBACK_GET); | |||
379 | free(freeptr); | |||
380 | } | |||
381 | ||||
382 | static void | |||
383 | H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
384 | MemcachedResponse *response, lcb_error_t immerr) | |||
385 | { | |||
386 | ResponsePack<lcb_RESPGET> w = {{ 0 }}; | |||
387 | lcb_RESPGET& resp = w.resp; | |||
388 | lcb_t instance = get_instance(pipeline); | |||
389 | void *freeptr = NULL__null; | |||
390 | mc_REQDATAEX *rd = request->u_rdata.exdata; | |||
391 | ||||
392 | init_resp(instance, response, request, immerr, &resp); | |||
393 | handle_error_info(response, &w); | |||
394 | ||||
395 | if (resp.rc == LCB_SUCCESS) { | |||
396 | const protocol_binary_response_get *get = | |||
397 | reinterpret_cast<const protocol_binary_response_get*>( | |||
398 | response->ephemeral_start()); | |||
399 | resp.itmflags = ntohl(get->message.body.flags); | |||
400 | resp.datatype = response->datatype(); | |||
401 | resp.value = response->value(); | |||
402 | resp.nvalue = response->vallen(); | |||
403 | resp.bufh = response->bufseg(); | |||
404 | } | |||
405 | ||||
406 | maybe_decompress(instance, response, &resp, &freeptr); | |||
407 | rd->procs->handler(pipeline, request, resp.rc, &resp); | |||
408 | free(freeptr); | |||
409 | } | |||
410 | ||||
411 | static void | |||
412 | H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
413 | MemcachedResponse *response, lcb_error_t immerr) | |||
414 | { | |||
415 | lcb_t o = get_instance(pipeline); | |||
416 | ResponsePack<lcb_RESPSUBDOC> w = {{ 0 }}; | |||
417 | lcb_CALLBACKTYPE cbtype; | |||
418 | init_resp(o, response, request, immerr, &w.resp); | |||
419 | w.resp.rflags |= LCB_RESP_F_FINAL; | |||
420 | ||||
421 | /* For mutations, add the mutation token */ | |||
422 | switch (response->opcode()) { | |||
423 | case PROTOCOL_BINARY_CMD_SUBDOC_GET: | |||
424 | case PROTOCOL_BINARY_CMD_SUBDOC_EXISTS: | |||
425 | case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP: | |||
426 | cbtype = LCB_CALLBACK_SDLOOKUP; | |||
427 | break; | |||
428 | ||||
429 | default: | |||
430 | handle_mutation_token(o, response, request, &w.mt); | |||
431 | w.resp.rflags |= LCB_RESP_F_EXTDATA; | |||
432 | cbtype = LCB_CALLBACK_SDMUTATE; | |||
433 | break; | |||
434 | } | |||
435 | ||||
436 | if (response->opcode() == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP || | |||
437 | response->opcode() == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION) { | |||
438 | if (w.resp.rc == LCB_SUCCESS || w.resp.rc == LCB_SUBDOC_MULTI_FAILURE) { | |||
439 | w.resp.responses = response; | |||
440 | } else { | |||
441 | handle_error_info(response, &w); | |||
442 | } | |||
443 | } else { | |||
444 | /* Single response */ | |||
445 | w.resp.rflags |= LCB_RESP_F_SDSINGLE; | |||
446 | if (w.resp.rc == LCB_SUCCESS) { | |||
447 | w.resp.responses = response; | |||
448 | } else if (LCB_EIFSUBDOC(w.resp.rc)(lcb_get_errtype(w.resp.rc) & LCB_ERRTYPE_SUBDOC)) { | |||
449 | w.resp.responses = response; | |||
450 | w.resp.rc = LCB_SUBDOC_MULTI_FAILURE; | |||
451 | } else { | |||
452 | handle_error_info(response, &w); | |||
453 | } | |||
454 | } | |||
455 | invoke_callback(request, o, &w.resp, cbtype); | |||
456 | } | |||
457 | ||||
458 | static int | |||
459 | sdlookup_next(const MemcachedResponse *response, lcb_SDENTRY *ent, size_t *iter) | |||
460 | { | |||
461 | const char *buf; | |||
462 | uint16_t rc; | |||
463 | uint32_t vlen; | |||
464 | ||||
465 | if (*iter == response->vallen()) { | |||
466 | return 0; | |||
467 | } | |||
468 | ||||
469 | buf = response->value(); | |||
470 | buf += *iter; | |||
471 | ||||
472 | memcpy(&rc, buf, 2); | |||
473 | memcpy(&vlen, buf + 2, 4); | |||
474 | ||||
475 | rc = ntohs(rc); | |||
476 | vlen = ntohl(vlen); | |||
477 | ||||
478 | ent->status = map_error(NULL__null, rc); | |||
479 | ent->nvalue = vlen; | |||
480 | ||||
481 | if (ent->status == LCB_SUCCESS) { | |||
482 | ent->value = buf + 6; | |||
483 | } else { | |||
484 | ent->value = NULL__null; | |||
485 | ent->nvalue = 0; | |||
486 | } | |||
487 | ||||
488 | *iter += (6 + vlen); | |||
489 | return 1; | |||
490 | } | |||
491 | ||||
492 | static int | |||
493 | sdmutate_next(const MemcachedResponse *response, lcb_SDENTRY *ent, size_t *iter) | |||
494 | { | |||
495 | const char *buf, *buf_end; | |||
496 | uint16_t rc; | |||
497 | uint32_t vlen; | |||
498 | ||||
499 | if (*iter == response->vallen()) { | |||
500 | return 0; | |||
501 | } | |||
502 | ||||
503 | buf_end = (const char *)response->value() + response->vallen(); | |||
504 | buf = ((const char *)(response->value())) + *iter; | |||
505 | ||||
506 | #define ADVANCE_BUF(sz) \ | |||
507 | buf += sz; \ | |||
508 | *iter += sz; \ | |||
509 | assert(buf <= buf_end)(static_cast <bool> (buf <= buf_end) ? void (0) : __assert_fail ("buf <= buf_end", "/home/avsej/code/libcouchbase/src/handler.cc" , 509, __extension__ __PRETTY_FUNCTION__)); \ | |||
510 | ||||
511 | /* Index */ | |||
512 | ent->index = *(lcb_U8*)buf; | |||
513 | ADVANCE_BUF(1); | |||
514 | ||||
515 | /* Status */ | |||
516 | memcpy(&rc, buf, 2); | |||
517 | ADVANCE_BUF(2); | |||
518 | ||||
519 | rc = ntohs(rc); | |||
520 | ent->status = map_error(NULL__null, rc); | |||
521 | ||||
522 | if (rc == PROTOCOL_BINARY_RESPONSE_SUCCESS) { | |||
523 | memcpy(&vlen, buf, 4); | |||
524 | ADVANCE_BUF(4); | |||
525 | ||||
526 | vlen = ntohl(vlen); | |||
527 | ent->nvalue = vlen; | |||
528 | ent->value = buf; | |||
529 | ADVANCE_BUF(vlen); | |||
530 | ||||
531 | } else { | |||
532 | ent->value = NULL__null; | |||
533 | ent->nvalue = 0; | |||
534 | } | |||
535 | ||||
536 | return 1; | |||
537 | #undef ADVANCE_BUF | |||
538 | } | |||
539 | ||||
540 | LIBCOUCHBASE_API__attribute__ ((visibility("default"))) | |||
541 | int | |||
542 | lcb_sdresult_next(const lcb_RESPSUBDOC *resp, lcb_SDENTRY *ent, size_t *iter) | |||
543 | { | |||
544 | size_t iter_s = 0; | |||
545 | const MemcachedResponse *response = | |||
546 | reinterpret_cast<const MemcachedResponse*>(resp->responses); | |||
547 | if (!response) { | |||
548 | return 0; | |||
549 | } | |||
550 | if (!iter) { | |||
551 | /* Single response */ | |||
552 | iter = &iter_s; | |||
553 | } | |||
554 | ||||
555 | switch (response->opcode()) { | |||
556 | case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP: | |||
557 | return sdlookup_next(response, ent, iter); | |||
558 | case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION: | |||
559 | return sdmutate_next(response, ent, iter); | |||
560 | default: | |||
561 | if (*iter) { | |||
562 | return 0; | |||
563 | } | |||
564 | *iter = 1; | |||
565 | ||||
566 | if (resp->rc == LCB_SUCCESS || resp->rc == LCB_SUBDOC_MULTI_FAILURE) { | |||
567 | ent->status = map_error(NULL__null, response->status()); | |||
568 | ent->value = response->value(); | |||
569 | ent->nvalue = response->vallen(); | |||
570 | ent->index = 0; | |||
571 | return 1; | |||
572 | } else { | |||
573 | return 0; | |||
574 | } | |||
575 | } | |||
576 | } | |||
577 | ||||
578 | static void | |||
579 | H_delete(mc_PIPELINE *pipeline, mc_PACKET *packet, MemcachedResponse *response, | |||
580 | lcb_error_t immerr) | |||
581 | { | |||
582 | lcb_t root = get_instance(pipeline); | |||
583 | ResponsePack<lcb_RESPREMOVE> w = { { 0 } }; | |||
584 | w.resp.rflags |= LCB_RESP_F_EXTDATA | LCB_RESP_F_FINAL; | |||
585 | init_resp(root, response, packet, immerr, &w.resp); | |||
586 | handle_error_info(response, &w); | |||
587 | handle_mutation_token(root, response, packet, &w.mt); | |||
588 | TRACE_REMOVE_END(response, &w.resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_remove_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"remove_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6] %n[_SDT_S7]@%[_SDT_A7]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&w.resp)-> rc) == 14 || __builtin_classify_type ((&w.resp)->rc) == 5) && __sdt_type<__typeof ((&w.resp)->rc)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (&w.resp)->rc) == 14 || __builtin_classify_type ((& w.resp)->rc) == 5) ? sizeof (void *) : sizeof ((&w.resp )->rc))), [_SDT_A4] "nor" (((&w.resp)->rc)), [_SDT_S5 ] "n" (((!(__builtin_classify_type ((const char *)(&w.resp )->key) == 14 || __builtin_classify_type ((const char *)(& w.resp)->key) == 5) && __sdt_type<__typeof ((const char *)(&w.resp)->key)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *)(&w.resp) ->key) == 14 || __builtin_classify_type ((const char *)(& w.resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&w.resp)->key))), [_SDT_A5] "nor" (((const char *) (&w.resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&w.resp)->nkey) == 14 || __builtin_classify_type (( &w.resp)->nkey) == 5) && __sdt_type<__typeof ((&w.resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type ((&w.resp)->nkey) == 14 || __builtin_classify_type ((&w.resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&w.resp)->nkey))), [_SDT_A6] "nor" (((&w.resp)->nkey)), [_SDT_S7] "n" (((!(__builtin_classify_type ((&w.resp)->cas) == 14 || __builtin_classify_type ((& w.resp)->cas) == 5) && __sdt_type<__typeof ((& w.resp)->cas)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&w.resp)->cas) == 14 || __builtin_classify_type ((& w.resp)->cas) == 5) ? sizeof (void *) : sizeof ((&w.resp )->cas))), [_SDT_A7] "nor" (((&w.resp)->cas))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
589 | invoke_callback(packet, root, &w.resp, LCB_CALLBACK_REMOVE); | |||
590 | } | |||
591 | ||||
592 | static void | |||
593 | H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response, | |||
594 | lcb_error_t immerr) | |||
595 | { | |||
596 | lcb_t root = get_instance(pipeline); | |||
597 | uint32_t ttp; | |||
598 | uint32_t ttr; | |||
599 | size_t pos; | |||
600 | lcbvb_CONFIG* config; | |||
601 | const char *end, *ptr; | |||
602 | mc_REQDATAEX *rd = request->u_rdata.exdata; | |||
603 | lcb_RESPOBSERVE resp = { 0 }; | |||
604 | make_error(root, &resp, response, immerr); | |||
605 | ||||
606 | if (resp.rc != LCB_SUCCESS) { | |||
607 | if (! (request->flags & MCREQ_F_INVOKED)) { | |||
608 | rd->procs->handler(pipeline, request, resp.rc, NULL__null); | |||
609 | } | |||
610 | return; | |||
611 | } | |||
612 | ||||
613 | /** The CAS field is split into TTP/TTR values */ | |||
614 | uint64_t tmpcas = lcb_htonll(response->cas())lcb_byteswap64(response->cas()); | |||
615 | ptr = reinterpret_cast<char*>(&tmpcas); | |||
616 | memcpy(&ttp, ptr, sizeof(ttp)); | |||
617 | memcpy(&ttr, ptr + sizeof(ttp), sizeof(ttp)); | |||
618 | ||||
619 | ttp = ntohl(ttp); | |||
620 | ttr = ntohl(ttr); | |||
621 | ||||
622 | /** Actual payload sequence of (vb, nkey, key). Repeats multiple times */ | |||
623 | ptr = response->body<const char *>(); | |||
624 | end = ptr + response->bodylen(); | |||
625 | config = pipeline->parent->config; | |||
626 | ||||
627 | for (pos = 0; ptr < end; pos++) { | |||
628 | uint64_t cas; | |||
629 | uint8_t obs; | |||
630 | uint16_t nkey, vb; | |||
631 | const char *key; | |||
632 | ||||
633 | memcpy(&vb, ptr, sizeof(vb)); | |||
634 | vb = ntohs(vb); | |||
635 | ptr += sizeof(vb); | |||
636 | memcpy(&nkey, ptr, sizeof(nkey)); | |||
637 | nkey = ntohs(nkey); | |||
638 | ptr += sizeof(nkey); | |||
639 | key = (const char *)ptr; | |||
640 | ptr += nkey; | |||
641 | obs = *((lcb_uint8_t *)ptr); | |||
642 | ptr += sizeof(obs); | |||
643 | memcpy(&cas, ptr, sizeof(cas)); | |||
644 | ptr += sizeof(cas); | |||
645 | ||||
646 | resp.key = key; | |||
647 | resp.nkey = nkey; | |||
648 | resp.cas = lcb_ntohll(cas)lcb_byteswap64(cas); | |||
649 | resp.status = obs; | |||
650 | resp.ismaster = pipeline->index == lcbvb_vbmaster(config, vb); | |||
651 | resp.ttp = 0; | |||
652 | resp.ttr = 0; | |||
653 | TRACE_OBSERVE_PROGRESS(response, &resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_observe_progress_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"observe_progress\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6] %n[_SDT_S7]@%[_SDT_A7] %n[_SDT_S8]@%[_SDT_A8] %n[_SDT_S9]@%[_SDT_A9] %n[_SDT_S10]@%[_SDT_A10] %n[_SDT_S11]@%[_SDT_A11]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&resp)->rc ) == 14 || __builtin_classify_type ((&resp)->rc) == 5) && __sdt_type<__typeof ((&resp)->rc)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((& resp)->rc) == 14 || __builtin_classify_type ((&resp)-> rc) == 5) ? sizeof (void *) : sizeof ((&resp)->rc))), [ _SDT_A4] "nor" (((&resp)->rc)), [_SDT_S5] "n" (((!(__builtin_classify_type ((const char *)(&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) && __sdt_type <__typeof ((const char *)(&resp)->key)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *) (&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&resp)->key))), [_SDT_A5] "nor" (((const char *)(&resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) && __sdt_type<__typeof ((& resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&resp) ->nkey))), [_SDT_A6] "nor" (((&resp)->nkey)), [_SDT_S7 ] "n" (((!(__builtin_classify_type ((&resp)->cas) == 14 || __builtin_classify_type ((&resp)->cas) == 5) && __sdt_type<__typeof ((&resp)->cas)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)-> cas) == 14 || __builtin_classify_type ((&resp)->cas) == 5) ? sizeof (void *) : sizeof ((&resp)->cas))), [_SDT_A7 ] "nor" (((&resp)->cas)), [_SDT_S8] "n" (((!(__builtin_classify_type ((&resp)->status) == 14 || __builtin_classify_type (( &resp)->status) == 5) && __sdt_type<__typeof ((&resp)->status)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type ((&resp)->status) == 14 || __builtin_classify_type ((&resp)->status) == 5) ? sizeof (void *) : sizeof ((&resp)->status))), [_SDT_A8] "nor" (((&resp)->status)), [_SDT_S9] "n" (((!(__builtin_classify_type ((&resp)->ismaster) == 14 || __builtin_classify_type ( (&resp)->ismaster) == 5) && __sdt_type<__typeof ((&resp)->ismaster)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type ((&resp)->ismaster) == 14 || __builtin_classify_type ((&resp)->ismaster) == 5) ? sizeof (void *) : sizeof ((&resp)->ismaster))), [_SDT_A9] "nor" (((&resp)->ismaster)), [_SDT_S10] "n" (((!(__builtin_classify_type ((&resp)->ttp) == 14 || __builtin_classify_type ((& resp)->ttp) == 5) && __sdt_type<__typeof ((& resp)->ttp)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->ttp) == 14 || __builtin_classify_type ((& resp)->ttp) == 5) ? sizeof (void *) : sizeof ((&resp)-> ttp))), [_SDT_A10] "nor" (((&resp)->ttp)), [_SDT_S11] "n" (((!(__builtin_classify_type ((&resp)->ttr) == 14 || __builtin_classify_type ((&resp)->ttr) == 5) && __sdt_type<__typeof ((&resp)->ttr)>::__sdt_signed) ? 1 : -1) * (int) ( (__builtin_classify_type ((&resp)->ttr) == 14 || __builtin_classify_type ((&resp)->ttr) == 5) ? sizeof (void *) : sizeof ((& resp)->ttr))), [_SDT_A11] "nor" (((&resp)->ttr))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
654 | if (! (request->flags & MCREQ_F_INVOKED)) { | |||
655 | rd->procs->handler(pipeline, request, resp.rc, &resp); | |||
656 | } | |||
657 | } | |||
658 | TRACE_OBSERVE_END(response)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_observe_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"observe_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type (LCB_SUCCESS) == 14 || __builtin_classify_type (LCB_SUCCESS) == 5) && __sdt_type <__typeof (LCB_SUCCESS)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type (LCB_SUCCESS) == 14 || __builtin_classify_type (LCB_SUCCESS) == 5) ? sizeof (void *) : sizeof (LCB_SUCCESS) )), [_SDT_A4] "nor" ((LCB_SUCCESS))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
659 | } | |||
660 | ||||
661 | static void | |||
662 | H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
663 | MemcachedResponse *response, lcb_error_t immerr) { | |||
664 | lcb_t root = get_instance(pipeline); | |||
665 | lcb_RESPOBSEQNO resp = { 0 }; | |||
666 | init_resp(root, response, request, immerr, &resp); | |||
667 | ||||
668 | resp.server_index = pipeline->index; | |||
669 | ||||
670 | if (resp.rc == LCB_SUCCESS) { | |||
671 | const uint8_t *data = response->body<const uint8_t*>(); | |||
672 | bool is_failover = *data != 0; | |||
673 | ||||
674 | data++; | |||
675 | #define COPY_ADV(dstfld, n, conv_fn) \ | |||
676 | memcpy(&resp.dstfld, data, n); \ | |||
677 | data += n; \ | |||
678 | resp.dstfld = conv_fn(resp.dstfld); | |||
679 | ||||
680 | COPY_ADV(vbid, 2, ntohs); | |||
681 | COPY_ADV(cur_uuid, 8, lcb_ntohll); | |||
682 | COPY_ADV(persisted_seqno, 8, lcb_ntohll); | |||
683 | COPY_ADV(mem_seqno, 8, lcb_ntohll); | |||
684 | if (is_failover) { | |||
685 | COPY_ADV(old_uuid, 8, lcb_ntohll); | |||
686 | COPY_ADV(old_seqno, 8, lcb_ntohll); | |||
687 | } | |||
688 | #undef COPY_ADV | |||
689 | ||||
690 | /* Get the server for this command. Note that since this is a successful | |||
691 | * operation, the server is never a dummy */ | |||
692 | } | |||
693 | invoke_callback(request, root, &resp, LCB_CALLBACK_OBSEQNO); | |||
694 | } | |||
695 | ||||
696 | static void | |||
697 | H_store(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response, | |||
698 | lcb_error_t immerr) | |||
699 | { | |||
700 | lcb_t root = get_instance(pipeline); | |||
701 | ResponsePack<lcb_RESPSTORE> w = { { 0 } }; | |||
702 | uint8_t opcode; | |||
703 | init_resp(root, response, request, immerr, &w.resp); | |||
704 | handle_error_info(response, &w); | |||
705 | if (!immerr) { | |||
706 | opcode = response->opcode(); | |||
707 | } else { | |||
708 | protocol_binary_request_header hdr; | |||
709 | mcreq_read_hdr(request, &hdr)memcpy( (&hdr)->bytes, (((&(request)->kh_span)-> offset == (nb_SIZE)-1) ? ((char *)(&(request)->kh_span )->parent) : ((&(request)->kh_span)->parent-> root + (&(request)->kh_span)->offset)), sizeof((& hdr)->bytes) ); | |||
710 | opcode = hdr.request.opcode; | |||
711 | } | |||
712 | if (opcode == PROTOCOL_BINARY_CMD_ADD) { | |||
713 | w.resp.op = LCB_ADD; | |||
714 | } else if (opcode == PROTOCOL_BINARY_CMD_REPLACE) { | |||
715 | w.resp.op = LCB_REPLACE; | |||
716 | } else if (opcode == PROTOCOL_BINARY_CMD_APPEND) { | |||
717 | w.resp.op = LCB_APPEND; | |||
718 | } else if (opcode == PROTOCOL_BINARY_CMD_PREPEND) { | |||
719 | w.resp.op = LCB_PREPEND; | |||
720 | } else if (opcode == PROTOCOL_BINARY_CMD_SET) { | |||
721 | w.resp.op = LCB_SET; | |||
722 | } | |||
723 | w.resp.rflags |= LCB_RESP_F_EXTDATA | LCB_RESP_F_FINAL; | |||
724 | handle_mutation_token(root, response, request, &w.mt); | |||
725 | TRACE_STORE_END(response, &w.resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_store_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"store_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6] %n[_SDT_S7]@%[_SDT_A7]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&w.resp)-> rc) == 14 || __builtin_classify_type ((&w.resp)->rc) == 5) && __sdt_type<__typeof ((&w.resp)->rc)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (&w.resp)->rc) == 14 || __builtin_classify_type ((& w.resp)->rc) == 5) ? sizeof (void *) : sizeof ((&w.resp )->rc))), [_SDT_A4] "nor" (((&w.resp)->rc)), [_SDT_S5 ] "n" (((!(__builtin_classify_type ((const char *)(&w.resp )->key) == 14 || __builtin_classify_type ((const char *)(& w.resp)->key) == 5) && __sdt_type<__typeof ((const char *)(&w.resp)->key)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *)(&w.resp) ->key) == 14 || __builtin_classify_type ((const char *)(& w.resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&w.resp)->key))), [_SDT_A5] "nor" (((const char *) (&w.resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&w.resp)->nkey) == 14 || __builtin_classify_type (( &w.resp)->nkey) == 5) && __sdt_type<__typeof ((&w.resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type ((&w.resp)->nkey) == 14 || __builtin_classify_type ((&w.resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&w.resp)->nkey))), [_SDT_A6] "nor" (((&w.resp)->nkey)), [_SDT_S7] "n" (((!(__builtin_classify_type ((&w.resp)->cas) == 14 || __builtin_classify_type ((& w.resp)->cas) == 5) && __sdt_type<__typeof ((& w.resp)->cas)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&w.resp)->cas) == 14 || __builtin_classify_type ((& w.resp)->cas) == 5) ? sizeof (void *) : sizeof ((&w.resp )->cas))), [_SDT_A7] "nor" (((&w.resp)->cas))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
726 | if (request->flags & MCREQ_F_REQEXT) { | |||
727 | request->u_rdata.exdata->procs->handler(pipeline, request, immerr, &w.resp); | |||
728 | } else { | |||
729 | invoke_callback(request, root, &w.resp, LCB_CALLBACK_STORE); | |||
730 | } | |||
731 | } | |||
732 | ||||
733 | static void | |||
734 | H_arithmetic(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
735 | MemcachedResponse *response, lcb_error_t immerr) | |||
736 | { | |||
737 | lcb_t root = get_instance(pipeline); | |||
738 | ResponsePack<lcb_RESPCOUNTER> w = { { 0 } }; | |||
739 | init_resp(root, response, request, immerr, &w.resp); | |||
740 | ||||
741 | if (w.resp.rc == LCB_SUCCESS) { | |||
742 | memcpy(&w.resp.value, response->value(), sizeof(w.resp.value)); | |||
743 | w.resp.value = lcb_ntohll(w.resp.value)lcb_byteswap64(w.resp.value); | |||
744 | w.resp.rflags |= LCB_RESP_F_EXTDATA; | |||
745 | handle_mutation_token(root, response, request, &w.mt); | |||
746 | } else { | |||
747 | handle_error_info(response, &w); | |||
748 | } | |||
749 | w.resp.rflags |= LCB_RESP_F_FINAL; | |||
750 | w.resp.cas = response->cas(); | |||
751 | TRACE_ARITHMETIC_END(response, &w.resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_arithmetic_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"arithmetic_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6] %n[_SDT_S7]@%[_SDT_A7] %n[_SDT_S8]@%[_SDT_A8]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&w.resp)-> rc) == 14 || __builtin_classify_type ((&w.resp)->rc) == 5) && __sdt_type<__typeof ((&w.resp)->rc)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (&w.resp)->rc) == 14 || __builtin_classify_type ((& w.resp)->rc) == 5) ? sizeof (void *) : sizeof ((&w.resp )->rc))), [_SDT_A4] "nor" (((&w.resp)->rc)), [_SDT_S5 ] "n" (((!(__builtin_classify_type ((const char *)(&w.resp )->key) == 14 || __builtin_classify_type ((const char *)(& w.resp)->key) == 5) && __sdt_type<__typeof ((const char *)(&w.resp)->key)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *)(&w.resp) ->key) == 14 || __builtin_classify_type ((const char *)(& w.resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&w.resp)->key))), [_SDT_A5] "nor" (((const char *) (&w.resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&w.resp)->nkey) == 14 || __builtin_classify_type (( &w.resp)->nkey) == 5) && __sdt_type<__typeof ((&w.resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type ((&w.resp)->nkey) == 14 || __builtin_classify_type ((&w.resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&w.resp)->nkey))), [_SDT_A6] "nor" (((&w.resp)->nkey)), [_SDT_S7] "n" (((!(__builtin_classify_type ((&w.resp)->value) == 14 || __builtin_classify_type ( (&w.resp)->value) == 5) && __sdt_type<__typeof ((&w.resp)->value)>::__sdt_signed) ? 1 : -1) * (int ) ((__builtin_classify_type ((&w.resp)->value) == 14 || __builtin_classify_type ((&w.resp)->value) == 5) ? sizeof (void *) : sizeof ((&w.resp)->value))), [_SDT_A7] "nor" (((&w.resp)->value)), [_SDT_S8] "n" (((!(__builtin_classify_type ((&w.resp)->cas) == 14 || __builtin_classify_type ((& w.resp)->cas) == 5) && __sdt_type<__typeof ((& w.resp)->cas)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&w.resp)->cas) == 14 || __builtin_classify_type ((& w.resp)->cas) == 5) ? sizeof (void *) : sizeof ((&w.resp )->cas))), [_SDT_A8] "nor" (((&w.resp)->cas))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
752 | invoke_callback(request, root, &w.resp, LCB_CALLBACK_COUNTER); | |||
753 | } | |||
754 | ||||
755 | static void | |||
756 | H_stats(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
757 | MemcachedResponse *response, lcb_error_t immerr) | |||
758 | { | |||
759 | lcb_t root = get_instance(pipeline); | |||
760 | lcb_RESPSTATS resp = { 0 }; | |||
761 | mc_REQDATAEX *exdata; | |||
762 | ||||
763 | make_error(root, &resp, response, immerr); | |||
764 | resp.version = 0; | |||
765 | ||||
766 | exdata = request->u_rdata.exdata; | |||
767 | if (resp.rc != LCB_SUCCESS || response->keylen() == 0) { | |||
768 | /* Call the handler without a response, this indicates that this server | |||
769 | * has finished responding */ | |||
770 | exdata->procs->handler(pipeline, request, resp.rc, NULL__null); | |||
771 | return; | |||
772 | } | |||
773 | ||||
774 | if ((resp.nkey = response->keylen())) { | |||
775 | resp.key = response->key(); | |||
776 | if ((resp.value = response->value())) { | |||
777 | resp.nvalue = response->vallen(); | |||
778 | } | |||
779 | } | |||
780 | ||||
781 | exdata->procs->handler(pipeline, request, resp.rc, &resp); | |||
782 | } | |||
783 | ||||
784 | static void | |||
785 | H_verbosity(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
786 | MemcachedResponse *response, lcb_error_t immerr) | |||
787 | { | |||
788 | lcb_t root = get_instance(pipeline); | |||
789 | lcb_RESPBASE dummy = { 0 }; | |||
790 | mc_REQDATAEX *exdata = request->u_rdata.exdata; | |||
791 | make_error(root, &dummy, response, immerr); | |||
792 | ||||
793 | exdata->procs->handler(pipeline, request, dummy.rc, NULL__null); | |||
794 | } | |||
795 | ||||
796 | static void | |||
797 | H_version(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
798 | MemcachedResponse *response, lcb_error_t immerr) | |||
799 | { | |||
800 | lcb_t root = get_instance(pipeline); | |||
801 | lcb_RESPMCVERSION resp = { 0 }; | |||
802 | mc_REQDATAEX *exdata = request->u_rdata.exdata; | |||
803 | ||||
804 | make_error(root, &resp, response, immerr); | |||
805 | ||||
806 | if (response->bodylen()) { | |||
807 | resp.mcversion = response->body<const char *>(); | |||
808 | resp.nversion = response->bodylen(); | |||
809 | } | |||
810 | ||||
811 | ||||
812 | exdata->procs->handler(pipeline, request, resp.rc, &resp); | |||
813 | } | |||
814 | ||||
815 | static void | |||
816 | H_noop(mc_PIPELINE *pipeline, mc_PACKET *request, | |||
817 | MemcachedResponse *response, lcb_error_t immerr) | |||
818 | { | |||
819 | lcb_t root = get_instance(pipeline); | |||
820 | lcb_RESPNOOP resp = { 0 }; | |||
821 | mc_REQDATAEX *exdata = request->u_rdata.exdata; | |||
822 | ||||
823 | make_error(root, &resp, response, immerr); | |||
824 | ||||
825 | exdata->procs->handler(pipeline, request, resp.rc, &resp); | |||
826 | } | |||
827 | ||||
828 | static void | |||
829 | H_touch(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response, | |||
830 | lcb_error_t immerr) | |||
831 | { | |||
832 | lcb_t root = get_instance(pipeline); | |||
833 | ResponsePack<lcb_RESPTOUCH> w = {{ 0 }}; | |||
834 | lcb_RESPTOUCH& resp = w.resp; | |||
835 | init_resp(root, response, request, immerr, &resp); | |||
836 | handle_error_info(response, &w); | |||
837 | resp.rflags |= LCB_RESP_F_FINAL; | |||
838 | TRACE_TOUCH_END(response, &resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_touch_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"touch_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6] %n[_SDT_S7]@%[_SDT_A7]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&resp)->rc ) == 14 || __builtin_classify_type ((&resp)->rc) == 5) && __sdt_type<__typeof ((&resp)->rc)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((& resp)->rc) == 14 || __builtin_classify_type ((&resp)-> rc) == 5) ? sizeof (void *) : sizeof ((&resp)->rc))), [ _SDT_A4] "nor" (((&resp)->rc)), [_SDT_S5] "n" (((!(__builtin_classify_type ((const char *)(&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) && __sdt_type <__typeof ((const char *)(&resp)->key)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *) (&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&resp)->key))), [_SDT_A5] "nor" (((const char *)(&resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) && __sdt_type<__typeof ((& resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&resp) ->nkey))), [_SDT_A6] "nor" (((&resp)->nkey)), [_SDT_S7 ] "n" (((!(__builtin_classify_type ((&resp)->cas) == 14 || __builtin_classify_type ((&resp)->cas) == 5) && __sdt_type<__typeof ((&resp)->cas)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)-> cas) == 14 || __builtin_classify_type ((&resp)->cas) == 5) ? sizeof (void *) : sizeof ((&resp)->cas))), [_SDT_A7 ] "nor" (((&resp)->cas))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
839 | invoke_callback(request, root, &resp, LCB_CALLBACK_TOUCH); | |||
840 | } | |||
841 | ||||
842 | static void | |||
843 | H_flush(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response, | |||
844 | lcb_error_t immerr) | |||
845 | { | |||
846 | lcb_t root = get_instance(pipeline); | |||
847 | lcb_RESPFLUSH resp = { 0 }; | |||
848 | mc_REQDATAEX *exdata = request->u_rdata.exdata; | |||
849 | make_error(root, &resp, response, immerr); | |||
850 | exdata->procs->handler(pipeline, request, resp.rc, &resp); | |||
851 | } | |||
852 | ||||
853 | static void | |||
854 | H_unlock(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response, | |||
855 | lcb_error_t immerr) | |||
856 | { | |||
857 | lcb_t root = get_instance(pipeline); | |||
858 | ResponsePack<lcb_RESPUNLOCK> w = {{ 0 }}; | |||
859 | lcb_RESPUNLOCK& resp = w.resp; | |||
860 | init_resp(root, response, request, immerr, &resp); | |||
861 | handle_error_info(response, &w); | |||
862 | resp.rflags |= LCB_RESP_F_FINAL; | |||
863 | TRACE_UNLOCK_END(response, &resp)do { __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte libcouchbase_unlock_end_semaphore" "\n" ".asciz \"libcouchbase\"" "\n" ".asciz \"unlock_end\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5] %n[_SDT_S6]@%[_SDT_A6]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (response->opaque()) == 14 || __builtin_classify_type (response->opaque()) == 5) && __sdt_type<__typeof (response->opaque())>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type (response->opaque ()) == 14 || __builtin_classify_type (response->opaque()) == 5) ? sizeof (void *) : sizeof (response->opaque()))), [_SDT_A1 ] "nor" ((response->opaque())), [_SDT_S2] "n" (((!(__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) && __sdt_type <__typeof (0)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (0) == 14 || __builtin_classify_type (0) == 5) ? sizeof (void *) : sizeof (0))), [_SDT_A2] "nor" ((0)), [_SDT_S3] "n" (((! (__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) && __sdt_type<__typeof (response->opcode())>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (response->opcode()) == 14 || __builtin_classify_type (response->opcode()) == 5) ? sizeof (void *) : sizeof (response ->opcode()))), [_SDT_A3] "nor" ((response->opcode())), [ _SDT_S4] "n" (((!(__builtin_classify_type ((&resp)->rc ) == 14 || __builtin_classify_type ((&resp)->rc) == 5) && __sdt_type<__typeof ((&resp)->rc)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((& resp)->rc) == 14 || __builtin_classify_type ((&resp)-> rc) == 5) ? sizeof (void *) : sizeof ((&resp)->rc))), [ _SDT_A4] "nor" (((&resp)->rc)), [_SDT_S5] "n" (((!(__builtin_classify_type ((const char *)(&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) && __sdt_type <__typeof ((const char *)(&resp)->key)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((const char *) (&resp)->key) == 14 || __builtin_classify_type ((const char *)(&resp)->key) == 5) ? sizeof (void *) : sizeof ((const char *)(&resp)->key))), [_SDT_A5] "nor" (((const char *)(&resp)->key)), [_SDT_S6] "n" (((!(__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) && __sdt_type<__typeof ((& resp)->nkey)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((&resp)->nkey) == 14 || __builtin_classify_type ((& resp)->nkey) == 5) ? sizeof (void *) : sizeof ((&resp) ->nkey))), [_SDT_A6] "nor" (((&resp)->nkey))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
864 | invoke_callback(request, root, &resp, LCB_CALLBACK_UNLOCK); | |||
865 | } | |||
866 | ||||
867 | static void | |||
868 | H_config(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response, | |||
869 | lcb_error_t immerr) | |||
870 | { | |||
871 | /** We just jump to the normal config handler */ | |||
872 | lcb_RESPBASE dummy; | |||
873 | mc_REQDATAEX *exdata = request->u_rdata.exdata; | |||
874 | make_error(get_instance(pipeline), &dummy, response, immerr); | |||
875 | ||||
876 | exdata->procs->handler(pipeline, request, dummy.rc, response); | |||
877 | } | |||
878 | ||||
879 | static void | |||
880 | record_metrics(mc_PIPELINE *pipeline, mc_PACKET *req, MemcachedResponse *) | |||
881 | { | |||
882 | lcb_t instance = get_instance(pipeline); | |||
883 | if (instance->kv_timings) { | |||
884 | lcb_histogram_record(instance->kv_timings, | |||
885 | gethrtime() - MCREQ_PKT_RDATA(req)(((req)->flags & MCREQ_F_REQEXT) ? ((mc_REQDATA *)(req )->u_rdata.exdata) : (&(req)->u_rdata.reqdata))->start); | |||
886 | } | |||
887 | } | |||
888 | ||||
889 | static void | |||
890 | dispatch_ufwd_error(mc_PIPELINE *pipeline, mc_PACKET *req, lcb_error_t immerr) | |||
891 | { | |||
892 | lcb_PKTFWDRESP resp = { 0 }; | |||
893 | lcb_t instance = static_cast<lcb::Server*>(pipeline)->get_instance(); | |||
894 | assert(immerr != LCB_SUCCESS)(static_cast <bool> (immerr != LCB_SUCCESS) ? void (0) : __assert_fail ("immerr != LCB_SUCCESS", "/home/avsej/code/libcouchbase/src/handler.cc" , 894, __extension__ __PRETTY_FUNCTION__)); | |||
895 | resp.version = 0; | |||
896 | instance->callbacks.pktfwd(instance, MCREQ_PKT_COOKIE(req)(((req)->flags & MCREQ_F_REQEXT) ? ((mc_REQDATA *)(req )->u_rdata.exdata) : (&(req)->u_rdata.reqdata))-> cookie, immerr, &resp); | |||
897 | } | |||
898 | ||||
899 | int | |||
900 | mcreq_dispatch_response( | |||
901 | mc_PIPELINE *pipeline, mc_PACKET *req, MemcachedResponse *res, | |||
902 | lcb_error_t immerr) | |||
903 | { | |||
904 | record_metrics(pipeline, req, res); | |||
905 | ||||
906 | if (req->flags & MCREQ_F_UFWD) { | |||
| ||||
907 | dispatch_ufwd_error(pipeline, req, immerr); | |||
908 | return 0; | |||
909 | } | |||
910 | ||||
911 | ||||
912 | #define INVOKE_OP(handler)handler(pipeline, req, res, immerr); return 0; break; \ | |||
913 | handler(pipeline, req, res, immerr); \ | |||
914 | return 0; \ | |||
915 | break; | |||
916 | ||||
917 | switch (res->opcode()) { | |||
918 | case PROTOCOL_BINARY_CMD_GET: | |||
919 | case PROTOCOL_BINARY_CMD_GAT: | |||
920 | case PROTOCOL_BINARY_CMD_GET_LOCKED: | |||
921 | INVOKE_OP(H_get)H_get(pipeline, req, res, immerr); return 0; break;; | |||
922 | ||||
923 | case PROTOCOL_BINARY_CMD_ADD: | |||
924 | case PROTOCOL_BINARY_CMD_REPLACE: | |||
925 | case PROTOCOL_BINARY_CMD_SET: | |||
926 | case PROTOCOL_BINARY_CMD_APPEND: | |||
927 | case PROTOCOL_BINARY_CMD_PREPEND: | |||
928 | INVOKE_OP(H_store)H_store(pipeline, req, res, immerr); return 0; break;; | |||
929 | ||||
930 | case PROTOCOL_BINARY_CMD_INCREMENT: | |||
931 | case PROTOCOL_BINARY_CMD_DECREMENT: | |||
932 | INVOKE_OP(H_arithmetic)H_arithmetic(pipeline, req, res, immerr); return 0; break;; | |||
933 | ||||
934 | case PROTOCOL_BINARY_CMD_SUBDOC_GET: | |||
935 | case PROTOCOL_BINARY_CMD_SUBDOC_EXISTS: | |||
936 | case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_ADD_UNIQUE: | |||
937 | case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_PUSH_FIRST: | |||
938 | case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_PUSH_LAST: | |||
939 | case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_INSERT: | |||
940 | case PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD: | |||
941 | case PROTOCOL_BINARY_CMD_SUBDOC_DICT_UPSERT: | |||
942 | case PROTOCOL_BINARY_CMD_SUBDOC_REPLACE: | |||
943 | case PROTOCOL_BINARY_CMD_SUBDOC_DELETE: | |||
944 | case PROTOCOL_BINARY_CMD_SUBDOC_COUNTER: | |||
945 | case PROTOCOL_BINARY_CMD_SUBDOC_GET_COUNT: | |||
946 | case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP: | |||
947 | case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION: | |||
948 | INVOKE_OP(H_subdoc)H_subdoc(pipeline, req, res, immerr); return 0; break;; | |||
949 | ||||
950 | case PROTOCOL_BINARY_CMD_OBSERVE: | |||
951 | INVOKE_OP(H_observe)H_observe(pipeline, req, res, immerr); return 0; break;; | |||
952 | ||||
953 | case PROTOCOL_BINARY_CMD_GET_REPLICA: | |||
954 | INVOKE_OP(H_getreplica)H_getreplica(pipeline, req, res, immerr); return 0; break;; | |||
955 | ||||
956 | case PROTOCOL_BINARY_CMD_UNLOCK_KEY: | |||
957 | INVOKE_OP(H_unlock)H_unlock(pipeline, req, res, immerr); return 0; break;; | |||
958 | ||||
959 | case PROTOCOL_BINARY_CMD_DELETE: | |||
960 | INVOKE_OP(H_delete)H_delete(pipeline, req, res, immerr); return 0; break;; | |||
961 | ||||
962 | case PROTOCOL_BINARY_CMD_TOUCH: | |||
963 | INVOKE_OP(H_touch)H_touch(pipeline, req, res, immerr); return 0; break;; | |||
964 | ||||
965 | case PROTOCOL_BINARY_CMD_OBSERVE_SEQNO: | |||
966 | INVOKE_OP(H_observe_seqno)H_observe_seqno(pipeline, req, res, immerr); return 0; break;; | |||
967 | ||||
968 | case PROTOCOL_BINARY_CMD_STAT: | |||
969 | INVOKE_OP(H_stats)H_stats(pipeline, req, res, immerr); return 0; break;; | |||
970 | ||||
971 | case PROTOCOL_BINARY_CMD_FLUSH: | |||
972 | INVOKE_OP(H_flush)H_flush(pipeline, req, res, immerr); return 0; break;; | |||
973 | ||||
974 | case PROTOCOL_BINARY_CMD_VERSION: | |||
975 | INVOKE_OP(H_version)H_version(pipeline, req, res, immerr); return 0; break;; | |||
976 | ||||
977 | case PROTOCOL_BINARY_CMD_VERBOSITY: | |||
978 | INVOKE_OP(H_verbosity)H_verbosity(pipeline, req, res, immerr); return 0; break;; | |||
979 | ||||
980 | case PROTOCOL_BINARY_CMD_NOOP: | |||
981 | INVOKE_OP(H_noop)H_noop(pipeline, req, res, immerr); return 0; break;; | |||
982 | ||||
983 | case PROTOCOL_BINARY_CMD_GET_CLUSTER_CONFIG: | |||
984 | INVOKE_OP(H_config)H_config(pipeline, req, res, immerr); return 0; break;; | |||
985 | ||||
986 | default: | |||
987 | fprintf(stderrstderr, "COUCHBASE: Received unknown opcode=0x%x\n", res->opcode()); | |||
988 | return -1; | |||
989 | } | |||
990 | } | |||
991 | ||||
992 | const lcb_MUTATION_TOKEN * | |||
993 | lcb_resp_get_mutation_token(int cbtype, const lcb_RESPBASE *rb) | |||
994 | { | |||
995 | const lcb_MUTATION_TOKEN *ss = NULL__null; | |||
996 | if ((rb->rflags & LCB_RESP_F_EXTDATA) == 0) { | |||
997 | return NULL__null; | |||
998 | } | |||
999 | ||||
1000 | switch (cbtype) { | |||
1001 | case LCB_CALLBACK_STORE: | |||
1002 | ss = ResponsePack<lcb_RESPSTORE>::get_mt(rb); | |||
1003 | break; | |||
1004 | ||||
1005 | case LCB_CALLBACK_COUNTER: | |||
1006 | ss = ResponsePack<lcb_RESPCOUNTER>::get_mt(rb); | |||
1007 | break; | |||
1008 | ||||
1009 | case LCB_CALLBACK_REMOVE: | |||
1010 | ss = ResponsePack<lcb_RESPREMOVE>::get_mt(rb); | |||
1011 | break; | |||
1012 | ||||
1013 | case LCB_CALLBACK_SDMUTATE: | |||
1014 | ss = ResponsePack<lcb_RESPSUBDOC>::get_mt(rb); | |||
1015 | break; | |||
1016 | ||||
1017 | default: | |||
1018 | return NULL__null; | |||
1019 | } | |||
1020 | ||||
1021 | if (ss->uuid_ == 0 && ss->seqno_ == 0) { | |||
1022 | return NULL__null; | |||
1023 | } | |||
1024 | return ss; | |||
1025 | } | |||
1026 | ||||
1027 | #define ERRINFO_CALLBACKS(X)X(LCB_CALLBACK_GET, lcb_RESPGET) X(LCB_CALLBACK_STORE, lcb_RESPSTORE ) X(LCB_CALLBACK_COUNTER, lcb_RESPCOUNTER) X(LCB_CALLBACK_TOUCH , lcb_RESPTOUCH) X(LCB_CALLBACK_REMOVE, lcb_RESPREMOVE) X(LCB_CALLBACK_UNLOCK , lcb_RESPUNLOCK) X(LCB_CALLBACK_SDLOOKUP, lcb_RESPSUBDOC) X( LCB_CALLBACK_SDMUTATE, lcb_RESPSUBDOC) \ | |||
1028 | X(LCB_CALLBACK_GET, lcb_RESPGET) \ | |||
1029 | X(LCB_CALLBACK_STORE, lcb_RESPSTORE) \ | |||
1030 | X(LCB_CALLBACK_COUNTER, lcb_RESPCOUNTER) \ | |||
1031 | X(LCB_CALLBACK_TOUCH, lcb_RESPTOUCH) \ | |||
1032 | X(LCB_CALLBACK_REMOVE, lcb_RESPREMOVE) \ | |||
1033 | X(LCB_CALLBACK_UNLOCK, lcb_RESPUNLOCK) \ | |||
1034 | X(LCB_CALLBACK_SDLOOKUP, lcb_RESPSUBDOC) \ | |||
1035 | X(LCB_CALLBACK_SDMUTATE, lcb_RESPSUBDOC) \ | |||
1036 | ||||
1037 | ||||
1038 | LIBCOUCHBASE_API__attribute__ ((visibility("default"))) | |||
1039 | const char * | |||
1040 | lcb_resp_get_error_context(int cbtype, const lcb_RESPBASE *rb) | |||
1041 | { | |||
1042 | if ((rb->rflags & LCB_RESP_F_ERRINFO) == 0) { | |||
1043 | return NULL__null; | |||
1044 | } | |||
1045 | ||||
1046 | #define X(CBTYPE, RESP) if (cbtype == CBTYPE) { return ResponsePack<RESP>::get_err_ctx(rb); } | |||
1047 | ERRINFO_CALLBACKS(X)X(LCB_CALLBACK_GET, lcb_RESPGET) X(LCB_CALLBACK_STORE, lcb_RESPSTORE ) X(LCB_CALLBACK_COUNTER, lcb_RESPCOUNTER) X(LCB_CALLBACK_TOUCH , lcb_RESPTOUCH) X(LCB_CALLBACK_REMOVE, lcb_RESPREMOVE) X(LCB_CALLBACK_UNLOCK , lcb_RESPUNLOCK) X(LCB_CALLBACK_SDLOOKUP, lcb_RESPSUBDOC) X( LCB_CALLBACK_SDMUTATE, lcb_RESPSUBDOC); | |||
1048 | #undef X | |||
1049 | return NULL__null; | |||
1050 | } | |||
1051 | ||||
1052 | LIBCOUCHBASE_API__attribute__ ((visibility("default"))) | |||
1053 | const char * | |||
1054 | lcb_resp_get_error_ref(int cbtype, const lcb_RESPBASE *rb) | |||
1055 | { | |||
1056 | if ((rb->rflags & LCB_RESP_F_ERRINFO) == 0) { | |||
1057 | return NULL__null; | |||
1058 | } | |||
1059 | ||||
1060 | #define X(CBTYPE, RESP) if (cbtype == CBTYPE) { return ResponsePack<RESP>::get_err_ref(rb); } | |||
1061 | ERRINFO_CALLBACKS(X)X(LCB_CALLBACK_GET, lcb_RESPGET) X(LCB_CALLBACK_STORE, lcb_RESPSTORE ) X(LCB_CALLBACK_COUNTER, lcb_RESPCOUNTER) X(LCB_CALLBACK_TOUCH , lcb_RESPTOUCH) X(LCB_CALLBACK_REMOVE, lcb_RESPREMOVE) X(LCB_CALLBACK_UNLOCK , lcb_RESPUNLOCK) X(LCB_CALLBACK_SDLOOKUP, lcb_RESPSUBDOC) X( LCB_CALLBACK_SDMUTATE, lcb_RESPSUBDOC); | |||
1062 | #undef X | |||
1063 | return NULL__null; | |||
1064 | } |