int s_exit(int hp, char* p){ if(hp){ return 4; }else{ s_shutdown(); return 0; } }
void lagopus_cbuffer_shutdown(lagopus_cbuffer_t *cbptr, bool free_values) { if (cbptr != NULL && *cbptr != NULL) { s_lock(*cbptr); { s_shutdown(*cbptr, free_values); } s_unlock(*cbptr); } }
void lagopus_cbuffer_destroy(lagopus_cbuffer_t *cbptr, bool free_values) { if (cbptr != NULL && *cbptr != NULL) { s_lock(*cbptr); { s_shutdown(*cbptr, free_values); lagopus_cond_destroy(&((*cbptr)->m_cond_put)); lagopus_cond_destroy(&((*cbptr)->m_cond_get)); lagopus_cond_destroy(&((*cbptr)->m_cond_awakened)); } s_unlock(*cbptr); lagopus_mutex_destroy(&((*cbptr)->m_lock)); free((void *)*cbptr); *cbptr = NULL; } }
static lagopus_result_t s_parse_shutdown(datastore_interp_t *iptr, datastore_interp_state_t state, size_t argc, const char *const argv[], lagopus_hashmap_t *hptr, datastore_update_proc_t u_proc, datastore_enable_proc_t e_proc, datastore_serialize_proc_t s_proc, datastore_destroy_proc_t d_proc, lagopus_dstring_t *result) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; size_t i; (void)state; (void)argc; (void)hptr; (void)u_proc; (void)e_proc; (void)s_proc; (void)d_proc; (void)result; for (i = 0; i < argc; i++) { lagopus_msg_debug(1, "argv[" PFSZS(4, u) "]:\t'%s'\n", i, argv[i]); } if (iptr != NULL && argv != NULL && result != NULL) { argv++; if (IS_VALID_STRING(*argv) == true) { if (strcmp(*argv, OPT_GRACE_LEVEL) == 0) { argv++; if (IS_VALID_STRING(*argv) == true) { if (strcmp(*argv, OPT_GRACE_LEVEL_RIGHT_NOW) == 0) { /* shutdown (right_now) */ s_shutdown(SHUTDOWN_RIGHT_NOW); ret = LAGOPUS_RESULT_OK; } else if (strcmp(*argv, OPT_GRACE_LEVEL_GRACEFULLY) == 0) { /* shutdown (gracefully) */ s_shutdown(SHUTDOWN_GRACEFULLY); ret = LAGOPUS_RESULT_OK; } else { ret = LAGOPUS_RESULT_INVALID_ARGS; lagopus_msg_warning( CMD_ERR_MSG_INVALID_OPT_VALUE". (%s)\n", *argv, lagopus_error_get_string(ret)); } } else { if (*argv == NULL) { ret = LAGOPUS_RESULT_INVALID_ARGS; lagopus_msg_warning("Bad opt value. (%s)\n", lagopus_error_get_string(ret)); } else { ret = LAGOPUS_RESULT_INVALID_ARGS; lagopus_msg_warning( CMD_ERR_MSG_INVALID_OPT_VALUE". (%s)\n", *argv, lagopus_error_get_string(ret)); } } } else { ret = LAGOPUS_RESULT_INVALID_ARGS; lagopus_msg_warning( CMD_ERR_MSG_INVALID_OPT". (%s)\n", *argv, lagopus_error_get_string(ret)); } } else { if (*argv == NULL) { /* shutdown (default) */ s_shutdown(GRACE_LEVEL_DEFAULT); } else { ret = LAGOPUS_RESULT_INVALID_ARGS; lagopus_msg_warning( CMD_ERR_MSG_INVALID_OPT". (%s)\n", *argv, lagopus_error_get_string(ret)); } } } else { ret = LAGOPUS_RESULT_INVALID_ARGS; } return ret; }