Exemplo n.º 1
0
int main(int argc, char* argv[])
{
    struct timespec tp;
    int rc, delay;

    target.jobid = ORTE_JOBID_INVALID;
    target.vpid = ORTE_VPID_INVALID;

    /* init the ORCM library - this includes registering
     * a multicast recv so we hear announcements and
     * their responses from other apps
     */
    if (ORCM_SUCCESS != (rc = orcm_init(ORCM_APP))) {
        fprintf(stderr, "Failed to init: error %d\n", rc);
        exit(1);
    }
    
    opal_event_signal_set(opal_event_base, &sigterm_handler, SIGTERM,
                          signal_trap, &sigterm_handler);
    opal_event_signal_add(&sigterm_handler, NULL);
    opal_event_signal_set(opal_event_base, &sigint_handler, SIGINT,
                          signal_trap, &sigint_handler);
    opal_event_signal_add(&sigint_handler, NULL);

    /* for this application, register to hear messages sent to our input  */
    if (ORCM_SUCCESS != (rc = orcm_pnp.register_receive("client", "2.0", "beta",
                                                        ORCM_PNP_GROUP_INPUT_CHANNEL,
                                                        ORCM_TEST_CLIENT_SERVER_TAG, recv_input, NULL))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* open a channel to any client 1.0 peers */
    if (ORCM_SUCCESS != (rc = orcm_pnp.open_channel("client", "1.0", NULL, ORTE_JOBID_WILDCARD, found_channel))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* announce our existence */
    if (ORCM_SUCCESS != (rc = orcm_pnp.announce("CLIENT", "2.0", "beta", responses))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    opal_output(0, "CLIENT2 %s ACTIVE", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));

    /* init the msg number */
    msg_num = 0;
    
    /* wake up every x seconds send something */
    ORTE_TIMER_EVENT(ORTE_PROC_MY_NAME->vpid + 1, 0, send_data);
    opal_event_dispatch(opal_event_base);

cleanup:
    orcm_finalize();
    return rc;
}
Exemplo n.º 2
0
int
main(int argc, char **argv)
{
    opal_event_t ev1, ev2;
    orte_state_caddy_t *caddy;

    opal_init(&argc, &argv);

    /* assign some signal traps */
    if (opal_event_signal_set(orte_event_base, &ev1, SIGTERM, cbfunc, &ev1) < 0) {
        die("event_assign");
    }
    if (opal_event_set_priority(&ev1, ORTE_ERROR_PRI) < 0) {
        die("event_set_pri");
    }
    if (opal_event_signal_add(&ev1, NULL) < 0) {
        die("event_add");
    }
    if (opal_event_signal_set(orte_event_base, &ev2, SIGPIPE, cbfunc, &ev2) < 0) {
        die("event_assign");
    }
    if (opal_event_set_priority(&ev2, ORTE_ERROR_PRI) < 0) {
        die("event_assign");
    }
    if (opal_event_signal_add(&ev2, NULL) < 0) {
        die("event_assign");
    }
    fprintf(stderr, "SIGNAL EVENTS DEFINED\n");
    fflush(stderr);

    /* assign a state event */
    caddy = OBJ_NEW(orte_state_caddy_t);
    opal_event_set(orte_event_base, &caddy->ev, -1, OPAL_EV_READ, t1func, caddy);
    opal_event_set_priority(&caddy->ev, ORTE_SYS_PRI);
    opal_event_active(&caddy->ev, OPAL_EV_WRITE, 1);
    fprintf(stderr, "FIRST EVENT DEFINED AND ACTIVATED\n");
    fflush(stderr);

    /*    event_dispatch(base); */

    while (run) {
        opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
    }

    fprintf(stderr, "EXITED LOOP - FINALIZING\n");
    fflush(stderr);
    opal_finalize();
    return 0;
}
Exemplo n.º 3
0
static void setup_sighandler(int signal, opal_event_t *ev,
                             opal_event_cbfunc_t cbfunc)
{
    opal_event_signal_set(orte_event_base, ev, signal, cbfunc, ev);
    opal_event_set_priority(ev, ORTE_ERROR_PRI);
    opal_event_signal_add(ev, NULL);
}
Exemplo n.º 4
0
int main(int argc, char* argv[])
{
    int i;
    float pi;
    int rc;
    
    /* init the ORCM library - this includes registering
     * a multicast recv so we hear announcements and
     * their responses from other apps
     */
    if (ORCM_SUCCESS != (rc = orcm_init(ORCM_APP))) {
        fprintf(stderr, "Failed to init: error %d\n", rc);
        exit(1);
    }
    
    opal_event_signal_set(opal_event_base, &sigterm_handler, SIGTERM,
                          signal_trap, &sigterm_handler);
    opal_event_signal_add(&sigterm_handler, NULL);
    opal_event_signal_set(opal_event_base, &sigint_handler, SIGINT,
                          signal_trap, &sigint_handler);
    opal_event_signal_add(&sigint_handler, NULL);

    /* listen on my input channel for direct messages */
    if (ORCM_SUCCESS != (rc = orcm_pnp.register_receive("LISTENER_IOVEC", "1.0", "alpha",
                                                        ORCM_PNP_GROUP_INPUT_CHANNEL,
                                                        ORCM_PNP_TAG_WILDCARD, recv_input, NULL))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* announce our existence */
    if (ORCM_SUCCESS != (rc = orcm_pnp.announce("LISTENER_IOVEC", "1.0", "alpha", NULL))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* just sit here */
    opal_event_dispatch(opal_event_base);
    
cleanup:

    orcm_finalize();
    return rc;
}
Exemplo n.º 5
0
int main(int argc, char* argv[])
{
    struct timespec tp;
    int rc;
    
    /* init the ORCM library - this includes registering
     * a multicast recv so we hear announcements and
     * their responses from other apps
     */
    if (ORCM_SUCCESS != (rc = orcm_init(ORCM_APP))) {
        fprintf(stderr, "Failed to init: error %d\n", rc);
        exit(1);
    }
    
    opal_event_signal_set(opal_event_base, &sigterm_handler, SIGTERM,
                          signal_trap, &sigterm_handler);
    opal_event_signal_add(&sigterm_handler, NULL);
    opal_event_signal_set(opal_event_base, &sigint_handler, SIGINT,
                          signal_trap, &sigint_handler);
    opal_event_signal_add(&sigint_handler, NULL);

    /* announce our existence */
    if (ORCM_SUCCESS != (rc = orcm_pnp.announce("TALKER_IOVEC", "1.0", "alpha", NULL))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* for this application, there are no desired
     * inputs, so we don't register any
     */
    ORTE_TIMER_EVENT(ORTE_PROC_MY_NAME->vpid + 1, 0, send_data);
    opal_event_dispatch(opal_event_base);
    
cleanup:
    orcm_finalize();
    return rc;
}
Exemplo n.º 6
0
static void trap_signals(void)
{
    int i;
    
    for (i=0; i < num_signals; i++) {
        if (SIGPIPE == signals[i]) {
            /* ignore this signal */
            opal_event_signal_set(opal_event_base, &trap_handler[i], signals[i],
                                  ignore_trap, &trap_handler[i]);
        } else {
            opal_event_signal_set(opal_event_base, &trap_handler[i], signals[i],
                                  signal_trap, &trap_handler[i]);
        }
        opal_event_signal_add(&trap_handler[i], NULL);
    }
}
Exemplo n.º 7
0
int main(int argc, char* argv[])
{
    int rc;
    
    if (1 < argc) {
        tp.tv_sec = strtol(argv[1], NULL, 10);
    } else {
        tp.tv_sec = 0;
    }
    if (2 < argc) {
        tp.tv_usec = strtol(argv[2], NULL, 10);
    } else {
        tp.tv_usec = 10000;
    }

    /* init the ORCM library - this includes registering
     * a multicast recv so we hear announcements and
     * their responses from other apps
     */
    if (ORCM_SUCCESS != (rc = orcm_init(ORCM_APP))) {
        fprintf(stderr, "Failed to init: error %d\n", rc);
        exit(1);
    }
    
    opal_event_signal_set(opal_event_base, &sigterm_handler, SIGTERM,
                          signal_trap, &sigterm_handler);
    opal_event_signal_add(&sigterm_handler, NULL);
    opal_event_signal_set(opal_event_base, &sigint_handler, SIGINT,
                          signal_trap, &sigint_handler);
    opal_event_signal_add(&sigint_handler, NULL);

    /* open a channel to send to the listener application */
    if (ORCM_SUCCESS != (rc = orcm_pnp.open_channel("LISTENER_IOVEC", "1.0", "alpha",
                                                    ORTE_JOBID_WILDCARD, found_channel))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }

    /* listen on my input channel for direct messages */
    if (ORCM_SUCCESS != (rc = orcm_pnp.register_receive("TALKER_IOVEC", "1.0", "alpha",
                                                        ORCM_PNP_GROUP_INPUT_CHANNEL,
                                                        ORCM_PNP_TAG_WILDCARD, recv_input, NULL))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* announce our existence */
    if (ORCM_SUCCESS != (rc = orcm_pnp.announce("TALKER_IOVEC", "1.0", "alpha", NULL))) {
        ORTE_ERROR_LOG(rc);
        goto cleanup;
    }
    
    /* wake up every x seconds to send something */
    ORTE_TIMER_EVENT(tp.tv_sec, tp.tv_usec, send_data);

    opal_event_dispatch(opal_event_base);
    
cleanup:
    orcm_finalize();
    return rc;
}