This source file includes following definitions.
- relcb
- pmix_server_release
- pmix_server_fencenb_fn
- dmodex_req
- pmix_server_dmodex_req_fn
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 #include "orte_config.h"
  30 
  31 #ifdef HAVE_UNISTD_H
  32 #include <unistd.h>
  33 #endif
  34 
  35 #include "opal/util/output.h"
  36 #include "opal/dss/dss.h"
  37 
  38 #include "orte/mca/errmgr/errmgr.h"
  39 #include "orte/util/name_fns.h"
  40 #include "orte/util/show_help.h"
  41 #include "orte/util/threads.h"
  42 #include "orte/runtime/orte_globals.h"
  43 #include "orte/mca/grpcomm/grpcomm.h"
  44 #include "orte/mca/rml/rml.h"
  45 
  46 #include "pmix_server_internal.h"
  47 #include "pmix_server.h"
  48 
  49 static void relcb(void *cbdata)
  50 {
  51     uint8_t *data = (uint8_t*)cbdata;
  52 
  53     if (NULL != data) {
  54         free(data);
  55     }
  56 }
  57 static void pmix_server_release(int status, opal_buffer_t *buf, void *cbdata)
  58 {
  59     orte_pmix_mdx_caddy_t *cd=(orte_pmix_mdx_caddy_t*)cbdata;
  60     char *data = NULL;
  61     int32_t ndata = 0;
  62     int rc = OPAL_SUCCESS;
  63 
  64     ORTE_ACQUIRE_OBJECT(cd);
  65 
  66     
  67     if (NULL != buf) {
  68         rc = opal_dss.unload(buf, (void**)&data, &ndata);
  69     }
  70     if (OPAL_SUCCESS == rc) {
  71         rc = status;
  72     }
  73     cd->cbfunc(rc, data, ndata, cd->cbdata, relcb, data);
  74     OBJ_RELEASE(cd);
  75 }
  76 
  77 
  78 
  79 
  80 
  81 int pmix_server_fencenb_fn(opal_list_t *procs, opal_list_t *info,
  82                            char *data, size_t ndata,
  83                            opal_pmix_modex_cbfunc_t cbfunc, void *cbdata)
  84 {
  85     orte_pmix_mdx_caddy_t *cd=NULL;
  86     int rc;
  87     opal_namelist_t *nm;
  88     size_t i;
  89     opal_buffer_t *buf=NULL;
  90 
  91     cd = OBJ_NEW(orte_pmix_mdx_caddy_t);
  92     cd->cbfunc = cbfunc;
  93     cd->cbdata = cbdata;
  94 
  95    
  96     if (NULL != procs) {
  97         cd->sig = OBJ_NEW(orte_grpcomm_signature_t);
  98         cd->sig->sz = opal_list_get_size(procs);
  99         cd->sig->signature = (orte_process_name_t*)malloc(cd->sig->sz * sizeof(orte_process_name_t));
 100         memset(cd->sig->signature, 0, cd->sig->sz * sizeof(orte_process_name_t));
 101         i=0;
 102         OPAL_LIST_FOREACH(nm, procs, opal_namelist_t) {
 103             cd->sig->signature[i].jobid = nm->name.jobid;
 104             cd->sig->signature[i].vpid = nm->name.vpid;
 105             ++i;
 106         }
 107     }
 108     buf = OBJ_NEW(opal_buffer_t);
 109 
 110     if (NULL != data) {
 111         opal_dss.load(buf, data, ndata);
 112     }
 113 
 114     if (4 < opal_output_get_verbosity(orte_pmix_server_globals.output)) {
 115         char *tmp=NULL;
 116         (void)opal_dss.print(&tmp, NULL, cd->sig, ORTE_SIGNATURE);
 117         free(tmp);
 118     }
 119 
 120     
 121     
 122     if (ORTE_SUCCESS != (rc = orte_grpcomm.allgather(cd->sig, buf, pmix_server_release, cd))) {
 123         ORTE_ERROR_LOG(rc);
 124         OBJ_RELEASE(buf);
 125         return rc;
 126     }
 127     OBJ_RELEASE(buf);
 128     return ORTE_SUCCESS;
 129 }
 130 
 131 static void dmodex_req(int sd, short args, void *cbdata)
 132 {
 133     pmix_server_req_t *req = (pmix_server_req_t*)cbdata;
 134     pmix_server_req_t *r;
 135     orte_job_t *jdata;
 136     orte_proc_t *proct, *dmn;
 137     int rc, rnum;
 138     opal_buffer_t *buf;
 139     uint8_t *data=NULL;
 140     int32_t sz=0;
 141 
 142     ORTE_ACQUIRE_OBJECT(rq);
 143 
 144     
 145 
 146 
 147 
 148 
 149 
 150 
 151     OPAL_MODEX_RECV_STRING(rc, "modex", &req->target, &data, &sz);
 152     if (OPAL_SUCCESS == rc) {
 153         req->mdxcbfunc(rc, (char*)data, sz, req->cbdata, relcb, data);
 154         OBJ_RELEASE(req);
 155         return;
 156     }
 157 
 158     
 159 
 160     ORTE_ADJUST_TIMEOUT(req);
 161 
 162     
 163 
 164     for (rnum=0; rnum < orte_pmix_server_globals.reqs.num_rooms; rnum++) {
 165         opal_hotel_knock(&orte_pmix_server_globals.reqs, rnum, (void**)&r);
 166         if (NULL == r) {
 167             continue;
 168         }
 169         if (r->target.jobid == req->target.jobid &&
 170             r->target.vpid == req->target.vpid) {
 171             
 172 
 173             if (OPAL_SUCCESS != (rc = opal_hotel_checkin(&orte_pmix_server_globals.reqs, req, &req->room_num))) {
 174                 orte_show_help("help-orted.txt", "noroom", true, req->operation, orte_pmix_server_globals.num_rooms);
 175                 
 176 
 177                 goto callback;
 178             }
 179             return;
 180         }
 181     }
 182 
 183     
 184     if (NULL == (jdata = orte_get_job_data_object(req->target.jobid))) {
 185         
 186 
 187 
 188 
 189         if (OPAL_SUCCESS != (rc = opal_hotel_checkin(&orte_pmix_server_globals.reqs, req, &req->room_num))) {
 190             orte_show_help("help-orted.txt", "noroom", true, req->operation, orte_pmix_server_globals.num_rooms);
 191             
 192 
 193             goto callback;
 194         }
 195         return;
 196     }
 197     
 198 
 199 
 200 
 201     if (ORTE_VPID_WILDCARD == req->target.vpid) {
 202         rc = orte_pmix_server_register_nspace(jdata, true);
 203         if (ORTE_SUCCESS != rc) {
 204             goto callback;
 205         }
 206         
 207         if (NULL != req->mdxcbfunc) {
 208             req->mdxcbfunc(rc, NULL, 0, req->cbdata, NULL, NULL);
 209         }
 210         OBJ_RELEASE(req);
 211         return;
 212     }
 213 
 214     
 215     if (NULL == (proct = (orte_proc_t*)opal_pointer_array_get_item(jdata->procs, req->target.vpid))) {
 216         
 217         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 218         rc = ORTE_ERR_NOT_FOUND;
 219         goto callback;
 220     }
 221 
 222     if (NULL == (dmn = proct->node->daemon)) {
 223         
 224 
 225 
 226         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 227         rc = ORTE_ERR_NOT_FOUND;
 228         goto callback;
 229     }
 230 
 231     
 232 
 233     req->proxy.vpid = dmn->name.vpid;
 234 
 235     
 236 
 237     if (OPAL_SUCCESS != (rc = opal_hotel_checkin(&orte_pmix_server_globals.reqs, req, &req->room_num))) {
 238         orte_show_help("help-orted.txt", "noroom", true, req->operation, orte_pmix_server_globals.num_rooms);
 239         goto callback;
 240     }
 241 
 242     
 243 
 244     if (ORTE_PROC_MY_NAME->jobid == dmn->name.jobid &&
 245         ORTE_PROC_MY_NAME->vpid == dmn->name.vpid) {
 246         return;
 247     }
 248 
 249     
 250     buf = OBJ_NEW(opal_buffer_t);
 251     if (OPAL_SUCCESS != (rc = opal_dss.pack(buf, &req->target, 1, OPAL_NAME))) {
 252         ORTE_ERROR_LOG(rc);
 253         opal_hotel_checkout(&orte_pmix_server_globals.reqs, req->room_num);
 254         OBJ_RELEASE(buf);
 255         goto callback;
 256     }
 257     
 258     if (OPAL_SUCCESS != (rc = opal_dss.pack(buf, &req->room_num, 1, OPAL_INT))) {
 259         ORTE_ERROR_LOG(rc);
 260         opal_hotel_checkout(&orte_pmix_server_globals.reqs, req->room_num);
 261         OBJ_RELEASE(buf);
 262         goto callback;
 263     }
 264 
 265     
 266     if (ORTE_SUCCESS != (rc = orte_rml.send_buffer_nb(&dmn->name, buf, ORTE_RML_TAG_DIRECT_MODEX,
 267                                                       orte_rml_send_callback, NULL))) {
 268         ORTE_ERROR_LOG(rc);
 269         opal_hotel_checkout(&orte_pmix_server_globals.reqs, req->room_num);
 270         OBJ_RELEASE(buf);
 271         goto callback;
 272     }
 273     return;
 274 
 275   callback:
 276     
 277     if (NULL != req->mdxcbfunc) {
 278         req->mdxcbfunc(rc, NULL, 0, req->cbdata, NULL, NULL);
 279     }
 280     OBJ_RELEASE(req);
 281 }
 282 
 283 
 284 
 285 int pmix_server_dmodex_req_fn(opal_process_name_t *proc, opal_list_t *info,
 286                               opal_pmix_modex_cbfunc_t cbfunc, void *cbdata)
 287 {
 288     
 289 
 290     ORTE_DMX_REQ(*proc, dmodex_req, cbfunc, cbdata);
 291     return OPAL_ERR_IN_PROCESS;
 292 }