Skip to content

Commit 41f4225

Browse files
committed
Fix IOF of stdin
Ensure we properly terminate the stream when the input is complete Signed-off-by: Ralph Castain <[email protected]>
1 parent 7f458b5 commit 41f4225

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

src/common/pmix_iof.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntargets, pmix_b
664664

665665
/* if we are not a server, then we send the provided
666666
* data to our server for processing */
667-
if (!PMIX_PEER_IS_SERVER(pmix_globals.mypeer) || PMIX_PEER_IS_LAUNCHER(pmix_globals.mypeer)) {
667+
if (!PMIX_PEER_IS_SERVER(pmix_globals.mypeer) ||
668+
PMIX_PEER_IS_LAUNCHER(pmix_globals.mypeer)) {
668669
msg = PMIX_NEW(pmix_buffer_t);
669670
if (NULL == msg) {
670671
return PMIX_ERR_NOMEM;
@@ -1803,21 +1804,31 @@ void pmix_iof_read_local_handler(int sd, short args, void *cbdata)
18031804
goto reactivate;
18041805
}
18051806

1807+
/* if I am a launcher and connected to a server, then
1808+
* we want to send things to our server for relay */
1809+
if (PMIX_PEER_IS_LAUNCHER(pmix_globals.mypeer) &&
1810+
pmix_globals.connected) {
1811+
goto forward;
1812+
}
1813+
18061814
/* if I am a server, then push this up to my host */
1807-
if (PMIX_PROC_IS_SERVER(&pmix_globals.mypeer->proc_type)) {
1815+
if (PMIX_PEER_IS_SERVER(pmix_globals.mypeer)) {
18081816
if (NULL == pmix_host_server.push_stdin) {
18091817
/* nothing we can do with this info - no point in reactivating it */
18101818
return;
18111819
}
18121820
PMIX_BYTE_OBJECT_CREATE(boptr, 1);
1813-
boptr->bytes = (char*)malloc(bo.size);
1814-
memcpy(boptr->bytes, bo.bytes, bo.size);
1815-
boptr->size = bo.size;
1821+
if (0 < bo.size) {
1822+
boptr->bytes = (char*)malloc(bo.size);
1823+
memcpy(boptr->bytes, bo.bytes, bo.size);
1824+
boptr->size = bo.size;
1825+
}
18161826
rc = pmix_host_server.push_stdin(&pmix_globals.myid, rev->targets, rev->ntargets,
18171827
rev->directives, rev->ndirs, boptr, opcbfn, (void*)boptr);
18181828
goto reactivate;
18191829
}
18201830

1831+
forward:
18211832
/* pass the data to our PMIx server so it can relay it
18221833
* to the host RM for distribution */
18231834
msg = PMIX_NEW(pmix_buffer_t);
@@ -1911,11 +1922,13 @@ PMIX_CLASS_INSTANCE(pmix_iof_sink_t, pmix_list_item_t, iof_sink_construct, iof_s
19111922

19121923
static void iof_read_event_construct(pmix_iof_read_event_t *rev)
19131924
{
1925+
rev->tv.tv_sec = 0;
1926+
rev->tv.tv_usec = 0;
19141927
rev->fd = -1;
1928+
rev->channel = PMIX_FWD_NO_CHANNELS;
19151929
rev->active = false;
19161930
rev->childproc = NULL;
1917-
rev->tv.tv_sec = 0;
1918-
rev->tv.tv_usec = 0;
1931+
rev->always_readable = false;
19191932
rev->targets = NULL;
19201933
rev->ntargets = 0;
19211934
rev->directives = NULL;

src/mca/bfrops/base/bfrop_base_pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pmix_status_t pmix_bfrops_base_pack(pmix_pointer_array_t *regtypes, pmix_buffer_
4343
pmix_status_t rc;
4444

4545
/* check for error */
46-
if (NULL == buffer || NULL == src) {
46+
if (NULL == buffer || (NULL == src && 0 < num_vals)) {
4747
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM);
4848
return PMIX_ERR_BAD_PARAM;
4949
}

src/server/pmix_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void server_iof_handler(struct pmix_peer_t *pr, pmix_ptl_hdr_t *hdr,
159159

160160
PMIX_HIDE_UNUSED_PARAMS(hdr, cbdata);
161161

162-
pmix_output_verbose(2, pmix_client_globals.iof_output,
162+
pmix_output_verbose(2, pmix_server_globals.iof_output,
163163
"recvd IOF with %d bytes from %s",
164164
(int) buf->bytes_used,
165165
PMIX_PNAME_PRINT(&peer->info->pname));

src/server/pmix_server_ops.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,15 +3621,19 @@ static void stdcbfunc(pmix_status_t status, void *cbdata)
36213621
PMIX_RELEASE(cd);
36223622
}
36233623

3624-
pmix_status_t pmix_server_iofstdin(pmix_peer_t *peer, pmix_buffer_t *buf, pmix_op_cbfunc_t cbfunc,
3624+
pmix_status_t pmix_server_iofstdin(pmix_peer_t *peer,
3625+
pmix_buffer_t *buf,
3626+
pmix_op_cbfunc_t cbfunc,
36253627
void *cbdata)
36263628
{
36273629
int32_t cnt;
36283630
pmix_status_t rc;
36293631
pmix_proc_t source;
36303632
pmix_setup_caddy_t *cd;
36313633

3632-
pmix_output_verbose(2, pmix_server_globals.iof_output, "recvd stdin IOF data from tool");
3634+
pmix_output_verbose(2, pmix_server_globals.iof_output,
3635+
"recvd stdin IOF data from tool %s",
3636+
PMIX_PEER_PRINT(peer));
36333637

36343638
if (NULL == pmix_host_server.push_stdin) {
36353639
return PMIX_ERR_NOT_SUPPORTED;

0 commit comments

Comments
 (0)