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

libsubprocess: Remove invalid EOF calculation #2230

Merged
merged 2 commits into from Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 13 additions & 31 deletions src/common/libsubprocess/local.c
Expand Up @@ -87,11 +87,10 @@ static void local_output (struct subprocess_channel *c,
flux_watcher_t *w, int revents,
flux_subprocess_output_f output_cb)
{
bool eof_set = false;

if (revents & FLUX_POLLIN) {
flux_buffer_t *fb;
bool eof_set = false;
if (!c->eof_sent_to_caller) {
flux_buffer_t *fb;

if (!(fb = flux_buffer_read_watcher_get_buffer (w))) {
flux_log_error (c->p->h, "flux_buffer_read_watcher_get_buffer");
Expand All @@ -107,41 +106,24 @@ static void local_output (struct subprocess_channel *c,

output_cb (c->p, c->name);

if (c->p->state == FLUX_SUBPROCESS_EXITED && !c->eof_sent_to_caller) {

if (!(fb = flux_buffer_read_watcher_get_buffer (w))) {
flux_log_error (c->p->h, "flux_buffer_read_watcher_get_buffer");
return;
}

if (!flux_buffer_bytes (fb)) {

output_cb (c->p, c->name);

c->eof_sent_to_caller = true;
eof_set = true;
c->p->channels_eof_sent++;
if (eof_set) {
flux_watcher_stop (w);

/* if the read pipe is ended, then we can go ahead and close
* the write side as well. Note that there is no need to
* "flush" the write buffer. If we've received the EOF on the
* read side, no more writes matter.
*/
if (c->flags & CHANNEL_WRITE) {
flux_watcher_stop (c->buffer_write_w);
c->closed = true;
}
}
}
else
flux_log_error (c->p->h, "flux_buffer_read_watcher on %s: 0x%X:",
c->name, revents);

if (eof_set) {
flux_watcher_stop (w);

/* if the read pipe is ended, then we can go ahead and close
* the write side as well. Note that there is no need to
* "flush" the write buffer. If we've received the EOF on the
* read side, no more writes matter.
*/
if (c->flags & CHANNEL_WRITE) {
flux_watcher_stop (c->buffer_write_w);
c->closed = true;
}
}

if (c->p->state == FLUX_SUBPROCESS_EXITED && c->eof_sent_to_caller)
subprocess_check_completed (c->p);
}
Expand Down
4 changes: 2 additions & 2 deletions t/t0005-rexec.t
Expand Up @@ -17,8 +17,8 @@ test_expect_success 'basic rexec functionality (process success)' '
${FLUX_BUILD_DIR}/t/rexec/rexec /bin/true
'

test_must_fail 'basic rexec functionality (process fail)' '
${FLUX_BUILD_DIR}/t/rexec/rexec /bin/false
test_expect_success 'basic rexec functionality (process fail)' '
! ${FLUX_BUILD_DIR}/t/rexec/rexec /bin/false
Copy link
Contributor

Choose a reason for hiding this comment

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

technically you want test_must_fail here, or maybe better yet test_expect_code 1 ...

Not a showstopper for a merge though

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw this error message pop up.

./sharness.sh: line 505: basic rexec functionality (process fail): command not found
test_must_fail: command not found: basic rexec functionality (process fail) 
	${FLUX_BUILD_DIR}/t/rexec/rexec /bin/false

It's when I realized, the mistake was I used test_must_fail as the primary uhhhh "expect" test call (i.e. test_expect_success, test_expect_failure). perhaps I should have done

test_expect_success 'basic rexec functionality (process fail)' '
	test_must_fail ${FLUX_BUILD_DIR}/t/rexec/rexec /bin/false

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is the suggested use of test_must_fail (and what I meant above. It is not suggested to use ! to negate exit status because it would register success even if the program crashed) Like I said though, not a huge deal.

test_expect_code 1 .. would also work here.

'

test_expect_success 'basic rexec - cwd correct' '
Expand Down