Streams: fix lp-count field for non-same-fields entries.

This commit is contained in:
antirez 2017-11-21 22:21:37 +01:00
parent 9bb18e5438
commit 115d076d65

View File

@ -308,8 +308,12 @@ int streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id,
} }
/* Compute and store the lp-count field. */ /* Compute and store the lp-count field. */
int lp_count = numfields; int lp_count = numfields;
if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) lp_count *= 2; lp_count += 3; /* Add the 3 fixed fields flags + ms-diff + seq-diff. */
lp_count += 3; /* Add the 3 fixed fileds flags + ms-diff + seq-diff. */ if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) {
/* If the item is not compressed, it also has the fields other than
* the values, and an additional num-fileds field. */
lp_count += numfields+1;
}
lp = lpAppendInteger(lp,lp_count); lp = lpAppendInteger(lp,lp_count);
/* Insert back into the tree in order to update the listpack pointer. */ /* Insert back into the tree in order to update the listpack pointer. */