summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-04-12 10:12:27 +0200
committerantirez <antirez@gmail.com>2017-04-12 10:12:27 +0200
commit1210af380429f2f96324f4c46a6aef7e4ddb7a3e (patch)
tree9ec35e0db79c8d8bca38486d33641ff2c253a600
parent4a850be4dc0709d66209e440315ca314a785e964 (diff)
downloadredis-1210af380429f2f96324f4c46a6aef7e4ddb7a3e.tar.gz
Add a top comment in crucial functions inside networking.c.
-rw-r--r--src/networking.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c
index 343a910e2..fbab9970f 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1027,6 +1027,13 @@ void resetClient(client *c) {
}
}
+/* Like processMultibulkBuffer(), but for the inline protocol instead of RESP,
+ * this function consumes the client query buffer and creates a command ready
+ * to be executed inside the client structure. Returns C_OK if the command
+ * is ready to be executed, or C_ERR if there is still protocol to read to
+ * have a well formed command. The function also returns C_ERR when there is
+ * a protocol error: in such a case the client structure is setup to reply
+ * with the error and close the connection. */
int processInlineBuffer(client *c) {
char *newline;
int argc, j;
@@ -1119,6 +1126,17 @@ static void setProtocolError(const char *errstr, client *c, int pos) {
sdsrange(c->querybuf,pos,-1);
}
+/* Process the query buffer for client 'c', setting up the client argument
+ * vector for command execution. Returns C_OK if after running the function
+ * the client has a well-formed ready to be processed command, otherwise
+ * C_ERR if there is still to read more buffer to get the full command.
+ * The function also returns C_ERR when there is a protocol error: in such a
+ * case the client structure is setup to reply with the error and close
+ * the connection.
+ *
+ * This function is called if processInputBuffer() detects that the next
+ * command is in RESP format, so the first byte in the command is found
+ * to be '*'. Otherwise for inline commands processInlineBuffer() is called. */
int processMultibulkBuffer(client *c) {
char *newline = NULL;
int pos = 0, ok;
@@ -1253,10 +1271,14 @@ int processMultibulkBuffer(client *c) {
/* We're done when c->multibulk == 0 */
if (c->multibulklen == 0) return C_OK;
- /* Still not read to process the command */
+ /* Still not ready to process the command */
return C_ERR;
}
+/* This function is called every time, in the client structure 'c', there is
+ * more query buffer to process, because we read more data from the socket
+ * or because a client was blocked and later reactivated, so there could be
+ * pending query buffer, already representing a full command, to process. */
void processInputBuffer(client *c) {
server.current_client = c;
/* Keep processing while there is something in the input buffer */