Skip to content

Commit 0daf8e2

Browse files
committed
Fix show_help output to include tools
Ensure that show_help is distributed to attached tools. Signed-off-by: Ralph Castain <[email protected]>
1 parent c9e3f09 commit 0daf8e2

File tree

4 files changed

+104
-85
lines changed

4 files changed

+104
-85
lines changed

src/mca/plog/base/plog_base_stubs.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, const pmix_info_t da
8585
return PMIX_ERR_INIT;
8686
}
8787

88+
/* if there is no data to output, then nothing to do */
89+
if (NULL == data) {
90+
return PMIX_OPERATION_SUCCEEDED;
91+
}
92+
8893
/* we have to serialize our way thru here as we are going
8994
* to construct a list of the available modules, and those
9095
* can only be on one list at a time */
@@ -142,9 +147,9 @@ pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, const pmix_info_t da
142147
}
143148
all_complete = false;
144149
for (m = 0; m < pmix_plog_globals.actives.size; m++) {
145-
if (NULL
146-
== (active = (pmix_plog_base_active_module_t *)
147-
pmix_pointer_array_get_item(&pmix_plog_globals.actives, m))) {
150+
active = (pmix_plog_base_active_module_t *)
151+
pmix_pointer_array_get_item(&pmix_plog_globals.actives, m);
152+
if (NULL == active) {
148153
continue;
149154
}
150155
/* if this channel is included in the ones serviced by this
@@ -177,8 +182,7 @@ pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, const pmix_info_t da
177182
}
178183
if (all_complete) {
179184
/* nothing we need do */
180-
while (NULL != pmix_list_remove_first(&channels))
181-
;
185+
while (NULL != pmix_list_remove_first(&channels));
182186
PMIX_DESTRUCT(&channels);
183187
PMIX_RELEASE(mycount);
184188
PMIX_RELEASE_THREAD(&pmix_plog_globals.lock);
@@ -254,8 +258,7 @@ pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, const pmix_info_t da
254258
}
255259

256260
/* cannot release the modules - just remove everything from the list */
257-
while (NULL != pmix_list_remove_first(&channels))
258-
;
261+
while (NULL != pmix_list_remove_first(&channels));
259262
PMIX_DESTRUCT(&channels);
260263

261264
rc = mycount->status; // save the status as it could change when the lock is released

src/mca/plog/default/plog_default.c

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
4343
void *cbdata);
4444

4545
/* Module def */
46-
pmix_plog_module_t pmix_plog_default_module = {.name = "default",
47-
.channels = NULL,
48-
.init = init,
49-
.finalize = NULL,
50-
.log = mylog};
46+
pmix_plog_module_t pmix_plog_default_module = {
47+
.name = "default",
48+
.channels = NULL,
49+
.init = init,
50+
.finalize = NULL,
51+
.log = mylog
52+
};
5153

5254
/* local object */
5355
typedef struct {
5456
pmix_object_t super;
55-
pmix_info_t *data;
57+
const pmix_info_t *data;
5658
size_t ndata;
5759
pmix_op_cbfunc_t cbfunc;
5860
void *cbdata;
@@ -62,13 +64,8 @@ static void lcon(local_caddy_t *p)
6264
p->data = NULL;
6365
p->ndata = 0;
6466
}
65-
static void ldes(local_caddy_t *p)
66-
{
67-
if (NULL != p->data) {
68-
PMIX_INFO_FREE(p->data, p->ndata);
69-
}
70-
}
71-
static PMIX_CLASS_INSTANCE(local_caddy_t, pmix_object_t, lcon, ldes);
67+
static PMIX_CLASS_INSTANCE(local_caddy_t, pmix_object_t,
68+
lcon, NULL);
7269

7370
static int init(void)
7471
{
@@ -94,19 +91,6 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
9491
void *cbdata)
9592
{
9693
local_caddy_t *cd;
97-
size_t ntodo, n;
98-
99-
/* if none of the prior modules performed a requested logging
100-
* operation, then we will try here */
101-
ntodo = 0;
102-
for (n = 0; n < ndata; n++) {
103-
if (!PMIX_INFO_OP_IS_COMPLETE(&data[n])) {
104-
++ntodo;
105-
}
106-
}
107-
if (0 == ntodo) {
108-
return PMIX_ERR_TAKE_NEXT_OPTION;
109-
}
11094

11195
/* send it upwards for potential handling. This might seem
11296
* odd in the case where we are a gateway, but we must allow
@@ -116,24 +100,11 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
116100
if (NULL == cd) {
117101
return PMIX_ERR_NOMEM;
118102
}
103+
cd->data = data;
104+
cd->ndata = ndata;
119105
cd->cbfunc = cbfunc;
120106
cd->cbdata = cbdata;
121107

122-
/* separate out the ones that weren't completed */
123-
PMIX_INFO_CREATE(cd->data, ntodo);
124-
if (NULL == cd->data) {
125-
PMIX_RELEASE(cd);
126-
return PMIX_ERR_NOMEM;
127-
}
128-
cd->ndata = ntodo;
129-
ntodo = 0;
130-
for (n = 0; n < ndata; n++) {
131-
if (!PMIX_INFO_OP_IS_COMPLETE(&data[n])) {
132-
PMIX_INFO_XFER(&cd->data[ntodo], (pmix_info_t *) &data[n]);
133-
++ntodo;
134-
}
135-
}
136-
137108
/* ask the host to log the remainder */
138109
pmix_host_server.log(source, cd->data, cd->ndata, directives, ndirs, localcbfn, (void *) cd);
139110

src/mca/plog/stdfd/plog_stdfd.c

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "pmix_config.h"
2323
#include "pmix_common.h"
24+
#include "pmix_server.h"
2425

2526
#include <string.h>
2627
#ifdef HAVE_SYS_TIME_H
@@ -45,10 +46,12 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
4546
void *cbdata);
4647

4748
/* Module def */
48-
pmix_plog_module_t pmix_plog_stdfd_module = {.name = "stdfd",
49-
.init = init,
50-
.finalize = finalize,
51-
.log = mylog};
49+
pmix_plog_module_t pmix_plog_stdfd_module = {
50+
.name = "stdfd",
51+
.init = init,
52+
.finalize = finalize,
53+
.log = mylog
54+
};
5255

5356
static int init(void)
5457
{
@@ -63,13 +66,45 @@ static void finalize(void)
6366
pmix_argv_free(pmix_plog_stdfd_module.channels);
6467
}
6568

69+
typedef struct{
70+
pmix_object_t super;
71+
pmix_proc_t source;
72+
pmix_byte_object_t bo;
73+
} pmix_iof_deliver_t;
74+
static void pdcon(pmix_iof_deliver_t *p)
75+
{
76+
p->bo.bytes = NULL;
77+
p->bo.size = 0;
78+
}
79+
static void pddes(pmix_iof_deliver_t *p)
80+
{
81+
if (NULL != p->bo.bytes) {
82+
free(p->bo.bytes);
83+
}
84+
}
85+
static PMIX_CLASS_INSTANCE(pmix_iof_deliver_t,
86+
pmix_object_t,
87+
pdcon, pddes);
88+
89+
static void lkcbfunc(pmix_status_t status, void *cbdata)
90+
{
91+
pmix_iof_deliver_t *p = (pmix_iof_deliver_t*)cbdata;
92+
93+
/* nothing to do here - we use this solely to
94+
* ensure that IOF_deliver doesn't block */
95+
if (PMIX_SUCCESS != status) {
96+
PMIX_ERROR_LOG(status);
97+
}
98+
PMIX_RELEASE(p);
99+
}
100+
66101
static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[], size_t ndata,
67102
const pmix_info_t directives[], size_t ndirs, pmix_op_cbfunc_t cbfunc,
68103
void *cbdata)
69104
{
70105
size_t n;
71106
pmix_status_t rc;
72-
pmix_byte_object_t bo;
107+
pmix_iof_deliver_t *p;
73108

74109
/* if there is no data, then we don't handle it */
75110
if (NULL == data || 0 == ndata) {
@@ -103,19 +138,27 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
103138
continue;
104139
}
105140
if (0 == strncmp(data[n].key, PMIX_LOG_STDERR, PMIX_MAX_KEYLEN)) {
106-
bo.bytes = data[n].value.data.string;
107-
bo.size = strlen(bo.bytes);
108-
pmix_iof_write_output(source, PMIX_FWD_STDERR_CHANNEL, &bo);
109-
/* flag that we did this one */
110-
PMIX_INFO_OP_COMPLETED(&data[n]);
111-
rc = PMIX_SUCCESS;
141+
p = PMIX_NEW(pmix_iof_deliver_t);
142+
PMIX_XFER_PROCID(&p->source, source);
143+
p->bo.size = strlen(data[n].value.data.string) + 1; // include NULL terminator
144+
p->bo.bytes = (char*)malloc(p->bo.size);
145+
memcpy(p->bo.bytes, data[n].value.data.string, p->bo.size);
146+
rc = PMIx_server_IOF_deliver(&p->source, PMIX_FWD_STDERR_CHANNEL, &p->bo, NULL, 0, lkcbfunc, (void*)p);
147+
if (PMIX_SUCCESS != rc) {
148+
PMIX_ERROR_LOG(rc);
149+
PMIX_RELEASE(p);
150+
}
112151
} else if (0 == strncmp(data[n].key, PMIX_LOG_STDOUT, PMIX_MAX_KEYLEN)) {
113-
bo.bytes = data[n].value.data.string;
114-
bo.size = strlen(bo.bytes);
115-
pmix_iof_write_output(source, PMIX_FWD_STDOUT_CHANNEL, &bo);
116-
/* flag that we did this one */
117-
PMIX_INFO_OP_COMPLETED(&data[n]);
118-
rc = PMIX_SUCCESS;
152+
p = PMIX_NEW(pmix_iof_deliver_t);
153+
PMIX_XFER_PROCID(&p->source, source);
154+
p->bo.size = strlen(data[n].value.data.string) + 1; // include NULL terminator
155+
p->bo.bytes = (char*)malloc(p->bo.size);
156+
memcpy(p->bo.bytes, data[n].value.data.string, p->bo.size);
157+
rc = PMIx_server_IOF_deliver(&p->source, PMIX_FWD_STDOUT_CHANNEL, &p->bo, NULL, 0, lkcbfunc, (void*)p);
158+
if (PMIX_SUCCESS != rc) {
159+
PMIX_ERROR_LOG(rc);
160+
PMIX_RELEASE(p);
161+
}
119162
}
120163
}
121164
return rc;

src/mca/plog/syslog/plog_syslog.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
5252
void *cbdata);
5353

5454
/* Module def */
55-
pmix_plog_module_t pmix_plog_syslog_module = {.name = "syslog",
56-
.init = init,
57-
.finalize = finalize,
58-
.log = mylog};
55+
pmix_plog_module_t pmix_plog_syslog_module = {
56+
.name = "syslog",
57+
.init = init,
58+
.finalize = finalize,
59+
.log = mylog
60+
};
5961

6062
static pmix_status_t init(void)
6163
{
@@ -109,28 +111,28 @@ static pmix_status_t mylog(const pmix_proc_t *source, const pmix_info_t data[],
109111

110112
/* check to see if there are any syslog entries */
111113
for (n = 0; n < ndata; n++) {
112-
if (0 == strncmp(data[n].key, PMIX_LOG_SYSLOG, PMIX_MAX_KEYLEN)) {
114+
if (PMIX_CHECK_KEY(&data[n], PMIX_LOG_SYSLOG)) {
113115
/* we default to using the local syslog */
114-
rc = write_local(source, timestamp, pri, data[n].value.data.string, data, ndata);
115-
if (PMIX_SUCCESS == rc) {
116-
/* flag that we did this one */
117-
PMIX_INFO_OP_COMPLETED(&data[n]);
116+
rc = write_local(source, timestamp, pri,
117+
data[n].value.data.string, data, ndata);
118+
if (PMIX_SUCCESS != rc) {
119+
return rc;
118120
}
119-
} else if (0 == strncmp(data[n].key, PMIX_LOG_LOCAL_SYSLOG, PMIX_MAX_KEYLEN)) {
120-
rc = write_local(source, timestamp, pri, data[n].value.data.string, data, ndata);
121-
if (PMIX_SUCCESS == rc) {
122-
/* flag that we did this one */
123-
PMIX_INFO_OP_COMPLETED(&data[n]);
121+
} else if (PMIX_CHECK_KEY(&data[n], PMIX_LOG_LOCAL_SYSLOG)) {
122+
rc = write_local(source, timestamp, pri,
123+
data[n].value.data.string, data, ndata);
124+
if (PMIX_SUCCESS != rc) {
125+
return rc;
124126
}
125-
} else if (0 == strncmp(data[n].key, PMIX_LOG_GLOBAL_SYSLOG, PMIX_MAX_KEYLEN)) {
127+
} else if (PMIX_CHECK_KEY(&data[n], PMIX_LOG_GLOBAL_SYSLOG)) {
126128
/* only do this if we are a gateway server */
127129
if (PMIX_PEER_IS_GATEWAY(pmix_globals.mypeer)) {
128-
rc = write_local(source, timestamp, pri, data[n].value.data.string, data, ndata);
129-
if (PMIX_SUCCESS == rc) {
130-
/* flag that we did this one */
131-
PMIX_INFO_OP_COMPLETED(&data[n]);
130+
rc = write_local(source, timestamp, pri,
131+
data[n].value.data.string, data, ndata);
132+
if (PMIX_SUCCESS != rc) {
133+
return rc;
132134
}
133-
}
135+
}
134136
}
135137
}
136138

0 commit comments

Comments
 (0)