示例#1
0
void
of_object_track_report(loci_writer_f writer, void* cookie)
{
    biglist_t *elt;
    of_object_t *obj;
    int count = 0;

    writer(cookie, "\nLOCI Outstanding object list.\n");
    writer(cookie, "Objs: Current %d. Max %d. Created %d. Deleted %d\n",
           TRACK->count_current, TRACK->count_max, TRACK->allocs,
           TRACK->deletes);
    if (TRACK_OBJS) {
        BIGLIST_FOREACH_DATA(elt, TRACK_OBJS, of_object_t *, obj) {
            of_object_track_output(obj, writer, cookie);
            ++count;
        }
    }
示例#2
0
static inline void
cxn_state_set(connection_t *cxn, indigo_cxn_state_t new_state)
{
    indigo_cxn_state_t old_state;

    old_state = CONNECTION_STATE(cxn);

    if (old_state == new_state) {
        LOG_TRACE(cxn, "Non-state change in %s", CXN_STATE_NAME(new_state));
        return;
    }

    LOG_INFO(cxn, "%s->%s", CXN_STATE_NAME(old_state),
             CXN_STATE_NAME(new_state));

    /****************************************************************
     *
     * Verify pre-conditions
     *
     * @fixme Check here for illegal state transitions
     *
     ****************************************************************/

    switch (new_state) {
    case INDIGO_CXN_S_DISCONNECTED:
        /* If moving to disconnected, must be closing (or disconnected) */
        if ((old_state != INDIGO_CXN_S_CLOSING)) {
            LOG_ERROR(cxn, "Error in cxn SM: disconnected from %s",
                      CXN_STATE_NAME(old_state));
            /* Clean up and hope for the best */
        }
        break;

    default:
        break;
    }


    /****************************************************************
     *
     * Exit conditions for old state
     *
     ****************************************************************/

    switch (old_state) {
    case INDIGO_CXN_S_CLOSING:
        ind_soc_timer_event_unregister(cxn_closing_timeout, (void *)cxn);
        break;
    case INDIGO_CXN_S_CONNECTING:
        if (!CXN_LOCAL(cxn)) {
            ind_soc_timer_event_unregister(cxn_connecting_timeout,
                                           (void *)cxn);
        }
        break;

    default:
        break;
    }

    /****************************************************************
     *
     * Process change to new state
     *
     ****************************************************************/

    /* Change state of connection */
    cxn->status.state = new_state;

    /* External notification of state change before processing */
    ind_cxn_status_change(cxn);

    /* Post-processing of state transition. */
    switch (new_state) {
    case INDIGO_CXN_S_DISCONNECTED:
        if (cxn->flags & CXN_TO_BE_REMOVED) {
            LOG_VERBOSE(cxn, "Completing cxn removal");
            cxn->active = 0;
        } else if (CXN_LOCAL(cxn)) {
            cxn->active = 0;
        } else {
            /* Disconnected but still active - start connecting again */
            ind_soc_timer_event_register_with_priority(
                ind_cxn_connection_retry_timer, cxn,
                IND_SOC_TIMER_IMMEDIATE, IND_CXN_EVENT_PRIORITY);
        }
        ind_cxn_disconnected_init(cxn);
        break;

    case INDIGO_CXN_S_CONNECTING:
        /* Register with socket manager */
        ind_soc_socket_register_with_priority(
            cxn->sd, indigo_cxn_socket_ready_callback,
            cxn, IND_CXN_EVENT_PRIORITY);
        ind_cxn_send_hello(cxn);
        if (CXN_LOCAL(cxn)) {
            /* Recursive call; transition to connected */
            cxn_state_set(cxn, INDIGO_CXN_S_HANDSHAKE_COMPLETE);
        } else {
            ind_soc_timer_event_register_with_priority(
                cxn_connecting_timeout, (void *)cxn,
                CXN_STATE_TIMEOUT(new_state), IND_CXN_EVENT_PRIORITY);
        }
        break;

    case INDIGO_CXN_S_CLOSING:
#if defined(OF_OBJECT_TRACKING)
#define VERBOSE_LOG_ENABLED 1    /* @FIXME Check log level */
        if ((cxn->outstanding_ops) && VERBOSE_LOG_ENABLED) {
            biglist_t *elt;
            of_object_t *obj;

            LOG_VERBOSE(cxn, "Closing connnection with outstanding ops");
            BIGLIST_FOREACH_DATA(elt, cxn->outstanding_ops,
                                 of_object_t *, obj) {
                of_object_track_output(obj, (loci_writer_f)aim_printf, AIM_LOG_STRUCT_POINTER->pvs);
            }
        }
#endif
        ind_soc_timer_event_unregister(periodic_keepalive, (void *)cxn);
        ind_soc_timer_event_register_with_priority(
            cxn_closing_timeout, (void *)cxn,
            CXN_STATE_TIMEOUT(new_state), IND_CXN_EVENT_PRIORITY);
        cleanup_disconnect(cxn);
        break;
    case INDIGO_CXN_S_HANDSHAKE_COMPLETE:
        if (cxn->keepalive.period_ms > 0) {
            /* Set up periodic echo request */
            ind_soc_timer_event_register_with_priority(
                periodic_keepalive, (void *)cxn,
                cxn->keepalive.period_ms, IND_CXN_EVENT_PRIORITY);
        }

        break;

    default:
        break;
    }