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

Fix using mbuf after returning it to mbuf free list for redis mset. #461

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,3 +1,3 @@
language: c
script: bash ./travis.sh

sudo: required
Copy link
Contributor

@andyqzb andyqzb Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intention of this line?

8 changes: 6 additions & 2 deletions src/proto/nc_redis.c
Expand Up @@ -2293,6 +2293,7 @@ redis_copy_bulk(struct msg *dst, struct msg *src)
struct mbuf *mbuf, *nbuf;
uint8_t *p;
uint32_t len = 0;
uint32_t mlen = 0;
uint32_t bytes = 0;
rstatus_t status;

Expand Down Expand Up @@ -2328,13 +2329,16 @@ redis_copy_bulk(struct msg *dst, struct msg *src)

/* copy len bytes to dst */
for (; mbuf;) {
if (mbuf_length(mbuf) <= len) { /* steal this buf from src to dst */
mlen = mbuf_length(mbuf);
if (mlen <= len) { /* steal this buf from src to dst */
nbuf = STAILQ_NEXT(mbuf, next);
mbuf_remove(&src->mhdr, mbuf);
if (dst != NULL) {
mbuf_insert(&dst->mhdr, mbuf);
} else {
mbuf_put(mbuf);
}
len -= mbuf_length(mbuf);
len -= mlen;
mbuf = nbuf;
} else { /* split it */
if (dst != NULL) {
Expand Down