Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
1210af38
Commit
1210af38
authored
Apr 12, 2017
by
antirez
Browse files
Add a top comment in crucial functions inside networking.c.
parent
4a850be4
Changes
1
Show whitespace changes
Inline
Side-by-side
src/networking.c
View file @
1210af38
...
@@ -1027,6 +1027,13 @@ void resetClient(client *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
)
{
int
processInlineBuffer
(
client
*
c
)
{
char
*
newline
;
char
*
newline
;
int
argc
,
j
;
int
argc
,
j
;
...
@@ -1119,6 +1126,17 @@ static void setProtocolError(const char *errstr, client *c, int pos) {
...
@@ -1119,6 +1126,17 @@ static void setProtocolError(const char *errstr, client *c, int pos) {
sdsrange
(
c
->
querybuf
,
pos
,
-
1
);
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
)
{
int
processMultibulkBuffer
(
client
*
c
)
{
char
*
newline
=
NULL
;
char
*
newline
=
NULL
;
int
pos
=
0
,
ok
;
int
pos
=
0
,
ok
;
...
@@ -1253,10 +1271,14 @@ int processMultibulkBuffer(client *c) {
...
@@ -1253,10 +1271,14 @@ int processMultibulkBuffer(client *c) {
/* We're done when c->multibulk == 0 */
/* We're done when c->multibulk == 0 */
if
(
c
->
multibulklen
==
0
)
return
C_OK
;
if
(
c
->
multibulklen
==
0
)
return
C_OK
;
/* Still not read to process the command */
/* Still not read
y
to process the command */
return
C_ERR
;
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
)
{
void
processInputBuffer
(
client
*
c
)
{
server
.
current_client
=
c
;
server
.
current_client
=
c
;
/* Keep processing while there is something in the input buffer */
/* Keep processing while there is something in the input buffer */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment