Beispiel #1
0
/* cleanup: Invoked by the various err_xxx funtions when dying.
 * -------- */
void cleanup()
{
    char *log_file, *tmp_log_file;
    int has_recv_data;

    ibuf_free(current_line);

    /* Cleanly scroll the screen up for a prompt */
    scrl(1);
    move(LINES - 1, 0);
    printf("\n");

    rline_write_history(rline, readline_history_path);

    /* The order of these is important. They each must restore the terminal
     * the way they found it. Thus, the order in which curses/readline is 
     * started, is the reverse order in which they should be shutdown 
     */

    /* Shut down interface */
    if_shutdown();

#if 0
    if (masterfd != -1)
        util_free_tty(&masterfd, &slavefd, tty_name);
#endif

    /* Finally, should display the errors. 
     * TGDB guarentees the logger to be open at this point.
     * So, we can get the filename directly from the logger 
     */
    logger_get_file(logger, &tmp_log_file);
    log_file = strdup(tmp_log_file);
    logger_has_recv_data(logger, &has_recv_data);

    /* Shut down debugger */
    tgdb_shutdown(tgdb);

    if (tty_set_attributes(STDIN_FILENO, &term_attributes) == -1)
        logger_write_pos(logger, __FILE__, __LINE__, "tty_reset error");

    if (has_recv_data)
        fprintf(stderr, "CGDB had unexpected results, see %s for details.\n",
                log_file);

    free(log_file);
    log_file = NULL;
}
Beispiel #2
0
/**
 * @brief Initialize the NSSI RPC mechanism.
 *
 * This implementation of \b nssi_rpc_init initializes the
 * Portals library and interface so that we can use Portals
 * as the underlying communication protocol.
 *
 * @param pid  @input The ID to use for this process.
 */
int nssi_rpc_init(
    const nssi_rpc_transport rpc_transport,
    const nssi_rpc_encode    rpc_encode,
    const char              *url)
{
    int rc;

    NNTI_transport_id_t transport_id;

    log_debug(rpc_debug_level, "************************************************************ entered");

    if (rpc_initialized) return NSSI_OK;

    /* check to see if logging is enabled */
    if (logger_not_initialized()) {
        logger_set_file(stderr);
    }

    /* make sure the timer works properly */
//    rc = nssi_timer_test();
//    if (rc != NSSI_OK) {
//        log_fatal(rpc_debug_level, "nssi_timer_test() failed");
//        return rc;
//    }

    /* stash the transport and encoding types so we know how to cleanup on exit */
//    transport = rpc_transport;
    encoding  = rpc_encode;

    /* initialize the transport mechanism */
    switch (rpc_transport) {
        case NSSI_RPC_PTL:
            transport_id=NNTI_TRANSPORT_PORTALS;
            break;
        case NSSI_RPC_IB:
            transport_id=NNTI_TRANSPORT_IB;
            break;
        case NSSI_RPC_LUC:
            transport_id=NNTI_TRANSPORT_LUC;
            break;
        case NSSI_RPC_GEMINI:
            transport_id=NNTI_TRANSPORT_GEMINI;
            break;
        case NSSI_RPC_MPI:
            transport_id=NNTI_TRANSPORT_MPI;
            break;
        default:
            rc = NSSI_ENOENT;
            log_error(rpc_debug_level, "the transport scheme %d does not exist", rpc_transport);
            return rc;
    }

    rc = NNTI_init(
            transport_id,
            url,
            &transports[rpc_transport]);
    if (rc != NNTI_OK) {
        log_fatal(rpc_debug_level,"failed");
        return rc;
    }

    /* initialize the xdr-encoding mechanism */
    switch (rpc_encode) {
        case NSSI_RPC_XDR:
            rc = nssi_xdr_init();
            if (rc != NSSI_OK) {
                log_fatal(rpc_debug_level,"failed, %d", rc);
                return rc;
            }
            break;

        default:
            rc = NSSI_ENOENT;
            log_error(rpc_debug_level, "the transport scheme "
            "does not exist");
            return rc;
    }

    config_init(&nssi_config);
    config_get_from_env(&nssi_config);
    if (nssi_config.use_buffer_queue) {
        trios_buffer_queue_init(
                &send_bq,
                nssi_config.buffer_queue_initial_size,
                nssi_config.buffer_queue_max_size,
                nssi_config.buffer_queue_create_if_empty,
                &transports[rpc_transport],
                NNTI_SEND_SRC,
                NSSI_SHORT_REQUEST_SIZE);
        trios_buffer_queue_init(
                &recv_bq,
                nssi_config.buffer_queue_initial_size,
                nssi_config.buffer_queue_max_size,
                nssi_config.buffer_queue_create_if_empty,
                &transports[rpc_transport],
                NNTI_RECV_DST,
                NSSI_SHORT_RESULT_SIZE);
        trios_buffer_queue_init(
                &rdma_target_bq,
                nssi_config.rdma_buffer_queue_initial_size,
                nssi_config.rdma_buffer_queue_max_size,
                nssi_config.rdma_buffer_queue_create_if_empty,
                &transports[rpc_transport],
                (NNTI_buf_ops_t)(NNTI_GET_SRC|NNTI_PUT_DST),
                nssi_config.rdma_buffer_queue_buffer_size);
        trios_buffer_queue_init(
                &rdma_get_bq,
                nssi_config.rdma_buffer_queue_initial_size,
                nssi_config.rdma_buffer_queue_max_size,
                nssi_config.rdma_buffer_queue_create_if_empty,
                &transports[rpc_transport],
                NNTI_GET_DST,
                nssi_config.rdma_buffer_queue_buffer_size);
        trios_buffer_queue_init(
                &rdma_put_bq,
                nssi_config.rdma_buffer_queue_initial_size,
                nssi_config.rdma_buffer_queue_max_size,
                nssi_config.rdma_buffer_queue_create_if_empty,
                &transports[rpc_transport],
                NNTI_PUT_SRC,
                nssi_config.rdma_buffer_queue_buffer_size);
    }

    rpc_initialized = true;

    if (logging_debug(rpc_debug_level)) {
        fprint_NNTI_peer(logger_get_file(), "transports[rpc_transport].me",
                "end of nssi_rpc_init", &transports[rpc_transport].me);
    }

    log_debug(rpc_debug_level, "************************************************************  exit");

    return NSSI_OK;
}