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

Problem: zmq_msg_send doc incorrect for large messages. #2488

Closed
evoskuil opened this issue Mar 31, 2017 · 3 comments
Closed

Problem: zmq_msg_send doc incorrect for large messages. #2488

evoskuil opened this issue Mar 31, 2017 · 3 comments

Comments

@evoskuil
Copy link
Contributor

Documentation for zmq_msg_send states:

"Return value

The zmq_msg_send() function shall return number of bytes in the message if successful. Otherwise it shall return -1 and set errno to one of the values defined below."

However due to the implementation:

s_sendmsg (zmq::socket_base_t *s_, zmq_msg_t *msg_, int flags_)
{
    size_t sz = zmq_msg_size (msg_);
    int rc = s_->send ((zmq::msg_t *) msg_, flags_);
    if (unlikely (rc < 0))
        return -1;

    size_t max_msgsz = INT_MAX;
    return (int) (sz < max_msgsz? sz: max_msgsz);
}

the documentation is incorrect for any message of size that exceeds INT_MAX. Either the documentation should be changed to indicate that the return is set to INT_MAX in the case of success for such messages, or the implementation should be changed to limit message size accordingly. Otherwise behavior in these cases is ambiguous to the API caller.

@evoskuil evoskuil changed the title Problem: send documentation incorrect for large messages. Problem: send doc incorrect for large messages. Mar 31, 2017
@evoskuil evoskuil changed the title Problem: send doc incorrect for large messages. Problem: zmq_msg_send doc incorrect for large messages. Mar 31, 2017
@bluca
Copy link
Member

bluca commented Mar 31, 2017

The documentation should be fixed I think, the problem if I remember correctly is that the value would just be truncated if higher than INT_MAX given the API returns an int.
I sincerely hope nobody ever has to send 2 gigabytes of data in a single message though :-)

antonrd added a commit to antonrd/libzmq that referenced this issue Oct 1, 2018
…urn value is MAX_INT and if more than this number of bytes are to be sent the function will not return the actual number of bytes. This is related to issue zeromq#2488.
antonrd added a commit to antonrd/libzmq that referenced this issue Oct 1, 2018
…eromq#2488)

Solution: Add more information to the doc specifying that MAX_INT is the maximum
possible return value.
@bluca
Copy link
Member

bluca commented Oct 1, 2018

Fixed by #3266

@bluca bluca closed this as completed Oct 1, 2018
glemercier pushed a commit to glemercier/libzmq that referenced this issue Oct 7, 2018
…eromq#2488)

Solution: Add more information to the doc specifying that MAX_INT is the maximum
possible return value.
MohammadAlTurany pushed a commit to FairRootGroup/libzmq that referenced this issue Jan 28, 2019
…eromq#2488)

Solution: Add more information to the doc specifying that MAX_INT is the maximum
possible return value.
@akropp
Copy link

akropp commented Apr 9, 2024

The documentation should be fixed I think, the problem if I remember correctly is that the value would just be truncated if higher than INT_MAX given the API returns an int. I sincerely hope nobody ever has to send 2 gigabytes of data in a single message though :-)

Actually, I just tried to send more than 2gb of data and hit the assertion in zmq.hpp that checks whether the return value from zmq_msg_recv matches the size of the message received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants