Ejemplo n.º 1
0
static void
external_acl_cache_delete(external_acl * def, external_acl_entry * entry)
{
    hash_remove_link(def->cache, &entry->hash);
    dlinkDelete(&entry->lru, &def->lru_list);
    def->cache_entries -= 1;
    cbdataFree(entry);
}
Ejemplo n.º 2
0
static void
identClose(int fdnotused, void *data)
{
    IdentStateData *state = data;
    identCallback(state, NULL);
    comm_close(state->fd);
    hash_remove_link(ident_hash, (hash_link *) state);
    cbdataFree(state);
}
Ejemplo n.º 3
0
void remove_file(hash_table *hash, const char *modname,const char * const url,const char * const client_addr) {
	tmpfile_hash_link* lp;
	if((lp=query_hash(hash, modname, url, client_addr)) !=NULL) {
		hash_remove_link(hash, (hash_link*) lp);
		unlink(lp->filename);
		xfree((void*) lp->hash.key);
		xfree((void*) lp->filename);
		xfree((void*) lp);
	}
}
Ejemplo n.º 4
0
static void
netdbHashDelete(const char *key)
{
    hash_link *hptr = hash_lookup(addr_table, key);
    if (hptr == NULL) {
        debug_trap("netdbHashDelete: key not found");
        return;
    }
    hash_remove_link(addr_table, hptr);
}
Ejemplo n.º 5
0
void *
leakFreeFL(void *p, const char *file, int line)
{
    ptr *c = (ptr *) hash_lookup(htable, p);
    assert(p);
    assert(c != NULL);
    hash_remove_link(htable, (hash_link *) c);
    leakCount--;
    xfree(c);
    return p;
}
Ejemplo n.º 6
0
static void
authDigestNoncePurge(digest_nonce_h * nonce)
{
    if (!nonce)
	return;
    if (!nonce->flags.incache)
	return;
    hash_remove_link(digest_nonce_cache, &nonce->hash);
    nonce->flags.incache = 0;
    /* the cache's link */
    authDigestNonceUnlink(nonce);
}
Ejemplo n.º 7
0
static void
pconnDelete(struct _pconn *p)
{
    debug(48, 3) ("pconnDelete: deleting %s\n", hashKeyStr(&p->hash));
    hash_remove_link(table, (hash_link *) p);
    if (p->nfds_alloc == PCONN_FDS_SZ)
	memPoolFree(pconn_fds_pool, p->fds);
    else
	xfree(p->fds);
    xfree(p->hash.key);
    memPoolFree(pconn_data_pool, p);
}
Ejemplo n.º 8
0
static void
cbdataReallyFree(cbdata * c)
{
    CBDUNL *unlock_func = c->unlock_func;
    void *p = (void *) c->key;
    int id = c->id;
    hash_remove_link(htable, (hash_link *) c);
    cbdataCount--;
    xfree(c);
    debug(45, 3) ("cbdataReallyFree: Freeing %p\n", p);
    if (unlock_func)
	unlock_func(p, id);
}
Ejemplo n.º 9
0
static void
authenticateDigestNonceDelete(digest_nonce_h * nonce)
{
    if (nonce) {
	assert(nonce->references == 0);
#if UNREACHABLECODE
	if (nonce->flags.incache)
	    hash_remove_link(digest_nonce_cache, &nonce->hash);
#endif
	assert(nonce->flags.incache == 0);
	safe_free(nonce->hash.key);
	memPoolFree(digest_nonce_pool, nonce);
    }
}
Ejemplo n.º 10
0
static void
cachePurge(Cache * cache, storeSwapLogData * s, int update_digest)
{
    CacheEntry *olde = (CacheEntry *) hash_lookup(cache->hash, s->key);
    if (!olde) {
	cache->bad_del_count++;
    } else {
	assert(cache->count);
	hash_remove_link(cache->hash, (hash_link *) olde);
	if (update_digest)
	    cacheDigestDel(cache->digest, s->key);
	cacheEntryDestroy(olde);
	cache->count--;
    }
}
Ejemplo n.º 11
0
static void
cacheIndexDestroy(CacheIndex * idx)
{
    hash_link *hashr = NULL;
    if (idx) {
	/* destroy hash list contents */
	hash_first(idx->hash);
	while (hashr = hash_next(idx->hash)) {
	    hash_remove_link(idx->hash, hashr);
	    cacheEntryDestroy((CacheEntry *) hashr);
	}
	/* destroy the hash table itself */
	hashFreeMemory(idx->hash);
	xfree(idx);
    }
}
Ejemplo n.º 12
0
static void
authenticateAuthUserRequestUnlinkIp(const struct in_addr ipaddr)
{
	auth_user_request_ip_hash_t *hash_entry;

	if (!auth_user_request_ip_hash)
		return;

	hash_entry = hash_lookup(auth_user_request_ip_hash, &ipaddr);
	if (hash_entry)
	{
		hash_remove_link(auth_user_request_ip_hash, &hash_entry->hash);
		authenticateAuthUserRequestUnlock(hash_entry->auth_user_request);
		memPoolFree(auth_user_request_ip_pool, hash_entry);
	}
}
Ejemplo n.º 13
0
static void
netdbHostDelete(const net_db_name * x)
{
    netdbEntry *n;
    net_db_name **X;
    assert(x != NULL);
    assert(x->net_db_entry != NULL);
    n = x->net_db_entry;
    n->link_count--;
    for (X = &n->hosts; *X; X = &(*X)->next) {
        if (*X == x) {
            *X = x->next;
            break;
        }
    }
    hash_remove_link(host_table, (hash_link *) x);
    xfree(x->hash.key);
    memFree((void *) x, MEM_NET_DB_NAME);
}
Ejemplo n.º 14
0
static void
cacheDestroy(Cache * cache)
{
    CacheEntry *e = NULL;
    hash_table *hash;
    assert(cache);
    hash = cache->hash;
    /* destroy hash table contents */
    hash_first(hash);
    while (e = hash_next(hash)) {
	hash_remove_link(hash, (hash_link *) e);
	cacheEntryDestroy(e);
    }
    /* destroy the hash table itself */
    hashFreeMemory(hash);
    if (cache->digest)
	cacheDigestDestroy(cache->digest);
    xfree(cache);
}
Ejemplo n.º 15
0
void
delayUnregisterDelayIdPtr(delay_id * loc)
{
    hash_link *lnk;
    if (!delay_id_ptr_hash)
	return;
    /*
     * If we went through a reconfigure, then all the delay_id's
     * got set to zero, and they were removed from our hash
     * table.
     */
    if (*loc == 0)
	return;
    lnk = hash_lookup(delay_id_ptr_hash, loc);
    assert(lnk);
    hash_remove_link(delay_id_ptr_hash, lnk);
    xxfree(lnk);
    memory_used -= sizeof(*lnk);
}
Ejemplo n.º 16
0
void
authenticateFreeProxyAuthUser(void *data)
{
	auth_user_t *u = data;
	auth_user_request_t *auth_user_request;
	dlink_node *link, *tmplink;
	assert(data != NULL);
	debug(29, 5) ("authenticateFreeProxyAuthUser: Freeing auth_user '%p' with refcount '%ld'.\n", u, (long int) u->references);
	assert(u->references == 0);
	/* were they linked in by username ? */
	if (u->usernamehash)
	{
		assert(u->usernamehash->auth_user == u);
		debug(29, 5) ("authenticateFreeProxyAuthUser: removing usernamehash entry '%p'\n", u->usernamehash);
		hash_remove_link(proxy_auth_username_cache,
						 (hash_link *) u->usernamehash);
		/* don't free the key as we use the same user string as the auth_user
		 * structure */
		memFree(u->usernamehash, MEM_AUTH_USER_HASH);
	}
	/* remove any outstanding requests */
	link = u->requests.head;
	while (link)
	{
		debug(29, 5) ("authenticateFreeProxyAuthUser: removing request entry '%p'\n", link->data);
		auth_user_request = link->data;
		tmplink = link;
		link = link->next;
		dlinkDelete(tmplink, &u->requests);
		dlinkNodeDelete(tmplink);
		authenticateAuthUserRequestFree(auth_user_request);
	}
	/* free cached acl results */
	aclCacheMatchFlush(&u->proxy_match_cache);
	/* free seen ip address's */
	authenticateAuthUserClearIp(u);
	if (u->scheme_data && u->auth_module > 0)
		authscheme_list[u->auth_module - 1].FreeUser(u);
	/* prevent accidental reuse */
	u->auth_type = AUTH_UNKNOWN;
	memFree(u, MEM_AUTH_USER_T);
}
Ejemplo n.º 17
0
static void
clientdbGC(void *unused)
{
    static int bucket = 0;
    hash_link *link_next;

    link_next = hash_get_bucket(client_table, bucket++);
    while (link_next != NULL) {
	ClientInfo *c = (ClientInfo *) link_next;
	int age = squid_curtime - c->last_seen;
	link_next = link_next->next;
	if (c->n_established)
	    continue;

	if (age < 24 * 3600 && c->Http.n_requests > 100)
	    continue;
	if (age < 4 * 3600 && (c->Http.n_requests > 10 || c->Icp.n_requests > 10))
	    continue;
	if (age < 5 * 60 && (c->Http.n_requests > 1 || c->Icp.n_requests > 1))
	    continue;
	if (age < 60)
	    continue;
	hash_remove_link(client_table, &c->hash);
	clientdbFreeItem(c);
	statCounter.client_http.clients--;
	cleanup_removed++;
    }

    if (bucket < CLIENT_DB_HASH_SIZE)
	eventAdd("client_db garbage collector", clientdbGC, NULL, 0.15, 0);
    else {
	bucket = 0;
	cleanup_running = 0;
	max_clients = statCounter.client_http.clients * 3 / 2;
	if (!cleanup_scheduled) {
	    cleanup_scheduled = 1;
	    eventAdd("client_db garbage collector", clientdbScheduledGC, NULL, 3 * 3600, 0);
	}
	debug(49, 2) ("clientdbGC: Removed %d entries\n", cleanup_removed);
    }
}
Ejemplo n.º 18
0
static void
idnsCallback(idns_query * q, rfc1035_rr * answers, int n, const char *error)
{
    int valid;
    valid = cbdataValid(q->callback_data);
    cbdataUnlock(q->callback_data);
    if (valid)
	q->callback(q->callback_data, answers, n, error);
    while (q->queue) {
	idns_query *q2 = q->queue;
	q->queue = q2->queue;
	valid = cbdataValid(q2->callback_data);
	cbdataUnlock(q2->callback_data);
	if (valid)
	    q2->callback(q2->callback_data, answers, n, error);
	cbdataFree(q2);
    }
    if (q->hash.key) {
	hash_remove_link(idns_lookup_hash, &q->hash);
	q->hash.key = NULL;
    }
}
Ejemplo n.º 19
0
static int
cacheIndexScan(CacheIndex * idx, const char *fname, FILE * file)
{
    int count = 0;
    storeSwapLogData s;
    fprintf(stderr, "%s scanning\n", fname);
    while (fread(&s, sizeof(s), 1, file) == 1) {
	count++;
	idx->scanned_count++;
	/* if (s.op <= SWAP_LOG_NOP || s.op >= SWAP_LOG_MAX)
	 * continue; */
	if (s.op == SWAP_LOG_ADD) {
	    CacheEntry *olde = (CacheEntry *) hash_lookup(idx->hash, s.key);
	    if (olde) {
		idx->bad_add_count++;
	    } else {
		CacheEntry *e = cacheEntryCreate(&s);
		hash_join(idx->hash, (hash_link *) e);
		idx->count++;
	    }
	} else if (s.op == SWAP_LOG_DEL) {
	    CacheEntry *olde = (CacheEntry *) hash_lookup(idx->hash, s.key);
	    if (!olde)
		idx->bad_del_count++;
	    else {
		assert(idx->count);
		hash_remove_link(idx->hash, (hash_link *) olde);
		cacheEntryDestroy(olde);
		idx->count--;
	    }
	} else {
	    fprintf(stderr, "%s:%d: unknown swap log action\n", fname, count);
	    exit(-3);
	}
    }
    fprintf(stderr, "%s:%d: scanned (size: %d bytes)\n",
	fname, count, (int) (count * sizeof(CacheEntry)));
    return count;
}
Ejemplo n.º 20
0
static void
idnsGrokReply(const char *buf, size_t sz)
{
    int n;
    rfc1035_message *message = NULL;
    idns_query *q;
    n = rfc1035MessageUnpack(buf,
	sz,
	&message);
    if (message == NULL) {
	debug(78, 2) ("idnsGrokReply: Malformed DNS response\n");
	return;
    }
    debug(78, 3) ("idnsGrokReply: ID %#hx, %d answers\n", message->id, n);

    q = idnsFindQuery(message->id);

    if (q == NULL) {
	debug(78, 3) ("idnsGrokReply: Late response\n");
	rfc1035MessageDestroy(message);
	return;
    }
    if (rfc1035QueryCompare(&q->query, message->query) != 0) {
	debug(78, 3) ("idnsGrokReply: Query mismatch (%s != %s)\n", q->query.name, message->query->name);
	rfc1035MessageDestroy(message);
	return;
    }
    dlinkDelete(&q->lru, &lru_list);
    if (message->tc && q->tcp_socket == -1) {
	debug(78, 2) ("idnsGrokReply: Response for %s truncated. Retrying using TCP\n", message->query->name);
	rfc1035MessageDestroy(message);
	idnsRetryTcp(q);
	return;
    }
    idnsRcodeCount(n, q->attempt);
    q->error = NULL;
    if (n < 0) {
	debug(78, 3) ("idnsGrokReply: error %s (%d)\n", rfc1035_error_message, rfc1035_errno);
	q->error = rfc1035_error_message;
	q->rcode = -n;
	if (q->rcode == 2 && ++q->attempt < MAX_ATTEMPT) {
	    /*
	     * RCODE 2 is "Server failure - The name server was
	     * unable to process this query due to a problem with
	     * the name server."
	     */
	    rfc1035MessageDestroy(message);
	    q->start_t = current_time;
	    q->id = idnsQueryID();
	    rfc1035SetQueryID(q->buf, q->id);
	    idnsSendQuery(q);
	    return;
	}
	if (q->rcode == 3 && q->do_searchpath && q->attempt < MAX_ATTEMPT) {
	    strcpy(q->name, q->orig);
	    if (q->domain < npc) {
		strcat(q->name, ".");
		strcat(q->name, searchpath[q->domain].domain);
		debug(78, 3) ("idnsGrokReply: searchpath used for %s\n",
		    q->name);
		q->domain++;
	    } else {
		q->attempt++;
	    }
	    rfc1035MessageDestroy(message);
	    if (q->hash.key) {
		hash_remove_link(idns_lookup_hash, &q->hash);
		q->hash.key = NULL;
	    }
	    q->start_t = current_time;
	    q->id = idnsQueryID();
	    rfc1035SetQueryID(q->buf, q->id);
	    q->sz = rfc1035BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id,
		&q->query);

	    idnsCacheQuery(q);
	    idnsSendQuery(q);
	    return;
	}
    }
    idnsCallback(q, message->answer, n, q->error);
    rfc1035MessageDestroy(message);

    idnsTcpCleanup(q);
    cbdataFree(q);
}