root/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_ptl_register
  2. pmix_ptl_close
  3. pmix_ptl_open
  4. scon
  5. sdes
  6. rcon
  7. rdes
  8. prcon
  9. srcon
  10. srdes
  11. pccon
  12. pcdes
  13. lcon
  14. ldes
  15. qcon
  16. qdes

   1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2009 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2012-2013 Los Alamos National Security, Inc.  All rights reserved.
  14  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
  15  * Copyright (c) 2015-2017 Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 /** @file:
  24  *
  25  */
  26 #include <src/include/pmix_config.h>
  27 
  28 #include <pmix_common.h>
  29 
  30 #ifdef HAVE_STRING_H
  31 #include <string.h>
  32 #endif
  33 #ifdef HAVE_FCNTL_H
  34 #include <fcntl.h>
  35 #endif
  36 #ifdef HAVE_SYS_STAT_H
  37 #include <sys/stat.h>
  38 #endif
  39 
  40 #include "src/mca/mca.h"
  41 #include "src/mca/base/base.h"
  42 #include "src/mca/base/pmix_mca_base_var.h"
  43 #include "src/mca/base/pmix_mca_base_framework.h"
  44 #include "src/class/pmix_list.h"
  45 #include "src/client/pmix_client_ops.h"
  46 #include "src/mca/ptl/base/base.h"
  47 
  48 /*
  49  * The following file was created by configure.  It contains extern
  50  * statements and the definition of an array of pointers to each
  51  * component's public mca_base_component_t struct.
  52  */
  53 
  54 #include "src/mca/ptl/base/static-components.h"
  55 
  56 #define PMIX_MAX_MSG_SIZE   16
  57 
  58 /* Instantiate the global vars */
  59 pmix_ptl_globals_t pmix_ptl_globals = {{{0}}};
  60 int pmix_ptl_base_output = -1;
  61 
  62 static size_t max_msg_size = PMIX_MAX_MSG_SIZE;
  63 
  64 static int pmix_ptl_register(pmix_mca_base_register_flag_t flags)
  65 {
  66     pmix_mca_base_var_register("pmix", "ptl", "base", "max_msg_size",
  67                                "Max size (in Mbytes) of a client/server msg",
  68                                PMIX_MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0,
  69                                PMIX_INFO_LVL_2,
  70                                PMIX_MCA_BASE_VAR_SCOPE_READONLY,
  71                                &max_msg_size);
  72     pmix_ptl_globals.max_msg_size = max_msg_size * 1024 * 1024;
  73     return PMIX_SUCCESS;
  74 }
  75 
  76 static pmix_status_t pmix_ptl_close(void)
  77 {
  78     if (!pmix_ptl_globals.initialized) {
  79         return PMIX_SUCCESS;
  80     }
  81     pmix_ptl_globals.initialized = false;
  82 
  83     /* ensure the listen thread has been shut down */
  84     pmix_ptl_base_stop_listening();
  85 
  86     if (NULL != pmix_client_globals.myserver) {
  87         if (0 <= pmix_client_globals.myserver->sd) {
  88             CLOSE_THE_SOCKET(pmix_client_globals.myserver->sd);
  89             pmix_client_globals.myserver->sd = -1;
  90         }
  91     }
  92 
  93     /* the components will cleanup when closed */
  94     PMIX_LIST_DESTRUCT(&pmix_ptl_globals.actives);
  95     PMIX_LIST_DESTRUCT(&pmix_ptl_globals.posted_recvs);
  96     PMIX_LIST_DESTRUCT(&pmix_ptl_globals.unexpected_msgs);
  97     PMIX_LIST_DESTRUCT(&pmix_ptl_globals.listeners);
  98 
  99     return pmix_mca_base_framework_components_close(&pmix_ptl_base_framework, NULL);
 100 }
 101 
 102 static pmix_status_t pmix_ptl_open(pmix_mca_base_open_flag_t flags)
 103 {
 104     pmix_status_t rc;
 105 
 106     /* initialize globals */
 107     pmix_ptl_globals.initialized = true;
 108     PMIX_CONSTRUCT(&pmix_ptl_globals.actives, pmix_list_t);
 109     PMIX_CONSTRUCT(&pmix_ptl_globals.posted_recvs, pmix_list_t);
 110     PMIX_CONSTRUCT(&pmix_ptl_globals.unexpected_msgs, pmix_list_t);
 111     pmix_ptl_globals.listen_thread_active = false;
 112     PMIX_CONSTRUCT(&pmix_ptl_globals.listeners, pmix_list_t);
 113     pmix_ptl_globals.current_tag = PMIX_PTL_TAG_DYNAMIC;
 114 
 115     /* Open up all available components */
 116     rc = pmix_mca_base_framework_components_open(&pmix_ptl_base_framework, flags);
 117     pmix_ptl_base_output = pmix_ptl_base_framework.framework_output;
 118     return rc;
 119 }
 120 
 121 PMIX_MCA_BASE_FRAMEWORK_DECLARE(pmix, ptl, "PMIx Transfer Layer",
 122                                 pmix_ptl_register, pmix_ptl_open, pmix_ptl_close,
 123                                 mca_ptl_base_static_components, 0);
 124 
 125 /***   INSTANTIATE INTERNAL CLASSES   ***/
 126 PMIX_CLASS_INSTANCE(pmix_ptl_base_active_t,
 127                     pmix_list_item_t,
 128                     NULL, NULL);
 129 
 130 static void scon(pmix_ptl_send_t *p)
 131 {
 132     memset(&p->hdr, 0, sizeof(pmix_ptl_hdr_t));
 133     p->hdr.tag = UINT32_MAX;
 134     p->hdr.nbytes = 0;
 135     p->data = NULL;
 136     p->hdr_sent = false;
 137     p->sdptr = NULL;
 138     p->sdbytes = 0;
 139 }
 140 static void sdes(pmix_ptl_send_t *p)
 141 {
 142     if (NULL != p->data) {
 143         PMIX_RELEASE(p->data);
 144     }
 145 }
 146 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_ptl_send_t,
 147                                 pmix_list_item_t,
 148                                 scon, sdes);
 149 
 150 static void rcon(pmix_ptl_recv_t *p)
 151 {
 152     p->peer = NULL;
 153     memset(&p->hdr, 0, sizeof(pmix_ptl_hdr_t));
 154     p->hdr.tag = UINT32_MAX;
 155     p->hdr.nbytes = 0;
 156     p->data = NULL;
 157     p->hdr_recvd = false;
 158     p->rdptr = NULL;
 159     p->rdbytes = 0;
 160 }
 161 static void rdes(pmix_ptl_recv_t *p)
 162 {
 163     if (NULL != p->peer) {
 164         PMIX_RELEASE(p->peer);
 165     }
 166 }
 167 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_ptl_recv_t,
 168                                 pmix_list_item_t,
 169                                 rcon, rdes);
 170 
 171 static void prcon(pmix_ptl_posted_recv_t *p)
 172 {
 173     p->tag = UINT32_MAX;
 174     p->cbfunc = NULL;
 175     p->cbdata = NULL;
 176 }
 177 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_ptl_posted_recv_t,
 178                                 pmix_list_item_t,
 179                                 prcon, NULL);
 180 
 181 
 182 static void srcon(pmix_ptl_sr_t *p)
 183 {
 184     p->peer = NULL;
 185     p->bfr = NULL;
 186     p->cbfunc = NULL;
 187     p->cbdata = NULL;
 188 }
 189 static void srdes(pmix_ptl_sr_t *p)
 190 {
 191     if (NULL != p->peer) {
 192         PMIX_RELEASE(p->peer);
 193     }
 194 }
 195 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_ptl_sr_t,
 196                                 pmix_object_t,
 197                                 srcon, srdes);
 198 
 199 static void pccon(pmix_pending_connection_t *p)
 200 {
 201     p->need_id = false;
 202     memset(p->nspace, 0, PMIX_MAX_NSLEN+1);
 203     p->info = NULL;
 204     p->ninfo = 0;
 205     p->peer = NULL;
 206     p->bfrops = NULL;
 207     p->psec = NULL;
 208     p->gds = NULL;
 209     p->ptl = NULL;
 210     p->cred = NULL;
 211     p->proc_type = PMIX_PROC_UNDEF;
 212 }
 213 static void pcdes(pmix_pending_connection_t *p)
 214 {
 215     if (NULL != p->info) {
 216         PMIX_INFO_FREE(p->info, p->ninfo);
 217     }
 218     if (NULL != p->bfrops) {
 219         free(p->bfrops);
 220     }
 221     if (NULL != p->psec) {
 222         free(p->psec);
 223     }
 224     if (NULL != p->gds) {
 225         free(p->gds);
 226     }
 227     if (NULL != p->cred) {
 228         free(p->cred);
 229     }
 230 }
 231 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_pending_connection_t,
 232                                 pmix_object_t,
 233                                 pccon, pcdes);
 234 
 235 static void lcon(pmix_listener_t *p)
 236 {
 237     p->socket = -1;
 238     p->varname = NULL;
 239     p->uri = NULL;
 240     p->owner_given = false;
 241     p->group_given = false;
 242     p->mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
 243 }
 244 static void ldes(pmix_listener_t *p)
 245 {
 246     if (0 <= p->socket) {
 247         CLOSE_THE_SOCKET(p->socket);
 248     }
 249     if (NULL != p->varname) {
 250         free(p->varname);
 251     }
 252     if (NULL != p->uri) {
 253         free(p->uri);
 254     }
 255 }
 256 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_listener_t,
 257                                 pmix_list_item_t,
 258                                 lcon, ldes);
 259 
 260 static void qcon(pmix_ptl_queue_t *p)
 261 {
 262     p->peer = NULL;
 263     p->buf = NULL;
 264     p->tag = UINT32_MAX;
 265 }
 266 static void qdes(pmix_ptl_queue_t *p)
 267 {
 268     if (NULL != p->peer) {
 269         PMIX_RELEASE(p->peer);
 270     }
 271 }
 272 PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_ptl_queue_t,
 273                                 pmix_object_t,
 274                                 qcon, qdes);

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