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
481a0db3
Commit
481a0db3
authored
Sep 28, 2015
by
antirez
Browse files
Move handleClientsWithPendingWrites() in networking.c.
parent
1c7d87df
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
481a0db3
...
...
@@ -900,6 +900,34 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
}
}
/* This function is called just before entering the event loop, in the hope
* we can just write the replies to the client output buffer without any
* need to use a syscall in order to install the writable event handler,
* get it called, and so forth. */
void
handleClientsWithPendingWrites
(
void
)
{
listIter
li
;
listNode
*
ln
;
listRewind
(
server
.
clients_pending_write
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
client
*
c
=
listNodeValue
(
ln
);
c
->
flags
&=
~
CLIENT_PENDING_WRITE
;
listDelNode
(
server
.
clients_pending_write
,
ln
);
/* Try to write buffers to the client socket. */
sendReplyToClient
(
server
.
el
,
c
->
fd
,
c
,
0
);
/* If there is nothing left, do nothing. Otherwise install
* the write handler. */
if
((
c
->
bufpos
||
listLength
(
c
->
reply
))
&&
aeCreateFileEvent
(
server
.
el
,
c
->
fd
,
AE_WRITABLE
,
sendReplyToClient
,
c
)
==
AE_ERR
)
{
freeClientAsync
(
c
);
}
}
}
/* resetClient prepare the client to process the next command */
void
resetClient
(
client
*
c
)
{
redisCommandProc
*
prevcmd
=
c
->
cmd
?
c
->
cmd
->
proc
:
NULL
;
...
...
src/server.c
View file @
481a0db3
...
...
@@ -1274,34 +1274,6 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
return
1000
/
server
.
hz
;
}
/* This function is called just before entering the event loop, in the hope
* we can just write the replies to the client output buffer without any
* need to use a syscall in order to install the writable event handler,
* get it called, and so forth. */
void
handleClientsWithPendingWrites
(
void
)
{
listIter
li
;
listNode
*
ln
;
listRewind
(
server
.
clients_pending_write
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
client
*
c
=
listNodeValue
(
ln
);
c
->
flags
&=
~
CLIENT_PENDING_WRITE
;
listDelNode
(
server
.
clients_pending_write
,
ln
);
/* Try to write buffers to the client socket. */
sendReplyToClient
(
server
.
el
,
c
->
fd
,
c
,
0
);
/* If there is nothing left, do nothing. Otherwise install
* the write handler. */
if
((
c
->
bufpos
||
listLength
(
c
->
reply
))
&&
aeCreateFileEvent
(
server
.
el
,
c
->
fd
,
AE_WRITABLE
,
sendReplyToClient
,
c
)
==
AE_ERR
)
{
freeClientAsync
(
c
);
}
}
}
/* This function gets called every time Redis is entering the
* main loop of the event driven library, that is, before to sleep
* for ready file descriptors. */
...
...
src/server.h
View file @
481a0db3
...
...
@@ -1110,6 +1110,7 @@ int listenToPort(int port, int *fds, int *count);
void
pauseClients
(
mstime_t
duration
);
int
clientsArePaused
(
void
);
int
processEventsWhileBlocked
(
void
);
void
handleClientsWithPendingWrites
(
void
);
#ifdef __GNUC__
void
addReplyErrorFormat
(
client
*
c
,
const
char
*
fmt
,
...)
...
...
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