From 8ec0743c7551de3c76126d080961cece732370f1 Mon Sep 17 00:00:00 2001 From: Bernd Melchers Date: Thu, 2 Sep 2010 07:33:57 +0200 Subject: Fix for signaler_t on HP-UX and AIX platforms --- src/signaler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/signaler.cpp b/src/signaler.cpp index d65957e..d4a9214 100644 --- a/src/signaler.cpp +++ b/src/signaler.cpp @@ -184,7 +184,7 @@ void zmq::signaler_t::send (const command_t &cmd_) zmq_assert (nbytes == sizeof (command_t)); } -bool zmq::signaler_t::recv (command_t &cmd_, bool block_) +bool zmq::signaler_t::recv (command_t *cmd_, bool block_) { if (block_) { @@ -199,7 +199,7 @@ bool zmq::signaler_t::recv (command_t &cmd_, bool block_) bool result; ssize_t nbytes; do { - nbytes = ::recv (r, buffer, sizeof (command_t), 0); + nbytes = ::recv (r, (char*) cmd_, sizeof (command_t), 0); } while (nbytes == -1 && errno == EINTR); if (nbytes == -1 && errno == EAGAIN) { result = false; @@ -213,7 +213,7 @@ bool zmq::signaler_t::recv (command_t &cmd_, bool block_) result = true; } - if (block_) + if (block_) { // Set the reader to non-blocking mode. int flags = fcntl (r, F_GETFL, 0); -- cgit v1.2.3 From 14853c2db528b3fd6eed84786053549e71f61bb7 Mon Sep 17 00:00:00 2001 From: Jon Dyte Date: Thu, 2 Sep 2010 07:52:02 +0200 Subject: Prior to this patch prefix_tree asserts. This is because as it adds the 255th element at a node it attempts to calculate the count member var which is an unsigned char via count = (255 -0) + 1; and pass the result to realloc. Unfortunately the result is zero and realloc returns null; the prefix_tree asserts. I have fixed it by making the count an unsigned short. --- src/prefix_tree.cpp | 12 ++++++------ src/prefix_tree.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/prefix_tree.cpp b/src/prefix_tree.cpp index 51225d6..6d4f084 100644 --- a/src/prefix_tree.cpp +++ b/src/prefix_tree.cpp @@ -42,7 +42,7 @@ zmq::prefix_tree_t::~prefix_tree_t () if (count == 1) delete next.node; else if (count > 1) { - for (unsigned char i = 0; i != count; ++i) + for (unsigned short i = 0; i != count; ++i) if (next.table [i]) delete next.table [i]; free (next.table); @@ -74,7 +74,7 @@ void zmq::prefix_tree_t::add (unsigned char *prefix_, size_t size_) next.table = (prefix_tree_t**) malloc (sizeof (prefix_tree_t*) * count); zmq_assert (next.table); - for (unsigned char i = 0; i != count; ++i) + for (unsigned short i = 0; i != count; ++i) next.table [i] = 0; min = std::min (min, c); next.table [oldc - min] = oldp; @@ -82,25 +82,25 @@ void zmq::prefix_tree_t::add (unsigned char *prefix_, size_t size_) else if (min < c) { // The new character is above the current character range. - unsigned char old_count = count; + unsigned short old_count = count; count = c - min + 1; next.table = (prefix_tree_t**) realloc ((void*) next.table, sizeof (prefix_tree_t*) * count); zmq_assert (next.table); - for (unsigned char i = old_count; i != count; i++) + for (unsigned short i = old_count; i != count; i++) next.table [i] = NULL; } else { // The new character is below the current character range. - unsigned char old_count = count; + unsigned short old_count = count; count = (min + old_count) - c; next.table = (prefix_tree_t**) realloc ((void*) next.table, sizeof (prefix_tree_t*) * count); zmq_assert (next.table); memmove (next.table + min - c, next.table, old_count * sizeof (prefix_tree_t*)); - for (unsigned char i = 0; i != min - c; i++) + for (unsigned short i = 0; i != min - c; i++) next.table [i] = NULL; min = c; } diff --git a/src/prefix_tree.hpp b/src/prefix_tree.hpp index 53c7c18..bf1c4b9 100644 --- a/src/prefix_tree.hpp +++ b/src/prefix_tree.hpp @@ -42,7 +42,7 @@ namespace zmq uint32_t refcnt; unsigned char min; - unsigned char count; + unsigned short count; union { class prefix_tree_t *node; class prefix_tree_t **table; -- cgit v1.2.3