[zeromq-dev] minor patch for streamer/forwarder not setting more flag.

Martin Sustrik sustrik at moloch.sk
Sat Aug 14 12:22:46 CEST 2010


Jon,

Opps! I haven't realised this is missing. Thaks for the patch!

Martin

On 08/14/2010 10:49 AM, Jon Dyte wrote:
> please review, but it looks straightforward enough.
>
> diff --git a/src/forwarder.cpp b/src/forwarder.cpp
> index 503868b..e7f1eb9 100644
> --- a/src/forwarder.cpp
> +++ b/src/forwarder.cpp
> @@ -29,6 +29,9 @@ int zmq::forwarder (socket_base_t *insocket_,
> socket_base_t *outsocket_)
>       int rc = zmq_msg_init (&msg);
>       errno_assert (rc == 0);
>
> +    int64_t more;
> +    size_t more_sz = sizeof(more);
> +
>       while (true) {
>           rc = insocket_->recv (&msg, 0);
>           if (rc<  0) {
> @@ -37,7 +40,14 @@ int zmq::forwarder (socket_base_t *insocket_,
> socket_base_t *outsocket_)
>               errno_assert (false);
>           }
>
> -        rc = outsocket_->send (&msg, 0);
> +        rc = insocket_->getsockopt (ZMQ_RCVMORE,&more,&more_sz);
> +        if (rc<  0) {
> +            if (errno == ETERM)
> +                return -1;
> +            errno_assert (false);
> +        }
> +
> +        rc = outsocket_->send (&msg, more ? ZMQ_SNDMORE : 0);
>           if (rc<  0) {
>               if (errno == ETERM)
>                   return -1;
> diff --git a/src/streamer.cpp b/src/streamer.cpp
> index 9799007..22c8d42 100644
> --- a/src/streamer.cpp
> +++ b/src/streamer.cpp
> @@ -29,6 +29,9 @@ int zmq::streamer (socket_base_t *insocket_,
> socket_base_t *outsocket_)
>       int rc = zmq_msg_init (&msg);
>       errno_assert (rc == 0);
>
> +    int64_t more;
> +    size_t more_sz = sizeof(more);
> +
>       while (true) {
>           rc = insocket_->recv (&msg, 0);
>           if (rc<  0) {
> @@ -36,8 +39,15 @@ int zmq::streamer (socket_base_t *insocket_,
> socket_base_t *outsocket_)
>                   return -1;
>               errno_assert (false);
>           }
> +
> +        rc = insocket_->getsockopt (ZMQ_RCVMORE,&more,&more_sz);
> +        if (rc<  0) {
> +            if (errno == ETERM)
> +                return -1;
> +            errno_assert (false);
> +        }
>
> -        rc = outsocket_->send (&msg, 0);
> +        rc = outsocket_->send (&msg, more ? ZMQ_SNDMORE : 0);
>           if (rc<  0) {
>               if (errno == ETERM)
>                   return -1;
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>    




More information about the zeromq-dev mailing list