Received messages are released too soon #2

merged 1 commit into from Apr 7, 2012


None yet

2 participants


while using the 0mq bindings to have some fun while learning racket, I think I found a small problem.
(socket-recv! sock) is releasing the received message too soon.

Its byte contents might be used by the caller after they were already released or reused by 0mq, this is particular true on high-rate scenarios with messages larger than just a few bytes.

The patch do the simplest fix: just copy the bytes.

A better API that lets the caller access the data without copying it, and then release the underling msg when done will be useful to avoid double-copying in many situations, being the caller's responsibility to copy the data somewhere if he need to access it latter. But that's beyond my current racket abilities ;)

@jeapostrophe jeapostrophe merged commit 7fd5945 into jeapostrophe:master Apr 7, 2012

Thanks so much. I think the better API you're thinking of is 0mq itself. socket-recv is just a convenience in Racket, so if it doesn't do the most efficient thing, the 0mq user should go directly to the API. In this case, your patch definitely fixes an error. Thank you!

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