Ejemplo n.º 1
0
/* should we digest this entry? used by storeDigestAdd() */
static int
storeDigestAddable(const StoreEntry * e)
{
    /* add some stats! XXX */

    debug(71, 6) ("storeDigestAddable: checking entry, key: %s\n",
	storeKeyText(e->hash.key));

    /* check various entry flags (mimics storeCheckCachable XXX) */
    if (!EBIT_TEST(e->flags, ENTRY_CACHABLE)) {
	debug(71, 6) ("storeDigestAddable: NO: not cachable\n");
	return 0;
    }
    if (EBIT_TEST(e->flags, KEY_PRIVATE)) {
	debug(71, 6) ("storeDigestAddable: NO: private key\n");
	return 0;
    }
    if (EBIT_TEST(e->flags, ENTRY_NEGCACHED)) {
	debug(71, 6) ("storeDigestAddable: NO: negative cached\n");
	return 0;
    }
    if (EBIT_TEST(e->flags, RELEASE_REQUEST)) {
	debug(71, 6) ("storeDigestAddable: NO: release requested\n");
	return 0;
    }
    if (e->store_status == STORE_OK && EBIT_TEST(e->flags, ENTRY_BAD_LENGTH)) {
	debug(71, 6) ("storeDigestAddable: NO: wrong content-length\n");
	return 0;
    }
    /* do not digest huge objects */
    if (e->swap_file_sz > Config.Store.maxObjectSize) {
	debug(71, 6) ("storeDigestAddable: NO: too big\n");
	return 0;
    }
    /* still here? check staleness */
    /* Note: We should use the time of the next rebuild, not (cur_time+period) */
    if (refreshCheckDigest(e, Config.digest.rebuild_period)) {
	debug(71, 6) ("storeDigestAddable: entry expires within %d secs, ignoring\n",
	    (int) Config.digest.rebuild_period);
	return 0;
    }
    /*
     * idea: how about also skipping very fresh (thus, potentially
     * unstable) entries? Should be configurable through
     * cd_refresh_pattern, of course.
     */
    /*
     * idea: skip objects that are going to be purged before the next
     * update.
     */
#if OLD_UNUSED_CODE		/* This code isn't applicable anymore, we can't fix it atm either :( */
    if ((squid_curtime + Config.digest.rebuild_period) - e->lastref > storeExpiredReferenceAge())
	return 0;
#endif
    return 1;
}
Ejemplo n.º 2
0
variable_list *
snmp_prfSysFn(variable_list * Var, snint * ErrP)
{
    variable_list *Answer = NULL;
    static struct rusage rusage;
    debug(49, 5) ("snmp_prfSysFn: Processing request with magic %d!\n", Var->name[LEN_SQ_PRF + 1]);
    *ErrP = SNMP_ERR_NOERROR;
    switch (Var->name[LEN_SQ_PRF + 1]) {
    case PERF_SYS_PF:
	squid_getrusage(&rusage);
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    rusage_pagefaults(&rusage),
	    SMI_COUNTER32);
	break;
    case PERF_SYS_NUMR:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    IOStats.Http.reads,
	    SMI_COUNTER32);
	break;
    case PERF_SYS_MEMUSAGE:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) memTotalAllocated() >> 10,
	    ASN_INTEGER);
	break;
    case PERF_SYS_CPUTIME:
	squid_getrusage(&rusage);
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) rusage_cputime(&rusage),
	    ASN_INTEGER);
	break;
    case PERF_SYS_CPUUSAGE:
	squid_getrusage(&rusage);
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) dpercent(rusage_cputime(&rusage), tvSubDsec(squid_start, current_time)),
	    ASN_INTEGER);
	break;
    case PERF_SYS_MAXRESSZ:
	squid_getrusage(&rusage);
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) rusage_maxrss(&rusage),
	    ASN_INTEGER);
	break;
    case PERF_SYS_CURLRUEXP:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
#if !HEAP_REPLACEMENT
	    (snint) (storeExpiredReferenceAge() * 100),
#else
	    0,
#endif
	    SMI_TIMETICKS);
	break;
    case PERF_SYS_CURUNLREQ:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) Counter.unlink.requests,
	    SMI_COUNTER32);
	break;
    case PERF_SYS_CURUNUSED_FD:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) Squid_MaxFD - Number_FD,
	    SMI_GAUGE32);
	break;
    case PERF_SYS_CURRESERVED_FD:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) Number_FD,
	    SMI_GAUGE32);
	break;
    case PERF_SYS_NUMOBJCNT:
	Answer = snmp_var_new_integer(Var->name, Var->name_length,
	    (snint) memInUse(MEM_STOREENTRY),
	    SMI_COUNTER32);
	break;
    default:
	*ErrP = SNMP_ERR_NOSUCHNAME;
	break;
    }
    return Answer;
}