root/orte/mca/state/tool/state_tool.c

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

DEFINITIONS

This source file includes following definitions.
  1. force_quit
  2. init
  3. finalize

   1 /*
   2  * Copyright (c) 2011      Los Alamos National Security, LLC.
   3  *                         All rights reserved.
   4  * Copyright (c) 2013      Intel, Inc. All rights reserved.
   5  * $COPYRIGHT$
   6  *
   7  * Additional copyrights may follow
   8  *
   9  * $HEADER$
  10  */
  11 
  12 #include "orte_config.h"
  13 
  14 #include <sys/types.h>
  15 #ifdef HAVE_UNISTD_H
  16 #include <unistd.h>
  17 #endif  /* HAVE_UNISTD_H */
  18 #include <string.h>
  19 
  20 #include "opal/util/output.h"
  21 
  22 #include "orte/runtime/orte_quit.h"
  23 #include "orte/mca/errmgr/errmgr.h"
  24 
  25 #include "orte/mca/state/state.h"
  26 #include "orte/mca/state/base/state_private.h"
  27 #include "state_tool.h"
  28 
  29 /*
  30  * Module functions: Global
  31  */
  32 static int init(void);
  33 static int finalize(void);
  34 
  35 /******************
  36  * TOOL module - just uses base functions after
  37  * initializing the proc state machine. Job state
  38  * machine is unused by tools at this
  39  * time.
  40  ******************/
  41 orte_state_base_module_t orte_state_tool_module = {
  42     init,
  43     finalize,
  44     orte_state_base_activate_job_state,
  45     orte_state_base_add_job_state,
  46     orte_state_base_set_job_state_callback,
  47     orte_state_base_set_job_state_priority,
  48     orte_state_base_remove_job_state,
  49     orte_state_base_activate_proc_state,
  50     orte_state_base_add_proc_state,
  51     orte_state_base_set_proc_state_callback,
  52     orte_state_base_set_proc_state_priority,
  53     orte_state_base_remove_proc_state
  54 };
  55 
  56 static void force_quit(int fd, short args, void *cbdata)
  57 {
  58     /* dont attempt to finalize as it could throw
  59      * us into an infinite loop on errors
  60      */
  61     exit(orte_exit_status);
  62 }
  63 
  64 /************************
  65  * API Definitions
  66  ************************/
  67 static int init(void)
  68 {
  69     int rc;
  70 
  71     OBJ_CONSTRUCT(&orte_job_states, opal_list_t);
  72     OBJ_CONSTRUCT(&orte_proc_states, opal_list_t);
  73 
  74     /* add a default error response */
  75     if (ORTE_SUCCESS != (rc = orte_state.add_job_state(ORTE_JOB_STATE_FORCED_EXIT,
  76                                                        force_quit, ORTE_ERROR_PRI))) {
  77         ORTE_ERROR_LOG(rc);
  78         return rc;
  79     }
  80 
  81     return ORTE_SUCCESS;
  82 }
  83 
  84 static int finalize(void)
  85 {
  86     opal_list_item_t *item;
  87 
  88     /* cleanup the state machines */
  89     while (NULL != (item = opal_list_remove_first(&orte_proc_states))) {
  90         OBJ_RELEASE(item);
  91     }
  92     OBJ_DESTRUCT(&orte_proc_states);
  93 
  94     while (NULL != (item = opal_list_remove_first(&orte_job_states))) {
  95         OBJ_RELEASE(item);
  96     }
  97     OBJ_DESTRUCT(&orte_job_states);
  98 
  99     return ORTE_SUCCESS;
 100 }

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