Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary system calls in redisAsyncCommand() #1089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions async.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,17 @@ static int __redisAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void
}
}

/* We know the previous write was partial if there is data in the output
* buffer. So, we wait for a write event to write to the socket. Otherwise,
* we can directly write data to the socket. */
int pending_write = (sdslen(c->obuf) != 0);

__redisAppendCommand(c,cmd,len);

/* Always schedule a write when the write buffer is non-empty */
_EL_ADD_WRITE(ac);
if (!pending_write)
redisAsyncWrite(ac);
else
_EL_ADD_WRITE(ac);

return REDIS_OK;
oom:
Expand Down