-
Notifications
You must be signed in to change notification settings - Fork 9
fix: --count exists without waiting for extra input message #182
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
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -741,29 +741,24 @@ io_write(struct nmsg_io_thr *iothr, struct nmsg_io_output *io_output, | |
| nmsg_io_t io = iothr->io; | ||
| nmsg_res res; | ||
|
|
||
| /* It's possible a set "count" has been reached. */ | ||
| check_close_event(iothr, io_output, 1); | ||
|
|
||
| if (io->stop) { | ||
| reset_close_event(iothr, io_output); | ||
| nmsg_message_destroy(&msg); | ||
| return (nmsg_res_stop); | ||
| } | ||
|
|
||
| res = nmsg_output_write(io_output->output, msg); | ||
| if (io_output->output->type != nmsg_output_type_callback) | ||
| nmsg_message_destroy(&msg); | ||
|
|
||
| /* | ||
| * Reset only after the write, in case another thread invokes | ||
| * check_close_event and makes changes to io_output in the meantime. | ||
| */ | ||
| reset_close_event(iothr, io_output); | ||
|
|
||
| if (res != nmsg_res_success) | ||
| return (res); | ||
|
|
||
| atomic_fetch_add_explicit(&io->io_count_nmsg_payload_out, 1, memory_order_relaxed); | ||
|
|
||
| /* It's possible a set "count" has been reached. */ | ||
| check_close_event(iothr, io_output, 1); | ||
| reset_close_event(iothr, io_output); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change results in However, they were affirmatively separated at the last refactor of this code: before commit 77f40, |
||
|
|
||
| if (io->stop) { | ||
| // nmsg_message_destroy(&msg); | ||
| return (nmsg_res_stop); | ||
| } | ||
|
|
||
| return (res); | ||
| } | ||
|
|
@@ -797,6 +792,8 @@ check_close_event(struct nmsg_io_thr *iothr, struct nmsg_io_output *io_output, u | |
| if (io->count > 0 && io_output->count_next_close == 0) | ||
| io_output->count_next_close = io->count; | ||
|
|
||
| io_output->count_nmsg_payload_out += count; | ||
|
|
||
| if (io->count > 0 && | ||
| io_output->count_nmsg_payload_out == io_output->count_next_close) | ||
| { | ||
|
|
@@ -856,13 +853,6 @@ check_close_event(struct nmsg_io_thr *iothr, struct nmsg_io_output *io_output, u | |
| } | ||
|
|
||
| out: | ||
| /* | ||
| * This incr is implicitly locked IF it's used, and this counter is | ||
| * only used IF io->count > 0; that condition results in an acquired | ||
| * lock at the beginning of this function. | ||
| */ | ||
| io_output->count_nmsg_payload_out += count; | ||
|
|
||
| if (io->close_fp != NULL || io->count > 0) | ||
| pthread_mutex_unlock(&io_output->lock); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit adds stray whitespace on this and one other line, a common editor artifact.
git diff --checkwill show these before adding, andgit diff --cached --checkwill show these before committing. I have the latter set up in a pre-commit hook script so I don't forget myself :)