MCPcopy Create free account
hub / github.com/MariaDB/server / response_recv

Method response_recv

plugin/handler_socket/libhsclient/hstcpcli.cpp:326–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326int
327hstcpcli::response_recv(size_t& num_flds_r)
328{
329 if (error_code < 0) {
330 return error_code;
331 }
332 clear_error();
333 if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 ||
334 response_end_offset != 0) {
335 close();
336 return set_error(-1, "response_recv: protocol out of sync");
337 }
338 cur_row_offset = 0;
339 num_flds_r = num_flds = 0;
340 if (fd.get() < 0) {
341 return set_error(-1, "read: closed");
342 }
343 size_t offset = 0;
344 while (true) {
345 const char *const lbegin = readbuf.begin() + offset;
346 const char *const lend = readbuf.end();
347 const char *const nl = memchr_char(lbegin, '\n', lend - lbegin);
348 if (nl != 0) {
349 offset = (nl + 1) - readbuf.begin();
350 break;
351 }
352 if (read_more() <= 0) {
353 close();
354 return set_error(-1, "read: eof");
355 }
356 }
357 response_end_offset = offset;
358 --num_req_sent;
359 ++num_req_rcvd;
360 char *start = readbuf.begin();
361 char *const finish = start + response_end_offset - 1;
362 const size_t resp_code = read_ui32(start, finish);
363 skip_one(start, finish);
364 num_flds_r = num_flds = read_ui32(start, finish);
365 if (resp_code != 0) {
366 skip_one(start, finish);
367 char *const err_begin = start;
368 read_token(start, finish);
369 char *const err_end = start;
370 std::string e = std::string(err_begin, err_end - err_begin);
371 if (e.empty()) {
372 e = "unknown_error";
373 }
374 return set_error(resp_code, e);
375 }
376 cur_row_offset = start - readbuf.begin();
377 DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n",
378 std::string(readbuf.begin(), readbuf.begin() + response_end_offset)
379 .c_str(),
380 cur_row_offset, response_end_offset));
381 DBG(fprintf(stderr, "RES 0\n"));
382 return 0;
383}

Callers 8

hstcpcli_mainFunction · 0.80
runMethod · 0.80
op_insertMethod · 0.80
op_deleteMethod · 0.80
op_updateMethod · 0.80
op_readMethod · 0.80
op_readnolockMethod · 0.80
test_11Method · 0.80

Calls 10

memchr_charFunction · 0.85
read_ui32Function · 0.85
skip_oneFunction · 0.85
stringClass · 0.85
read_tokenFunction · 0.70
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45

Tested by 1

test_11Method · 0.64