This source file includes following definitions.
- lcon
- ldes
- init
- localcbfn
- mylog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "pmix_config.h"
22 #include "pmix_common.h"
23
24 #include <string.h>
25 #ifdef HAVE_SYS_TIME_H
26 #include <sys/time.h>
27 #endif
28 #include <stdarg.h>
29
30 #include "src/include/pmix_globals.h"
31 #include "src/util/show_help.h"
32 #include "src/util/error.h"
33 #include "src/server/pmix_server_ops.h"
34
35 #include "src/mca/plog/base/base.h"
36 #include "plog_default.h"
37
38
39
40 static int init(void);
41 static pmix_status_t mylog(const pmix_proc_t *source,
42 const pmix_info_t data[], size_t ndata,
43 const pmix_info_t directives[], size_t ndirs,
44 pmix_op_cbfunc_t cbfunc, void *cbdata);
45
46
47 pmix_plog_module_t pmix_plog_default_module = {
48 .name = "default",
49 .channels = NULL,
50 .init = init,
51 .finalize = NULL,
52 .log = mylog
53 };
54
55
56 typedef struct {
57 pmix_object_t super;
58 pmix_info_t *data;
59 size_t ndata;
60 pmix_op_cbfunc_t cbfunc;
61 void *cbdata;
62 } local_caddy_t;
63 static void lcon(local_caddy_t *p)
64 {
65 p->data = NULL;
66 p->ndata = 0;
67 }
68 static void ldes(local_caddy_t *p)
69 {
70 if (NULL != p->data) {
71 PMIX_INFO_FREE(p->data, p->ndata);
72 }
73 }
74 static PMIX_CLASS_INSTANCE(local_caddy_t,
75 pmix_object_t,
76 lcon, ldes);
77
78
79 static int init(void)
80 {
81
82 if (NULL == pmix_host_server.log) {
83 return PMIX_ERR_NOT_AVAILABLE;
84 }
85 return PMIX_SUCCESS;
86 }
87
88 static void localcbfn(pmix_status_t status, void *cbdata)
89 {
90 local_caddy_t *cd = (local_caddy_t*)cbdata;
91
92 if (NULL != cd->cbfunc) {
93 cd->cbfunc(status, cd->cbdata);
94 }
95 PMIX_RELEASE(cd);
96 }
97
98 static pmix_status_t mylog(const pmix_proc_t *source,
99 const pmix_info_t data[], size_t ndata,
100 const pmix_info_t directives[], size_t ndirs,
101 pmix_op_cbfunc_t cbfunc, void *cbdata)
102 {
103 local_caddy_t *cd;
104 size_t ntodo, n;
105
106
107
108 ntodo = 0;
109 for (n=0; n < ndata; n++) {
110 if (!PMIX_INFO_OP_IS_COMPLETE(&data[n])) {
111 ++ntodo;
112 }
113 }
114 if (0 == ntodo) {
115 return PMIX_ERR_TAKE_NEXT_OPTION;
116 }
117
118
119
120
121
122 cd = PMIX_NEW(local_caddy_t);
123 if (NULL == cd) {
124 return PMIX_ERR_NOMEM;
125 }
126 cd->cbfunc = cbfunc;
127 cd->cbdata = cbdata;
128
129
130 PMIX_INFO_CREATE(cd->data, ntodo);
131 if (NULL == cd->data) {
132 PMIX_RELEASE(cd);
133 return PMIX_ERR_NOMEM;
134 }
135 cd->ndata = ntodo;
136 ntodo = 0;
137 for (n=0; n < ndata; n++) {
138 if (!PMIX_INFO_OP_IS_COMPLETE(&data[n])) {
139 PMIX_INFO_XFER(&cd->data[ntodo], (pmix_info_t*)&data[n]);
140 ++ntodo;
141 }
142 }
143
144
145 pmix_host_server.log(source, cd->data, cd->ndata,
146 directives, ndirs,
147 localcbfn, (void*)cd);
148
149 return PMIX_OPERATION_IN_PROGRESS;
150 }