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

Extend Blocking SIGINT Fix to JSON and Presentation Inputs #170

Open
wants to merge 9 commits into
base: next
Choose a base branch
from

Conversation

kadealicious
Copy link
Contributor

@kadealicious kadealicious commented Jan 8, 2025

In MR #156, a bugfix was added to prevent NMSG inputs from blocking on SIGINT; this fix did not extend to JSON and Presentation inputs. That has been fixed here, and the same reviewers of that MR have also been added here.

I have also verified that this bug does not occur with PCAP, ZMQ, and socket inputs.

Note: The original unit test test-io/test_dummy() would fail if the value returned from nmsg_input_read() (and by extension _input_read_json()) was not nmsg_res_success or nmsg_res_eof. The ideal solution to this, as discussed by Stephen and I, is to adjust the unit test to call nmsg_input_read() again when nmsg_res_again is returned. The intention is that this is a backwards-compatible change that conveys more information to the caller of nmsg_input_read().

@@ -57,6 +57,15 @@ _input_json_read(nmsg_input_t input, nmsg_message_t *msg) {
struct nmsg_strbuf_storage sbs;
struct nmsg_strbuf *sb = _nmsg_strbuf_init(&sbs);

/* make sure our input is valid and that we have nothing to read */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that given that we will now have this exact code stanza in exactly 3 different places, it might be time to make a common function like nmsg_res input_can_read(int fd) ... maybe in nmsg/input.c ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea; done.

@kadealicious kadealicious requested a review from shw700 January 14, 2025 18:05
@kadealicious kadealicious force-pushed the sigint-json-pres-inputs branch from e9294bb to fd58770 Compare January 16, 2025 22:15
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