示例#1
0
void
indigo_core_flow_removed(indigo_fi_flow_removed_t reason,
                         indigo_fi_flow_stats_t *stats)
{
    ft_entry_t *entry;

    if (!ind_core_init_done) {
        return;
    }

    LOG_TRACE("Async flow removed. reason %d. id "
              INDIGO_FLOW_ID_PRINTF_FORMAT, reason,
              INDIGO_FLOW_ID_PRINTF_ARG((indigo_cookie_t) stats->flow_id));

    /* After entry look up, this looks like ind_core_flow_entry_delete */
    entry = ft_lookup(ind_core_ft, stats->flow_id);
    if (entry == NULL) {
        LOG_TRACE("Async flow removed: did not find entry in SM table. id "
                  INDIGO_FLOW_ID_PRINTF_FORMAT,
                  INDIGO_FLOW_ID_PRINTF_ARG((indigo_cookie_t) stats->flow_id));
        return;
    }

    process_flow_removal(entry, stats, reason);
}
示例#2
0
unsigned int test_figtree(unsigned int seed, int threadid) {
    figtree_t ft;
    int i;
    byte_index_t j;
    figtree_value_t file[MAX_FILE_SIZE];
    figtree_value_t* res;

    for (j = 0; j < MAX_FILE_SIZE; j++) {
        file[j] = MAGIC;
    }
    ft_init(&ft);

    i = 0;
    while (i < NUM_ITERATIONS) {
        if (((++i) & PRINT_FREQ_MASK) == 0) {
            printf("Thread %d: iteration 0x%x (%d) [height = %d]\n", threadid,
                   i, i, ft.root->HEIGHT);
        }
        byte_index_t start = (byte_index_t) (rand_r(&seed) & BYTE_INDEX_MASK);
        byte_index_t end = start +
            (byte_index_t) (rand_r(&seed) & MAX_WRITE_MASK);
        figtree_value_t value = (figtree_value_t) rand_r(&seed);
        if (end >= MAX_FILE_SIZE) {
            end = MAX_FILE_SIZE - 1;
        }
        ft_write(&ft, start, end, value);
        for (j = start; j <= end; j++) {
            file[j] = value;
        }
        
        for (j = 0; j < MAX_FILE_SIZE; j++) {
            res = ft_lookup(&ft, j);
            if (res == NULL) {
                value = MAGIC;
            } else {
                value = *res;
            }
            if (value != file[j]) {
                fprintf(stderr,
                        "[ERROR] Byte %lu is not 0x%x (instead, it is 0x%x)\n",
                        (long unsigned int) j, (unsigned int) file[j],
                        (unsigned int) value);
                goto done;
            }
        }
        for (start = 0; start < MAX_FILE_SIZE; start++) {
            for (end = start; end < MAX_FILE_SIZE; end++) {
                figiter_t* figiter;
                fig_t fig;

                figiter = ft_read(&ft, start, end);
                j = start;
                while (fti_next(figiter, &fig)) {
                    /* Verify that the fig is in bounds. */
                    if (fig.irange.left < start || fig.irange.right > end
                        || fig.irange.left > fig.irange.right) {
                        fprintf(stderr, "[ERROR] Invalid fig [%lu, %lu]\n",
                                (long unsigned int) fig.irange.left,
                                (long unsigned int) fig.irange.right);
                    }
                    /* Verify that there's nothing in the file before the
                     * range.
                     */
                    for (; j < fig.irange.left; j++) {
                        if (file[j] != (figtree_value_t) MAGIC) {
                            fprintf(stderr,
                                    "[ERROR] Byte %lu is not 0x%x (no range)\n",
                                    (long unsigned int) j,
                                    (unsigned int) file[j]);
                        }
                    }
                    /* Verify that everything in the range is correct. */
                    for (; j <= fig.irange.right; j++) {
                        if (file[j] != fig.value) {
                            fprintf(stderr,
                                    "[ERROR] Byte %lu is not 0x%x (got 0x%x)\n",
                                    (long unsigned int) j,
                                    (unsigned int) file[j],
                                    (unsigned int) value);
                        }
                    }
                }
                /* Make sure that there's nothing past the last range. */
                for (; j <= end; j++) {
                    if (file[j] != (figtree_value_t) MAGIC) {
                        fprintf(stderr,
                                "File at byte %lu is not 0x%x (no range)\n",
                                (long unsigned int) j, (unsigned int) file[j]);
                    }
                }
                fti_free(figiter);
            }
        }
    }

    done:
    printf("Deallocating the Fig Tree...\n");
    ft_dealloc(&ft);

    printf("Done.\n");

    return seed;
}