//???????ͷŵ?callback static int free_callback(void* param) { int loop; struct mod_conf_param* data = (struct mod_conf_param*) param; if(data) { for(loop=0; loop<data->count; loop++) { if(data->acp[loop]) { if(data->acp[loop]->hdr) { if(strLen(data->acp[loop]->hdr->header)) stringClean(&data->acp[loop]->hdr->header); if(strLen(data->acp[loop]->hdr->value)) stringClean(&data->acp[loop]->hdr->value); memPoolFree(header_info_pool, data->acp[loop]->hdr); data->acp[loop]->hdr = NULL; } memPoolFree(action_part_pool, data->acp[loop]); data->acp[loop] = NULL; } } memPoolFree(mod_config_pool, data); data = NULL; } return 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); }
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; }
void aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data) { aio_ctrl_t *ctrlp; assert(initialised); aio_counts.stat++; ctrlp = memPoolAlloc(aio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_STAT; cbdataLock(callback_data); if (aio_stat(path, sb, &ctrlp->result) < 0) { if (errno == ENOMEM || errno == EAGAIN || errno == EINVAL) errno = EWOULDBLOCK; if (callback) (callback) (ctrlp->fd, callback_data, -1, errno); cbdataUnlock(callback_data); memPoolFree(aio_ctrl_pool, ctrlp); return; } ctrlp->next = used_list; used_list = ctrlp; return; } /* aioStat */
void aioUnlink(const char *pathname, AIOCB * callback, void *callback_data) { aio_ctrl_t *ctrlp; char *path; assert(initialised); aio_counts.unlink++; ctrlp = memPoolAlloc(aio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_UNLINK; path = xstrdup(pathname); cbdataLock(callback_data); if (aio_unlink(path, &ctrlp->result) < 0) { int ret = unlink(path); (callback) (ctrlp->fd, callback_data, ret, errno); cbdataUnlock(callback_data); memPoolFree(aio_ctrl_pool, ctrlp); xfree(path); return; } ctrlp->next = used_list; used_list = ctrlp; xfree(path); } /* aioUnlink */
/* delete the digest reuqest structure. Does NOT delete related structures */ static void authDigestRequestDelete(digest_request_h * digest_request) { if (digest_request->nonceb64) xfree(digest_request->nonceb64); if (digest_request->cnonce) xfree(digest_request->cnonce); if (digest_request->realm) xfree(digest_request->realm); if (digest_request->pszPass) xfree(digest_request->pszPass); if (digest_request->algorithm) xfree(digest_request->algorithm); if (digest_request->pszMethod) xfree(digest_request->pszMethod); if (digest_request->qop) xfree(digest_request->qop); if (digest_request->uri) xfree(digest_request->uri); if (digest_request->response) xfree(digest_request->response); if (digest_request->nonce) authDigestNonceUnlink(digest_request->nonce); memPoolFree(digest_request_pool, digest_request); }
void aioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callback_data) { aio_ctrl_t *ctrlp; int ret; assert(initialised); aio_counts.open++; ctrlp = memPoolAlloc(aio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_OPEN; cbdataLock(callback_data); if (aio_open(path, oflag, mode, &ctrlp->result) < 0) { ret = open(path, oflag, mode); if (callback) (callback) (ctrlp->fd, callback_data, ret, errno); cbdataUnlock(callback_data); memPoolFree(aio_ctrl_pool, ctrlp); return; } ctrlp->next = used_list; used_list = ctrlp; return; }
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); }
void chunkedBufferFree(ChunkedBuffer *buffer) { //Properly dispose data chunks chunkedBufferSetLength(buffer, 0); //Release multi-part buffer memPoolFree(buffer); }
cbdataUnlock(const void *p) #endif { cbdata *c; FREE *free_func; if (p == NULL) return; c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data)); assert(c->y == c); debug(45, 3) ("cbdataUnlock: %p\n", p); assert(c != NULL); assert(c->locks > 0); c->locks--; #if CBDATA_DEBUG c->file = file; c->line = line; #endif if (c->valid || c->locks) return; cbdataCount--; debug(45, 3) ("cbdataUnlock: Freeing %p\n", p); free_func = cbdata_index[c->type].free_func; if (free_func) free_func((void *) p); memPoolFree(cbdata_index[c->type].pool, c); }
static int free_callback(void* data) { mod_config *cfg = (mod_config*) data; if(cfg){ memPoolFree(mod_config_pool,cfg); cfg = NULL; } return 0; }
static int free_callback(void* param) { struct mod_conf_param* data = (struct mod_conf_param*) param; if (data) { memPoolFree(mod_config_pool, data); } data = NULL; return 0; }
static int free_timeout(void* data) { int *timeout = (int *)data; if(NULL != timeout) { memPoolFree(timeout_pool, timeout); timeout = NULL; } return 0; }
void squidaio_xfree(void *p, int size) { MemPool *pool; if ((pool = squidaio_get_pool(size)) != NULL) { memPoolFree(pool, p); } else xfree(p); }
static int free_error_page_private_data(void* data) { error_page_private_data* pd = (error_page_private_data*) data; if(NULL != pd) { memPoolFree(error_page_private_data_pool, pd); pd = NULL; } return 0; }
static void authenticateNegotiateFreeUser(auth_user_t * auth_user) { negotiate_user_t *negotiate_user = auth_user->scheme_data; debug(29, 5) ("authenticateNegotiateFreeUser: Clearing Negotiate scheme data\n"); safe_free(negotiate_user->username); memPoolFree(negotiate_user_pool, negotiate_user); auth_user->scheme_data = NULL; }
static void squidaio_xstrfree(char *str) { MemPool *pool; int len = strlen(str) + 1; if ((pool = squidaio_get_pool(len)) != NULL) { memPoolFree(pool, str); } else xfree(str); }
static int free_data(void *data) { MemBuf * mb = (MemBuf*)data; if(NULL != mb && NULL != mb->buf) { memFreeBuf(mb->capacity, mb->buf); memPoolFree(text_mb_pool, mb); mb = NULL; } return 0; }
static int free_request_param(void* data) { request_param *req_param = (request_param *) data; if(req_param != NULL){ close(req_param->m3u8_fd); memBufClean(&(req_param->prevBuf)); memPoolFree(request_param_pool, req_param); req_param = NULL; } return 0; }
void authenticateBasicFreeUser(auth_user_t * auth_user) { basic_data *basic_auth = auth_user->scheme_data; debug(29, 5) ("authenticateBasicFreeUser: Clearing Basic scheme data\n"); if (basic_auth->username) xfree(basic_auth->username); if (basic_auth->passwd) xfree(basic_auth->passwd); memPoolFree(basic_data_pool, auth_user->scheme_data); auth_user->scheme_data = NULL; }
static int free_mod_config(void *data) { mod_config* cfg = (mod_config*)data; if(cfg) { if(NULL != cfg->customized_error_text.buf) memBufClean(&cfg->customized_error_text); memPoolFree(mod_config_pool, cfg); cfg = NULL; } return 0; }
static int cleanup_registered_deferfunc_when_shutdown(cc_module * module) { debug(147, 1)("(mod_helper_defer) -> hook_cleanup:\n"); is_defer_func * temp_node = NULL; while(NULL != is_defer_accept_req_funcs_list) { temp_node = is_defer_accept_req_funcs_list->next; memPoolFree(is_defer_func_pool, is_defer_accept_req_funcs_list); is_defer_accept_req_funcs_list = temp_node; } while(NULL != is_defer_read_req_funcs_list) { temp_node = is_defer_read_req_funcs_list->next; memPoolFree(is_defer_func_pool, is_defer_read_req_funcs_list); is_defer_read_req_funcs_list = temp_node; } return 0; }
/* * Clean up references from the SIO before it gets released. * The actuall SIO is managed by cbdata so we do not need * to bother with that. */ static void storeAufsIOFreeEntry(void *siop) { storeIOState *sio = (storeIOState *) siop; squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate; struct _queued_write *qw; struct _queued_read *qr; while ((qw = linklistShift(&aiostate->pending_writes))) { if (qw->free_func) qw->free_func(qw->buf); memPoolFree(aufs_qwrite_pool, qw); } while ((qr = linklistShift(&aiostate->pending_reads))) { cbdataUnlock(qr->callback_data); memPoolFree(aufs_qread_pool, qr); } if (sio->read.callback_data) cbdataUnlock(sio->read.callback_data); if (sio->callback_data) cbdataUnlock(sio->callback_data); memPoolFree(squidaio_state_pool, aiostate); }
static int storeAufsKickWriteQueue(storeIOState * sio) { squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate; struct _queued_write *q = linklistShift(&aiostate->pending_writes); if (NULL == q) return 0; debug(79, 3) ("storeAufsKickWriteQueue: writing queued chunk of %ld bytes\n", (long int) q->size); storeAufsWrite(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->free_func); memPoolFree(aufs_qwrite_pool, q); return 1; }
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); } }
static int free_callback(void* param) { struct mod_conf_param* data = (struct mod_conf_param*) param; if(data) { if(strLen(data->orig_name)) stringClean(&data->orig_name); if(strLen(data->new_name)) stringClean(&data->new_name); memPoolFree(mod_config_pool, data); data = NULL; } return 0; }
static int storeAufsKickZCopyQueue(storeIOState * sio) { squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate; struct _queued_zcopy *q = linklistShift(&(aiostate->pending_zcopies)); if (NULL == q) return 0; debug(79, 3) ("storeAufsKickReadQueue: zcopying queued request of %ld bytes\n",(long int) q->size); if (cbdataValid(q->callback_data)) storeAufsZCopy(INDEXSD(sio->swap_dirn), sio, q->zc_target_fd, q->size, q->offset, q->callback, q->callback_data); cbdataUnlock(q->callback_data); memPoolFree(aufs_qzcopy_pool, q); return 1; }
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 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); } }
void aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data, FREE * free_func) { aio_ctrl_t *ctrlp; int seekmode; assert(initialised); aio_counts.write++; for (ctrlp = used_list; ctrlp != NULL; ctrlp = ctrlp->next) if (ctrlp->fd == fd) break; if (ctrlp != NULL) { debug(32, 2) ("aioWrite: EWOULDBLOCK\n"); errno = EWOULDBLOCK; if (callback) (callback) (fd, callback_data, -1, errno); free_func(bufp); return; } ctrlp = memPoolAlloc(aio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_WRITE; if (offset >= 0) seekmode = SEEK_SET; else { seekmode = SEEK_END; offset = 0; } cbdataLock(callback_data); if (aio_write(fd, bufp, len, offset, seekmode, &ctrlp->result) < 0) { if (errno == ENOMEM || errno == EAGAIN || errno == EINVAL) errno = EWOULDBLOCK; if (callback) (callback) (fd, callback_data, -1, errno); cbdataUnlock(callback_data); memPoolFree(aio_ctrl_pool, ctrlp); } else { ctrlp->next = used_list; used_list = ctrlp; } /* * aio_write copies the buffer so we can free it here */ free_func(bufp); } /* aioWrite */