root/opal/mca/pmix/pmix4x/pmix/src/mca/plog/default/plog_default.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. lcon
  2. ldes
  3. init
  4. localcbfn
  5. mylog

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2007      Sun Microsystems, Inc.  All rights reserved.
  13  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  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  /* HAVE_SYS_TIME_H */
  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 /* Static API's */
  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 /* Module def */
  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 /* local object */
  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     /* we cannot operate if our host doesn't support log */
  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     /* if none of the prior modules performed a requested logging
 107      * operation, then we will try here */
 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     /* send it upwards for potential handling. This might seem
 119      * odd in the case where we are a gateway, but we must allow
 120      * for the possibility that the host has a channel we don't
 121      * directly support */
 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     /* separate out the ones that weren't completed */
 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     /* ask the host to log the remainder */
 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 }

/* [<][>][^][v][top][bottom][index][help] */