Exemple #1
0
int check_and_reload_table (struct internal_mib_table *table)
{
    /*
     * If the saved data is fairly recent,
     *    we don't need to reload it
     */
    if (table->cache_markerM && !(netsnmp_ready_monotonic (table->cache_markerM, table->cache_timeout * 1000)))
        return 1;


    /*
     * Call the routine provided to read in the data
     *
     * N.B:  Update the cache marker *before* calling
     *   this routine, to avoid problems with recursion
     */
    netsnmp_set_monotonic_marker (&table->cache_markerM);

    table->next_index = 1;
    if (table->reload ((mib_table_t) table) < 0)
    {
        free (table->cache_markerM);
        table->cache_markerM = NULL;
        return 0;
    }
    table->current_index = 1;
    if (table->compare != NULL)    /* Sort the table */
        qsort (TABLE_START (table), table->next_index - 1, table->data_size, table->compare);
    return 1;
}
Exemple #2
0
/** Check if the cache timeout has passed. Sets and return the expired flag. */
int
netsnmp_cache_check_expired(netsnmp_cache *cache)
{
    if(NULL == cache)
        return 0;
    if (cache->expired)
        return 1;
    if(!cache->valid || (NULL == cache->timestampM) || (-1 == cache->timeout))
        cache->expired = 1;
    else
        cache->expired = netsnmp_ready_monotonic(cache->timestampM,
                                                 1000 * cache->timeout);
    
    return cache->expired;
}