Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed a bug in the mtrie table compaction logic. #268

Merged
merged 1 commit into from

2 participants

@gimaker

Signed-off-by: Staffan Gimåker staffan@spotify.com

@gimaker gimaker Fixed a bug in the mtrie table compaction logic.
Signed-off-by: Staffan Gimåker <staffan@spotify.com>
3485b3e
@ianbarber ianbarber merged commit 3f8322b into zeromq:master
@hurtonm hurtonm referenced this pull request from a commit in hurtonm/libzmq
@hurtonm hurtonm Fix issue #268
This patch fixes a bug in the message encoder which was
responsible for computing incorrect message offset.
The bug affected PGM receiver making it unable to
decode inital messages.
3d93c1a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2012
  1. @gimaker

    Fixed a bug in the mtrie table compaction logic.

    gimaker authored
    Signed-off-by: Staffan Gimåker <staffan@spotify.com>
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 5 deletions.
  1. +12 −5 src/mtrie.cpp
View
17 src/mtrie.cpp
@@ -200,16 +200,16 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
// If there are multiple subnodes.
//
// New min non-null character in the node table after the removal
- unsigned char new_min = min;
+ unsigned char new_min = min + count - 1;
// New max non-null character in the node table after the removal
- unsigned char new_max = min + count - 1;
+ unsigned char new_max = min;
for (unsigned short c = 0; c != count; c++) {
(*buff_) [buffsize_] = min + c;
if (next.table [c]) {
next.table [c]->rm_helper (pipe_, buff_, buffsize_ + 1,
maxbuffsize_, func_, arg_);
- // Prune redudant nodes from the mtrie
+ // Prune redundant nodes from the mtrie
if (next.table [c]->is_redundant ()) {
delete next.table [c];
next.table [c] = 0;
@@ -218,9 +218,16 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
--live_nodes;
}
else {
- if (c + min > new_min)
+ // The node is not redundant, so it's a candidate for being
+ // the new min/max node.
+ //
+ // We loop through the node array from left to right, so the
+ // first non-null, non-redundant node encountered is the new
+ // minimum index. Conversely, the last non-redundant, non-null
+ // node encountered is the new maximum index.
+ if (c + min < new_min)
new_min = c + min;
- if (c + min < new_max)
+ if (c + min > new_max)
new_max = c + min;
}
}
Something went wrong with that request. Please try again.