Skip to content

Conversation

@andrewthad
Copy link

The recv subcommand has a mistake that can cause it to truncate messages when outputting them. It ignores error codes and doesn't call write in a loop to write out the entirety of the buffer. This PR fixes that mistake. Additionally, it adds support for a "no delimiter" option, selected with the character x.

I've not actually tested this yet, so don't merge this. I'm just planning on using this in a one-off script where the output is piped to curl, and I noticed that the output would occasionally be wrong.

@andrewthad
Copy link
Author

I've confirmed that these changes work.

@goeb
Copy link
Owner

goeb commented Aug 17, 2022

Could you please give more context and details to clarify why the write() function was interrupted before writing all bytes? (does the mq process receive signals, ...)
Do you have a minimal and reproducible example?

@andrewthad
Copy link
Author

It doesn't receive any signals. I just thought it would be good for it to be correct in that case, but I can back that change out if you prefer. Or I could just change it to fail loudly if it doesn't write all the bytes on the first attempt.

@goeb
Copy link
Owner

goeb commented Aug 21, 2022

I agree with the no-delimiter option ('x'). Why didn't you apply it to the cmd_recv_follow() function ?

But I do not agree with how you handle a hypothetical partial write. As we do not know what could cause a partial write, it is hard to handle it and avoid an infinite loop or a long blocking. I prefer the program to fail with an error message.

For the naming of your variables, please use lower_case_with_underscore.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants