Skip to content

Commit 97f94c5

Browse files
authored
Merge pull request #4763 from ggouaillardet/topic/v3.0.x/iof
iof: do not release a sink before all read data is written.
2 parents 733c3ce + d6fcd47 commit 97f94c5

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

orte/mca/iof/base/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ typedef struct {
103103
orte_iof_write_event_t *wev;
104104
bool xoff;
105105
bool exclusive;
106+
bool closed;
106107
} orte_iof_sink_t;
107108
ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_iof_sink_t);
108109

orte/mca/iof/base/iof_base_frame.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ static void orte_iof_base_sink_construct(orte_iof_sink_t* ptr)
250250
ptr->wev = OBJ_NEW(orte_iof_write_event_t);
251251
ptr->xoff = false;
252252
ptr->exclusive = false;
253+
ptr->closed = false;
253254
}
254255
static void orte_iof_base_sink_destruct(orte_iof_sink_t* ptr)
255256
{

orte/mca/iof/hnp/iof_hnp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2017 Research Organization for Information Science
16+
* Copyright (c) 2014-2018 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
1919
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
@@ -629,6 +629,10 @@ static void stdin_write_handler(int fd, short event, void *cbdata)
629629
ORTE_IOF_READ_ACTIVATE(mca_iof_hnp_component.stdinev);
630630
}
631631
}
632+
if (sink->closed && 0 == opal_list_get_size(&wev->outputs)) {
633+
/* the sink has already been closed and everything was written, time to release it */
634+
OBJ_RELEASE(sink);
635+
}
632636
return;
633637
finish:
634638
OBJ_RELEASE(wev);

orte/mca/iof/hnp/iof_hnp_read.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* reserved.
1515
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
17+
* Copyright (c) 2018 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -202,8 +204,13 @@ void orte_iof_hnp_read_local_handler(int fd, short event, void *cbdata)
202204

203205
/* if num_bytes was zero, or we read the last piece of the file, then we need to terminate the event */
204206
if (0 == numbytes) {
205-
/* this will also close our stdin file descriptor */
206-
OBJ_RELEASE(proct->stdinev);
207+
if (0 != opal_list_get_size(&proct->stdinev->wev->outputs)) {
208+
/* some stuff has yet to be written, so delay the release of proct->stdinev */
209+
proct->stdinev->closed = true;
210+
} else {
211+
/* this will also close our stdin file descriptor */
212+
OBJ_RELEASE(proct->stdinev);
213+
}
207214
} else {
208215
/* if we are looking at a tty, then we just go ahead and restart the
209216
* read event assuming we are not backgrounded

0 commit comments

Comments
 (0)