MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setProtocolError

Function setProtocolError

app/redis-6.2.6/src/networking.c:1801–1828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1799 * CLIENT_PROTOCOL_ERROR. */
1800#define PROTO_DUMP_LEN 128
1801static void setProtocolError(const char *errstr, client *c) {
1802 if (server.verbosity <= LL_VERBOSE || c->flags & CLIENT_MASTER) {
1803 sds client = catClientInfoString(sdsempty(),c);
1804
1805 /* Sample some protocol to given an idea about what was inside. */
1806 char buf[256];
1807 if (sdslen(c->querybuf)-c->qb_pos < PROTO_DUMP_LEN) {
1808 snprintf(buf,sizeof(buf),"Query buffer during protocol error: '%s'", c->querybuf+c->qb_pos);
1809 } else {
1810 snprintf(buf,sizeof(buf),"Query buffer during protocol error: '%.*s' (... more %zu bytes ...) '%.*s'", PROTO_DUMP_LEN/2, c->querybuf+c->qb_pos, sdslen(c->querybuf)-c->qb_pos-PROTO_DUMP_LEN, PROTO_DUMP_LEN/2, c->querybuf+sdslen(c->querybuf)-PROTO_DUMP_LEN/2);
1811 }
1812
1813 /* Remove non printable chars. */
1814 char *p = buf;
1815 while (*p != '\0') {
1816 if (!isprint(*p)) *p = '.';
1817 p++;
1818 }
1819
1820 /* Log all the client and protocol info. */
1821 int loglevel = (c->flags & CLIENT_MASTER) ? LL_WARNING :
1822 LL_VERBOSE;
1823 serverLog(loglevel,
1824 "Protocol error (%s) from client: %s. %s", errstr, client, buf);
1825 sdsfree(client);
1826 }
1827 c->flags |= (CLIENT_CLOSE_AFTER_REPLY|CLIENT_PROTOCOL_ERROR);
1828}
1829
1830/* Process the query buffer for client 'c', setting up the client argument
1831 * vector for command execution. Returns C_OK if after running the function

Callers 2

processInlineBufferFunction · 0.85
processMultibulkBufferFunction · 0.85

Calls 6

catClientInfoStringFunction · 0.85
sdsemptyFunction · 0.85
sdslenFunction · 0.85
snprintfFunction · 0.85
isprintFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected