Beispiel #1
0
void
ccnet_processor_done (CcnetProcessor *processor,
                      gboolean success)
{
    if (processor->thread_running) {
        processor->delay_shutdown = TRUE;
        processor->was_success = success;
        return;
    }

    if (processor->state == STATE_IN_SHUTDOWN) {
        return;
    }
    processor->state = STATE_IN_SHUTDOWN;
    if (processor->failure == PROC_NOTSET && success)
        processor->failure = PROC_DONE;

    g_debug ("[proc] Processor %s(%d) done %d\n", GET_PNAME(processor),
             PRINT_ID(processor->id), success);

    /* Notify */
    if (!IS_SLAVE (processor) && success) {
        ccnet_processor_send_update (processor, SC_PROC_DONE, SS_PROC_DONE,
                                     NULL, 0);
    }

    g_signal_emit (processor, signals[DONE_SIG], 0, success);

    ccnet_client_remove_processor (processor->session, processor);
    ccnet_processor_release_resource (processor);
    ccnet_proc_factory_recycle (processor->session->proc_factory, processor);
}
Beispiel #2
0
void
ccnet_processor_done (CcnetProcessor *processor, gboolean success)
{
    if (processor->thread_running) {
        processor->delay_shutdown = TRUE;
        processor->was_success = success;
        return;
    }

    if (processor->state == STATE_IN_SHUTDOWN) {
        return;
    }

    processor->state = STATE_IN_SHUTDOWN;
    if (processor->failure == PROC_NOTSET)
        processor->failure = PROC_DONE;
    if (!processor->peer->is_local)
        ccnet_debug ("Processsor %s(%d) done %d\n", GET_PNAME(processor),
                     PRINT_ID(processor->id), success);

    if (!processor->detached && success)
    {
        if (!IS_SLAVE (processor)) {
            ccnet_processor_send_update (processor, SC_PROC_DONE, SS_PROC_DONE,
                                         NULL, 0);
        }
    }

    /* When we emit the done signal, the corresponding handler may
     * shutdown the peer, we should remove this processor from the
     * peers processor list, otherwise this processor will be freed
     * twice. */
    g_signal_emit (processor, signals[DONE_SIG], 0, success);

    if (!processor->detached) {
        ccnet_peer_remove_processor (processor->peer, processor);
    }

    ccnet_processor_release_resource (processor);

    ccnet_proc_factory_recycle (processor->session->proc_factory, processor);
}