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

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