mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
Move handleClientsWithPendingWrites() in networking.c.
This commit is contained in:
parent
1c7d87df0c
commit
481a0db315
@ -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;
|
||||
|
28
src/server.c
28
src/server.c
@ -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. */
|
||||
|
@ -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, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user