/* * del_from_accept * * inputs - pointer to source client * - pointer to target client * output - NONE * side effects - Delete's source pointer to targets allow list * * Walk through the target's accept list, remove if source is found, * Then walk through the source's on_accept_list remove target if found. */ void del_from_accept(struct Client *source, struct Client *target) { dlink_node *ptr; dlink_node *ptr2; dlink_node *next_ptr; dlink_node *next_ptr2; struct Client *target_p; for (ptr = target->allow_list.head; ptr; ptr = next_ptr) { next_ptr = ptr->next; target_p = ptr->data; if(source == target_p) { dlinkDelete(ptr, &target->allow_list); free_dlink_node(ptr); for (ptr2 = source->on_allow_list.head; ptr2; ptr2 = next_ptr2) { next_ptr2 = ptr2->next; target_p = ptr2->data; if (target == target_p) { dlinkDelete(ptr2, &source->on_allow_list); free_dlink_node(ptr2); } } } } }
static StoreEntry * lru_purgeNext(RemovalPurgeWalker * walker) { LruPurgeData *lru_walker = walker->_data; RemovalPolicy *policy = walker->_policy; LruPolicyData *lru = policy->_data; LruNode *lru_node; StoreEntry *entry; try_again: lru_node = lru_walker->current; if (!lru_node || walker->scanned >= walker->max_scan) return NULL; walker->scanned += 1; lru_walker->current = (LruNode *) lru_node->node.next; if (lru_walker->current == lru_walker->start) { /* Last node found */ lru_walker->current = NULL; } entry = (StoreEntry *) lru_node->node.data; dlinkDelete(&lru_node->node, &lru->list); if (storeEntryLocked(entry)) { /* Shit, it is locked. we can't return this one */ walker->locked++; dlinkAddTail(entry, &lru_node->node, &lru->list); goto try_again; } memPoolFree(lru_node_pool, lru_node); lru->count -= 1; SET_POLICY_NODE(entry, NULL); return entry; }
static void authDigestNonceUserUnlink(digest_nonce_h * nonce) { digest_user_h *digest_user; dlink_node *link, *tmplink; if (!nonce) return; if (!nonce->auth_user) return; digest_user = nonce->auth_user->scheme_data; /* unlink from the user list. Yes we're crossing structures but this is the only * time this code is needed */ link = digest_user->nonces.head; while (link) { tmplink = link; link = link->next; if (tmplink->data == nonce) { dlinkDelete(tmplink, &digest_user->nonces); authDigestNonceUnlink(tmplink->data); dlinkNodeDelete(tmplink); link = NULL; } } /* this reference to auth_user was not locked because freeeing the auth_user frees * the nonce too. */ nonce->auth_user = NULL; }
void dbuf_delete(struct dbuf_queue *qptr, size_t count) { dlink_node *ptr; struct dbuf_block *first; assert(qptr->total_size >= count); if (count == 0) return; /* free whole blocks first.. */ while (1) { if (!count) return; ptr = qptr->blocks.head; first = ptr->data; if (count < first->size) break; qptr->total_size -= first->size; count -= first->size; dlinkDelete(ptr, &qptr->blocks); free_dlink_node(ptr); BlockHeapFree(dbuf_heap, first); } /* ..then remove data from the beginning of the queue */ first->size -= count; qptr->total_size -= count; memmove((void *) &first->data, (void *) &first->data[count], first->size); }
static void authenticateAuthUserRequestFree(auth_user_request_t * auth_user_request) { dlink_node *link; debug(29, 5) ("authenticateAuthUserRequestFree: freeing request %p\n", auth_user_request); if (!auth_user_request) return; assert(auth_user_request->references == 0); if (auth_user_request->auth_user) { if (auth_user_request->scheme_data != NULL) { /* we MUST know the module */ assert((auth_user_request->auth_user->auth_module > 0)); /* and the module MUST support requestFree if it has created scheme data */ assert(authscheme_list[auth_user_request->auth_user->auth_module - 1].requestFree != NULL); authscheme_list[auth_user_request->auth_user->auth_module - 1].requestFree(auth_user_request); } /* unlink from the auth_user struct */ link = auth_user_request->auth_user->requests.head; while (link && (link->data != auth_user_request)) link = link->next; assert(link != NULL); dlinkDelete(link, &auth_user_request->auth_user->requests); dlinkNodeDelete(link); /* unlock the request structure's lock */ authenticateAuthUserUnlock(auth_user_request->auth_user); auth_user_request->auth_user = NULL; } else assert(auth_user_request->scheme_data == NULL); if (auth_user_request->message) xfree(auth_user_request->message); memPoolFree(auth_user_request_pool, auth_user_request); }
/* * Combine two user structs. ONLY to be called from within a scheme * module. The scheme module is responsible for ensuring that the * two users _can_ be merged without invalidating all the request * scheme data. the scheme is also responsible for merging any user * related scheme data itself. */ void authenticateAuthUserMerge(auth_user_t * from, auth_user_t * to) { dlink_node *link, *tmplink; auth_user_request_t *auth_user_request; /* * XXX combine two authuser structs. Incomplete: it should merge * in hash references too and ask the module to merge in scheme * data */ debug(29, 5) ("authenticateAuthUserMerge auth_user '%p' into auth_user '%p'.\n", from, to); link = from->requests.head; while (link) { auth_user_request = link->data; tmplink = link; link = link->next; dlinkDelete(tmplink, &from->requests); dlinkAddTail(auth_user_request, tmplink, &to->requests); auth_user_request->auth_user = to; } to->references += from->references; from->references = 0; authenticateFreeProxyAuthUser(from); }
static void idnsCheckQueue(void *unused) { dlink_node *n; dlink_node *p = NULL; idns_query *q; event_queued = 0; for (n = lru_list.tail; n; n = p) { q = n->data; if (tvSubDsec(q->sent_t, current_time) < 5.0) break; debug(78, 3) ("idnsCheckQueue: ID %#04x timeout\n", q->id); p = n->prev; dlinkDelete(&q->lru, &lru_list); if (q->nsends < IDNS_MAX_TRIES) { idnsSendQuery(q); } else { int v = cbdataValid(q->callback_data); debug(78, 1) ("idnsCheckQueue: ID %x: giving up after %d tries and %5.1f seconds\n", (int) q->id, q->nsends, tvSubDsec(q->start_t, current_time)); cbdataUnlock(q->callback_data); if (v) q->callback(q->callback_data, NULL, 0); memFree(q, MEM_IDNS_QUERY); } } idnsTickleQueue(); }
static void idnsCheckQueue(void *unused) { dlink_node *n; dlink_node *p = NULL; idns_query *q; event_queued = 0; if (0 == nns) /* name servers went away; reconfiguring or shutting down */ return; for (n = lru_list.tail; n; n = p) { p = n->prev; q = n->data; /* Anything to process in the queue? */ if (tvSubDsec(q->queue_t, current_time) < Config.Timeout.idns_retransmit) break; /* Query timer expired? */ if (tvSubDsec(q->sent_t, current_time) < Config.Timeout.idns_retransmit * 1 << ((q->nsends - 1) / nns)) { dlinkDelete(&q->lru, &lru_list); q->queue_t = current_time; dlinkAdd(q, &q->lru, &lru_list); continue; } debug(78, 3) ("idnsCheckQueue: ID %#04x timeout\n", q->id); dlinkDelete(&q->lru, &lru_list); if (tvSubDsec(q->start_t, current_time) < Config.Timeout.idns_query) { idnsSendQuery(q); } else { debug(78, 2) ("idnsCheckQueue: ID %x: giving up after %d tries and %5.1f seconds\n", (int) q->id, q->nsends, tvSubDsec(q->start_t, current_time)); if (q->rcode != 0) idnsCallback(q, NULL, -q->rcode, q->error); else idnsCallback(q, NULL, -16, "Timeout"); idnsTcpCleanup(q); cbdataFree(q); } } idnsTickleQueue(); }
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); }
static void externalAclHandleReply(void *data, char *reply) { externalAclState *state = data; externalAclState *next; int result = 0; char *status; char *token; char *value; char *t; char *user = NULL; char *error = NULL; external_acl_entry *entry = NULL; debug(82, 2) ("externalAclHandleReply: reply=\"%s\"\n", reply); if (reply) { status = strwordtok(reply, &t); if (status && strcmp(status, "OK") == 0) result = 1; while ((token = strwordtok(NULL, &t))) { value = strchr(token, '='); if (value) { *value++ = '\0'; /* terminate the token, and move up to the value */ if (strcmp(token, "user") == 0) user = value; else if (strcmp(token, "error") == 0) error = value; } } } dlinkDelete(&state->list, &state->def->queue); if (cbdataValid(state->def)) { if (reply) entry = external_acl_cache_add(state->def, state->key, result, user, error); else { external_acl_entry *oldentry = hash_lookup(state->def->cache, state->key); if (oldentry) external_acl_cache_delete(state->def, oldentry); } } do { cbdataUnlock(state->def); state->def = NULL; if (cbdataValid(state->callback_data)) state->callback(state->callback_data, entry); cbdataUnlock(state->callback_data); state->callback_data = NULL; next = state->queue; cbdataFree(state); state = next; } while (state); }
static inline void authenticateAuthUserRemoveIpEntry(auth_user_t * auth_user, auth_user_ip_t * ipdata) { /* remove the node */ dlinkDelete(&ipdata->node, &auth_user->ip_list); authenticateAuthUserRequestUnlinkIp(ipdata->ipaddr); cbdataFree(ipdata); /* catch incipient underflow */ assert(auth_user->ipcount); auth_user->ipcount--; }
static void lru_referenced(RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node) { LruPolicyData *lru = policy->_data; LruNode *lru_node = node->data; if (!lru_node) return; dlinkDelete(&lru_node->node, &lru->list); dlinkAddTail((void *) entry, &lru_node->node, &lru->list); }
static helper_stateful_request * StatefulDequeue(statefulhelper * hlp) { dlink_node *link; helper_stateful_request *r = NULL; if ((link = hlp->queue.head)) { r = link->data; dlinkDelete(link, &hlp->queue); memFree(link, MEM_DLINK_NODE); hlp->stats.queue_size--; } return r; }
void exit_aborted_clients(void) { dlink_node *ptr, *next; struct Client *target_p; for(ptr = abort_list.head; ptr; ptr = next) { target_p = ptr->data; next = ptr->next; if (ptr->data == NULL) { sendto_realops_flags(FLAGS_ALL, L_ALL, "Warning: null client on abort_list!"); dlinkDelete(ptr, &abort_list); free_dlink_node(ptr); continue; } dlinkDelete(ptr, &abort_list); exit_client(target_p, target_p, &me, "Dead link"); free_dlink_node(ptr); } }
static void authenticateAuthUserRequestSetIp(auth_user_request_t * auth_user_request, struct in_addr ipaddr) { auth_user_ip_t *ipdata, *tempnode; auth_user_t *auth_user; char *ip1; int found = 0; CBDATA_INIT_TYPE(auth_user_ip_t); if (!auth_user_request->auth_user) return; auth_user = auth_user_request->auth_user; ipdata = (auth_user_ip_t *) auth_user->ip_list.head; /* * we walk the entire list to prevent the first item in the list * preventing old entries being flushed and locking a user out after * a timeout+reconfigure */ while (ipdata) { tempnode = (auth_user_ip_t *) ipdata->node.next; /* walk the ip list */ if (ipdata->ipaddr.s_addr == ipaddr.s_addr) { /* This ip has already been seen. */ found = 1; /* update IP ttl */ ipdata->ip_expiretime = squid_curtime; } else if (ipdata->ip_expiretime + Config.authenticateIpTTL < squid_curtime) { /* This IP has expired - remove from the seen list */ dlinkDelete(&ipdata->node, &auth_user->ip_list); cbdataFree(ipdata); /* catch incipient underflow */ assert(auth_user->ipcount); auth_user->ipcount--; } ipdata = tempnode; } if (found) return; /* This ip is not in the seen list */ ipdata = cbdataAlloc(auth_user_ip_t); ipdata->ip_expiretime = squid_curtime; ipdata->ipaddr = ipaddr; dlinkAddTail(ipdata, &ipdata->node, &auth_user->ip_list); auth_user->ipcount++; ip1 = xstrdup(inet_ntoa(ipaddr)); debug(29, 2) ("authenticateAuthUserRequestSetIp: user '%s' has been seen at a new IP address (%s)\n ", authenticateUserUsername(auth_user), ip1); safe_free(ip1); }
static void free_exited_clients(void *unused) { dlink_node *ptr, *next; struct Client *target_p; for(ptr = dead_list.head; ptr; ptr = next) { target_p = ptr->data; next = ptr->next; if (ptr->data == NULL) { sendto_realops_flags(FLAGS_ALL, L_ALL, "Warning: null client on dead_list!"); dlinkDelete(ptr, &dead_list); free_dlink_node(ptr); continue; } release_client_state(target_p); free_client(target_p); dlinkDelete(ptr, &dead_list); free_dlink_node(ptr); } }
int aioCheckCallbacks(SwapDir * SD) { squidaio_result_t *resultp; squidaio_ctrl_t *ctrlp; AIOCB *done_handler; void *their_data; int retval = 0; assert(initialised); squidaio_counts.check_callback++; for (;;) { if ((resultp = squidaio_poll_done()) == NULL) break; ctrlp = (squidaio_ctrl_t *) resultp->data; if (ctrlp == NULL) continue; /* XXX Should not happen */ dlinkDelete(&ctrlp->node, &used_list); if ((done_handler = ctrlp->done_handler)) { their_data = ctrlp->done_handler_data; ctrlp->done_handler = NULL; ctrlp->done_handler_data = NULL; if (cbdataValid(their_data)) { retval = 1; /* Return that we've actually done some work */ done_handler(ctrlp->fd, their_data, ctrlp->bufp, ctrlp->result.aio_return, ctrlp->result.aio_errno); } else { if (ctrlp->operation == _AIO_OPEN) { /* The open operation was aborted.. */ int fd = ctrlp->result.aio_return; if (fd >= 0) aioClose(fd); } } cbdataUnlock(their_data); } /* free data if requested to aioWrite() */ if (ctrlp->free_func) ctrlp->free_func(ctrlp->bufp); /* free temporary read buffer */ if (ctrlp->operation == _AIO_READ) squidaio_xfree(ctrlp->bufp, ctrlp->len); if (ctrlp->operation == _AIO_CLOSE) aioFDWasClosed(ctrlp->fd); memPoolFree(squidaio_ctrl_pool, ctrlp); } return retval; }
static void idnsGrokReply(const char *buf, size_t sz) { int n; int valid; rfc1035_rr *answers = NULL; unsigned short rid = 0xFFFF; idns_query *q; n = rfc1035AnswersUnpack(buf, sz, &answers, &rid); debug(78, 3) ("idnsGrokReply: ID %#hx, %d answers\n", rid, n); if (rid == 0xFFFF) { debug(78, 1) ("idnsGrokReply: Unknown error\n"); /* XXX leak answers? */ return; } q = idnsFindQuery(rid); if (q == NULL) { debug(78, 3) ("idnsGrokReply: Late response\n"); rfc1035RRDestroy(answers, n); return; } dlinkDelete(&q->lru, &lru_list); idnsRcodeCount(n, q->attempt); if (n < 0) { debug(78, 3) ("idnsGrokReply: error %d\n", rfc1035_errno); if (-2 == n && ++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." */ assert(NULL == answers); q->start_t = current_time; q->id = rfc1035RetryQuery(q->buf); idnsSendQuery(q); return; } } valid = cbdataValid(q->callback_data); cbdataUnlock(q->callback_data); if (valid) q->callback(q->callback_data, answers, n); rfc1035RRDestroy(answers, n); memFree(q, MEM_IDNS_QUERY); }
void * _BlockHeapAlloc(BlockHeap * bh) { Block *walker; dlink_node *new_node; assert(bh != NULL); if (bh == NULL) { return(NULL); } if (bh->freeElems == 0) { /* Allocate new block and assign */ /* newblock returns 1 if unsuccessful, 0 if not */ if (newblock(bh)) { /* That didn't work..try to garbage collect */ BlockHeapGarbageCollect(bh); if(bh->freeElems == 0) { outofmemory(); /* Well that didn't work either...bail */ } } } for (walker = bh->base; walker != NULL; walker = walker->next) { if (walker->freeElems > 0) { bh->freeElems--; walker->freeElems--; new_node = walker->free_list.head; dlinkDelete(new_node, &walker->free_list); dlinkAdd(new_node->data, new_node, &walker->used_list); assert(new_node->data != NULL); if(new_node->data == NULL) outofmemory(); return (new_node->data); } } assert(0 == 1); return(NULL); /* If you get here, something bad happened ! */ }
/*! \brief Returns a pointer to a struct within our BlockHeap that's free for * the taking. * \param bh Pointer to the Blockheap * \return Address pointer to allocated data space, or NULL if unsuccessful */ void * BlockHeapAlloc(BlockHeap *bh) { Block *walker = NULL; dlink_node *new_node = NULL; assert(bh != NULL); if (bh->freeElems == 0) { /* Allocate new block and assign */ /* newblock returns 1 if unsuccessful, 0 if not */ if (newblock(bh)) { /* That didn't work..try to garbage collect */ BlockHeapGarbageCollect(bh); if (newblock(bh)) outofmemory(); /* Well that didn't work either...bail */ } } for (walker = bh->base; walker != NULL; walker = walker->next) { if (walker->freeElems > 0) { --bh->freeElems; --walker->freeElems; new_node = walker->free_list.head; dlinkDelete(new_node, &walker->free_list); assert(new_node->data != NULL); memset(new_node->data, 0, bh->elemSize); return new_node->data; } } assert(0 == 1); outofmemory(); return NULL; }
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); }
/* * This routine hasn't been optimised to take advantage of the * passed sc. Yet. */ int storeUnregister(store_client * sc, StoreEntry * e, void *data) { MemObject *mem = e->mem_obj; #if STORE_CLIENT_LIST_DEBUG assert(sc == storeClientListSearch(e->mem_obj, data)); #endif if (mem == NULL) return 0; debug(20, 3) ("storeUnregister: called for '%s'\n", storeKeyText(e->hash.key)); if (sc == NULL) return 0; if (mem->clients.head == NULL) return 0; dlinkDelete(&sc->node, &mem->clients); mem->nclients--; if (e->store_status == STORE_OK && e->swap_status != SWAPOUT_DONE) storeSwapOut(e); if (sc->swapin_sio) { storeClose(sc->swapin_sio); cbdataUnlock(sc->swapin_sio); sc->swapin_sio = NULL; statCounter.swap.ins++; } if (NULL != sc->callback) { /* callback with ssize = -1 to indicate unexpected termination */ debug(20, 3) ("storeUnregister: store_client for %s has a callback\n", mem->url); storeClientCallback(sc, -1); } #if DELAY_POOLS delayUnregisterDelayIdPtr(&sc->delay_id); #endif cbdataUnlock(sc->callback_data); /* we're done with it now */ /*assert(!sc->flags.disk_io_pending); */ cbdataFree(sc); assert(e->lock_count > 0); storeSwapOutMaintainMemObject(e); if (mem->nclients == 0) CheckQuickAbort(e); return 1; }
static void lru_remove(RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node) { LruPolicyData *lru = policy->_data; LruNode *lru_node = node->data; if (!lru_node) return; /* * It seems to be possible for an entry to exist in the hash * but not be in the LRU list, so check for that case rather * than suffer a NULL pointer access. */ if (NULL == lru_node->node.data) return; assert(lru_node->node.data == entry); node->data = NULL; dlinkDelete(&lru_node->node, &lru->list); memPoolFree(lru_node_pool, lru_node); lru->count -= 1; }
static void authenticateAuthUserClearIp(auth_user_t * auth_user) { auth_user_ip_t *ipdata, *tempnode; if (!auth_user) return; ipdata = (auth_user_ip_t *) auth_user->ip_list.head; while (ipdata) { tempnode = (auth_user_ip_t *) ipdata->node.next; /* walk the ip list */ dlinkDelete(&ipdata->node, &auth_user->ip_list); cbdataFree(ipdata); /* catch incipient underflow */ assert(auth_user->ipcount); auth_user->ipcount--; ipdata = tempnode; } /* integrity check */ assert(auth_user->ipcount == 0); }
/* * This routine hasn't been optimised to take advantage of the * passed sc. Yet. */ int storeClientUnregister(store_client * sc, StoreEntry * e, void *owner) { MemObject *mem = e->mem_obj; if (sc == NULL) return 0; debug(20, 3) ("storeClientUnregister: called for '%s'\n", storeKeyText(e->hash.key)); #if STORE_CLIENT_LIST_DEBUG assert(sc == storeClientListSearch(e->mem_obj, owner)); #endif assert(sc->entry == e); if (mem->clients.head == NULL) return 0; dlinkDelete(&sc->node, &mem->clients); mem->nclients--; if (e->store_status == STORE_OK && e->swap_status != SWAPOUT_DONE) storeSwapOut(e); if (sc->swapin_sio) { storeClose(sc->swapin_sio); cbdataUnlock(sc->swapin_sio); sc->swapin_sio = NULL; statCounter.swap.ins++; } if (NULL != sc->new_callback) { /* callback with ssize = -1 to indicate unexpected termination */ debug(20, 3) ("storeClientUnregister: store_client for %s has a callback\n", mem->url); storeClientCallback(sc, -1); } stmemNodeUnref(&sc->node_ref); #if DELAY_POOLS delayUnregisterDelayIdPtr(&sc->delay_id); #endif storeSwapOutMaintainMemObject(e); if (mem->nclients == 0) CheckQuickAbort(e); storeUnlockObject(sc->entry); sc->entry = NULL; cbdataFree(sc); return 1; }
/* ************************************************************************ */ int _BlockHeapFree(BlockHeap * bh, void *ptr) { Block *block; struct MemBlock *memblock; assert(bh != NULL); assert(ptr != NULL); if (bh == NULL) { ilog(L_NOTICE, "balloc.c:BlockHeapFree() bh == NULL"); return(1); } if (ptr == NULL) { ilog(L_NOTICE, "balloc.BlockHeapFree() ptr == NULL"); return(1); } memblock = (void *)((size_t)ptr - sizeof(MemBlock)); assert(memblock->block != NULL); if(memblock->block == NULL) { outofmemory(); } /* Is this block really on the used list? */ assert(dlinkFind(&memblock->block->used_list, memblock) == NULL); block = memblock->block; bh->freeElems++; block->freeElems++; mem_frob(ptr, bh->elemSize); dlinkDelete(&memblock->self, &block->used_list); dlinkAdd(ptr, &memblock->self, &block->free_list); return(0); }
static void helperStatefulServerFree(int fd, void *data) { helper_stateful_server *srv = data; statefulhelper *hlp = srv->parent; helper_stateful_request *r; assert(srv->rfd == fd); if (srv->buf) { memFree(srv->buf, MEM_8K_BUF); srv->buf = NULL; } if ((r = srv->request)) { if (cbdataValid(r->data)) r->callback(r->data, srv, srv->buf); helperStatefulRequestFree(r); srv->request = NULL; } /* TODO: walk the local queue of requests and carry them all out */ if (srv->wfd != srv->rfd && srv->wfd != -1) comm_close(srv->wfd); dlinkDelete(&srv->link, &hlp->servers); hlp->n_running--; assert(hlp->n_running >= 0); if (!srv->flags.shutdown) { debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", hlp->id_name, srv->index + 1, fd); if (hlp->n_running <= hlp->n_to_start / 2) { debug(80, 0) ("Too few %s processes are running", hlp->id_name); if (hlp->last_restart > squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); debug(80, 0) ("Starting new helpers\n"); helperStatefulOpenServers(hlp); } } if (srv->data != NULL) memPoolFree(hlp->datapool, srv->data); cbdataUnlock(srv->parent); cbdataFree(srv); }
static void authenticateDigestUserFree(auth_user_t * auth_user) { digest_user_h *digest_user = auth_user->scheme_data; dlink_node *link, *tmplink; debug(29, 9) ("authenticateDigestFreeUser: Clearing Digest scheme data\n"); if (!digest_user) return; safe_free(digest_user->username); link = digest_user->nonces.head; while (link) { tmplink = link; link = link->next; dlinkDelete(tmplink, &digest_user->nonces); authDigestNoncePurge(tmplink->data); authDigestNonceUnlink(tmplink->data); dlinkNodeDelete(tmplink); } memPoolFree(digest_user_pool, auth_user->scheme_data); auth_user->scheme_data = NULL; }
void aioCancel(int fd) { squidaio_ctrl_t *ctrlp; AIOCB *done_handler; void *their_data; dlink_node *m, *next; assert(initialised); squidaio_counts.cancel++; for (m = used_list.head; m; m = next) { next = m->next; ctrlp = m->data; if (ctrlp->fd != fd) continue; squidaio_cancel(&ctrlp->result); if ((done_handler = ctrlp->done_handler)) { their_data = ctrlp->done_handler_data; ctrlp->done_handler = NULL; ctrlp->done_handler_data = NULL; debug(32, 0) ("this be aioCancel. Danger ahead!\n"); if (cbdataValid(their_data)) done_handler(fd, their_data, NULL, -2, -2); cbdataUnlock(their_data); /* free data if requested to aioWrite() */ if (ctrlp->free_func) ctrlp->free_func(ctrlp->bufp); /* free temporary read buffer */ if (ctrlp->operation == _AIO_READ) squidaio_xfree(ctrlp->bufp, ctrlp->len); } dlinkDelete(m, &used_list); memPoolFree(squidaio_ctrl_pool, ctrlp); } }
void authenticateAuthUserRequestRemoveIp(auth_user_request_t * auth_user_request, struct in_addr ipaddr) { auth_user_ip_t *ipdata; auth_user_t *auth_user; if (!auth_user_request->auth_user) return; auth_user = auth_user_request->auth_user; ipdata = (auth_user_ip_t *) auth_user->ip_list.head; while (ipdata) { /* walk the ip list */ if (ipdata->ipaddr.s_addr == ipaddr.s_addr) { /* remove the node */ dlinkDelete(&ipdata->node, &auth_user->ip_list); cbdataFree(ipdata); /* catch incipient underflow */ assert(auth_user->ipcount); auth_user->ipcount--; return; } ipdata = (auth_user_ip_t *) ipdata->node.next; } }