Ejemplo n.º 1
0
static ind_soc_task_status_t
task_callback_yield(void *cookie)
{
    int *count_ptr = cookie;
    printf("Task callback called\n");

    while (*count_ptr < 100) {
        usleep(1000);
        (*count_ptr)++;
        printf("Task callback working count=%d\n", *count_ptr);

        if (ind_soc_should_yield()) {
            break;
        }
    }

    return *count_ptr == 100 ? IND_SOC_TASK_FINISHED : IND_SOC_TASK_CONTINUE;
}
Ejemplo n.º 2
0
static ind_soc_task_status_t
bundle_task(void *cookie)
{
    struct bundle_task_state *state = cookie;

    connection_t *cxn = ind_cxn_id_to_connection(state->cxn_id);

    while (state->offset < state->count) {
        if (cxn) {
            of_object_storage_t obj_storage;
            of_object_t *obj = parse_message(state->msgs[state->offset], &obj_storage);
            ind_cxn_process_message(cxn, obj);
        } else {
            /* Connection went away. Drop remaining messages. */
        }

        aim_free(state->msgs[state->offset]);
        state->msgs[state->offset] = NULL;
        state->offset++;

        if (ind_soc_should_yield()) {
            return IND_SOC_TASK_CONTINUE;
        }
    }

    if (cxn) {
        indigo_cxn_send_controller_message(cxn->cxn_id, state->reply);
    } else {
        of_object_delete(state->reply);
    }

    aim_free(state->msgs);
    aim_free(state);

    if (cxn) {
        ind_cxn_resume(cxn);
    }

    return IND_SOC_TASK_FINISHED;
}
Ejemplo n.º 3
0
static ind_soc_task_status_t
expiration_task(void *cookie)
{
    indigo_time_t current_time = INDIGO_CURRENT_TIME;
    (void) cookie;

    while (!list_empty(&expiration_queue)) {
        int reason;
        list_links_t *links = expiration_queue.links.next;
        ft_entry_t *entry = FT_ENTRY_CONTAINER(links, expiration);
        if (calc_expiration_time(entry, &reason) <= current_time) {
            expire_flow(entry, reason);
        } else {
            break;
        }
        if (ind_soc_should_yield()) {
            return IND_SOC_TASK_CONTINUE;
        }
    }

    task_running = false;
    return IND_SOC_TASK_FINISHED;
}