| 2570 | } |
| 2571 | |
| 2572 | void parseClientCommandBuffer(client *c) { |
| 2573 | if (!FClientReady(c)) |
| 2574 | return; |
| 2575 | |
| 2576 | while(c->qb_pos < sdslen(c->querybuf)) { |
| 2577 | /* Determine request type when unknown. */ |
| 2578 | if (!c->reqtype) { |
| 2579 | if (c->querybuf[c->qb_pos] == '*') { |
| 2580 | c->reqtype = PROTO_REQ_MULTIBULK; |
| 2581 | } else { |
| 2582 | c->reqtype = PROTO_REQ_INLINE; |
| 2583 | } |
| 2584 | } |
| 2585 | |
| 2586 | size_t cqueriesStart = c->vecqueuedcmd.size(); |
| 2587 | if (c->reqtype == PROTO_REQ_INLINE) { |
| 2588 | if (processInlineBuffer(c) != C_OK) break; |
| 2589 | } else if (c->reqtype == PROTO_REQ_MULTIBULK) { |
| 2590 | if (processMultibulkBuffer(c) != C_OK) break; |
| 2591 | } else { |
| 2592 | serverPanic("Unknown request type"); |
| 2593 | } |
| 2594 | if (!c->vecqueuedcmd.empty() && (c->vecqueuedcmd.back().argc <= 0 || c->vecqueuedcmd.back().argv == nullptr)) { |
| 2595 | c->vecqueuedcmd.pop_back(); |
| 2596 | } else if (!c->vecqueuedcmd.empty()) { |
| 2597 | if (c->flags & CLIENT_MASTER) c->vecqueuedcmd.back().reploff = c->read_reploff - sdslen(c->querybuf) + c->qb_pos; |
| 2598 | serverAssert(c->vecqueuedcmd.back().reploff >= 0); |
| 2599 | } |
| 2600 | |
| 2601 | /* Prefetch outside the lock for better perf */ |
| 2602 | if (g_pserver->prefetch_enabled && (cserver.cthreads > 1 || g_pserver->m_pstorageFactory) && cqueriesStart < c->vecqueuedcmd.size() && |
| 2603 | (g_pserver->m_pstorageFactory || aeLockContested(cserver.cthreads/2) || cserver.cthreads == 1) && !GlobalLocksAcquired()) { |
| 2604 | auto &query = c->vecqueuedcmd.back(); |
| 2605 | if (query.argc > 0 && query.argc == query.argcMax) { |
| 2606 | c->db->prefetchKeysAsync(c, query); |
| 2607 | } |
| 2608 | } |
| 2609 | c->reqtype = 0; |
| 2610 | c->multibulklen = 0; |
| 2611 | c->bulklen = -1; |
| 2612 | c->reqtype = 0; |
| 2613 | } |
| 2614 | |
| 2615 | /* Trim to pos */ |
| 2616 | if (c->qb_pos) { |
| 2617 | sdsrange(c->querybuf,c->qb_pos,-1); |
| 2618 | c->qb_pos = 0; |
| 2619 | } |
| 2620 | } |
| 2621 | |
| 2622 | bool FAsyncCommand(parsed_command &cmd) |
| 2623 | { |
no test coverage detected