Skip to content

Commit 8f936a8

Browse files
ggouaillardetrhc54
authored andcommitted
iof/hnp: correctly handle short write to stdin
when a short write occurs, on top of adjusting the data, also adjust the number of bytes to be sent Refs openpmix#2220 Thanks Kim Doyoung for raising this issue on Stack Overflow Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent ce818cd commit 8f936a8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/mca/iof/hnp/iof_hnp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ static void stdin_write_handler(int fd, short event, void *cbdata)
456456
PMIX_OUTPUT_VERBOSE((1, prte_iof_base_framework.framework_output,
457457
"%s hnp:stdin:write:handler incomplete write %d - adjusting data",
458458
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), num_written));
459-
/* incomplete write - adjust data to avoid duplicate output */
460-
memmove(output->data, &output->data[num_written], output->numbytes - num_written);
459+
/* incomplete write - adjust data and count to avoid duplicate output */
460+
output->numbytes -= num_written;
461+
memmove(output->data, &output->data[num_written], output->numbytes);
461462
/* push this item back on the front of the list */
462463
pmix_list_prepend(&wev->outputs, item);
463464
/* leave the write event running so it will call us again

0 commit comments

Comments
 (0)