/* * add_accept() * * input - pointer to clients accept list to add to * - pointer to client to add * output - none * side effects - target is added to clients list */ static void add_accept(struct Client *source_p, struct Client *target_p) { dlink_node *m; m = make_dlink_node(); dlinkAdd(target_p, m, &source_p->allow_list); m = make_dlink_node() dlinkAdd(source_p, m, &target_p->on_allow_list); }
/* setup the necessary info to log the username */ static void authDigestLogUsername(auth_user_request_t * auth_user_request, char *username) { auth_user_t *auth_user; digest_user_h *digest_user; dlink_node *node; /* log the username */ debug(29, 9) ("authDigestLogUsername: Creating new user for logging '%s'\n", username); /* new auth_user */ auth_user = authenticateAuthUserNew("digest"); /* new scheme data */ digest_user = authDigestUserNew(); /* save the credentials */ digest_user->username = username; /* link the scheme data in */ auth_user->scheme_data = digest_user; /* set the auth_user type */ auth_user->auth_type = AUTH_BROKEN; /* link the request to the user */ auth_user_request->auth_user = auth_user; /* lock for the auth_user_request link */ authenticateAuthUserLock(auth_user); node = dlinkNodeNew(); dlinkAdd(auth_user_request, node, &auth_user->requests); }
/* * check for public repeating and keep/replace appropriate last phrase * -demond */ static int check_repeat(struct Client *source_p, struct Channel *chptr, char *text) { dlink_node *ptr; struct Repeat *repeatptr; for (ptr = source_p->user->repeat.head; ptr; ptr = ptr->next) { repeatptr = ptr->data; if (repeatptr->chptr == chptr) if (!strcmp(repeatptr->text, text)) { return 1; } else { MyFree(repeatptr->text); DupString(repeatptr->text, text); repeatptr->lastphrase = CurrentTime; return 0; } } repeatptr = (struct Repeat *)MyMalloc(sizeof(struct Repeat)); repeatptr->chptr = chptr; DupString(repeatptr->text, text); repeatptr->lastphrase = CurrentTime; ptr = make_dlink_node(); dlinkAdd(repeatptr, ptr, &source_p->user->repeat); return 0; }
/* add client with fd to client list */ store_client * storeClientListAdd(StoreEntry * e, void *data) { MemObject *mem = e->mem_obj; store_client *sc; assert(mem); #if STORE_CLIENT_LIST_DEBUG if (storeClientListSearch(mem, data) != NULL) assert(1 == 0); /* XXX die! */ #endif e->refcount++; mem->nclients++; sc = cbdataAlloc(store_client); cbdataLock(data); /* locked while we point to it */ sc->callback_data = data; sc->seen_offset = 0; sc->copy_offset = 0; sc->flags.disk_io_pending = 0; sc->entry = e; sc->type = storeClientType(e); dlinkAdd(sc, &sc->node, &mem->clients); #if DELAY_POOLS sc->delay_id = 0; #endif return sc; }
static void idnsRetryTcp(idns_query * q) { struct in_addr addr; int ns = (q->nsends - 1) % nns; idnsTcpCleanup(q); if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr) addr = Config.Addrs.udp_outgoing; else addr = Config.Addrs.udp_incoming; q->tcp_socket = comm_open(SOCK_STREAM, IPPROTO_TCP, addr, 0, COMM_NONBLOCKING, "DNS TCP Socket"); q->queue_t = q->sent_t = current_time; dlinkAdd(q, &q->lru, &lru_list); commConnectStart(q->tcp_socket, inet_ntoa(nameservers[ns].S.sin_addr), ntohs(nameservers[ns].S.sin_port), idnsSendTcpQuery, q ); }
static void serv_connect_callback(fde_t *fd, int status, void *data) { struct Client *client = (struct Client*)data; struct Server *server = NULL; assert(client != NULL); server = client->server; assert(server != NULL); assert(&server->fd == fd); if(status != COMM_OK) { ilog(L_CRIT, "serv_connect_callback: Connect failed :("); exit(1); } ilog(L_DEBUG, "serv_connect_callback: Connect succeeded!"); comm_setselect(fd, COMM_SELECT_READ, read_packet, client, 0); dlinkAdd(client, &client->node, &global_server_list); execute_callback(connected_cb, client); }
void aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data, FREE * free_func) { squidaio_ctrl_t *ctrlp; int seekmode; assert(initialised); squidaio_counts.write++; ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_WRITE; ctrlp->bufp = bufp; ctrlp->free_func = free_func; if (offset >= 0) seekmode = SEEK_SET; else { seekmode = SEEK_END; offset = 0; } cbdataLock(callback_data); ctrlp->result.data = ctrlp; squidaio_write(fd, bufp, len, offset, seekmode, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); } /* aioWrite */
static void idnsSendQuery(idns_query * q) { int x; int ns; if (DnsSocket < 0) { debug(78, 1) ("idnsSendQuery: Can't send query, no DNS socket!\n"); return; } /* XXX Select nameserver */ assert(nns > 0); assert(q->lru.next == NULL); assert(q->lru.prev == NULL); ns = q->nsends % nns; x = comm_udp_sendto(DnsSocket, &nameservers[ns].S, sizeof(nameservers[ns].S), q->buf, q->sz); if (x < 0) { debug(50, 1) ("idnsSendQuery: FD %d: sendto: %s\n", DnsSocket, xstrerror()); } else { fd_bytes(DnsSocket, x, FD_WRITE); commSetSelect(DnsSocket, COMM_SELECT_READ, idnsRead, NULL, 0); } q->nsends++; q->sent_t = current_time; nameservers[ns].nqueries++; dlinkAdd(q, &q->lru, &lru_list); idnsTickleQueue(); }
static VALUE ServiceModule_service_name(VALUE self, VALUE name) { struct Service *ruby_service; struct Client *ruby_client; Check_Type(name, T_STRING); rb_iv_set(self, "@ServiceName", name); ruby_service = make_service(StringValueCStr(name)); set_service(self, ruby_service); if(ircncmp(ruby_service->name, StringValueCStr(name), NICKLEN) != 0) rb_iv_set(self, "@ServiceName", rb_str_new2(ruby_service->name)); clear_serv_tree_parse(&ruby_service->msg_tree); dlinkAdd(ruby_service, &ruby_service->node, &services_list); hash_add_service(ruby_service); ruby_client = introduce_client(ruby_service->name, ruby_service->name, TRUE); rb_iv_set(self, "@client", client_to_value(ruby_client)); rb_iv_set(self, "@langpath", rb_str_new2(LANGPATH)); return name; }
void aioRead(int fd, int offset, int len, AIOCB * callback, void *callback_data) { squidaio_ctrl_t *ctrlp; int seekmode; assert(initialised); squidaio_counts.read++; ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_READ; ctrlp->len = len; ctrlp->bufp = squidaio_xmalloc(len); if (offset >= 0) seekmode = SEEK_SET; else { seekmode = SEEK_CUR; offset = 0; } cbdataLock(callback_data); ctrlp->result.data = ctrlp; squidaio_read(fd, ctrlp->bufp, len, offset, seekmode, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } /* aioRead */
/* add client with fd to client list */ store_client * storeClientRegister(StoreEntry * e, void *owner) { MemObject *mem = e->mem_obj; store_client *sc; assert(mem); e->refcount++; mem->nclients++; sc = cbdataAlloc(store_client); sc->callback_data = NULL; sc->seen_offset = 0; sc->copy_offset = 0; sc->flags.disk_io_pending = 0; sc->entry = e; storeLockObject(sc->entry); sc->type = storeClientType(e); #if STORE_CLIENT_LIST_DEBUG assert(!storeClientListSearch(mem, owner)); sc->owner = owner; #endif dlinkAdd(sc, &sc->node, &mem->clients); #if DELAY_POOLS sc->delay_id = 0; #endif return sc; }
/* * dead_link - Adds client to a list of clients that need an exit_client() * */ void dead_link(struct Client *client_p) { dlink_node *m; const char *notice; if(IsClosing(client_p)) return; linebuf_donebuf(&client_p->localClient->buf_recvq); linebuf_donebuf(&client_p->localClient->buf_sendq); if(client_p->flags & FLAGS_SENDQEX) notice = "Max SendQ exceeded"; else notice = "Dead link"; if (!IsPerson(client_p) && !IsUnknown(client_p) && !IsClosing(client_p)) { sendto_realops_flags(FLAGS_ALL, L_ADMIN, notice, get_client_name(client_p, HIDE_IP)); sendto_realops_flags(FLAGS_ALL, L_OPER, notice, get_client_name(client_p, MASK_IP)); } Debug((DEBUG_ERROR, notice, get_client_name(to, HIDE_IP))); assert(dlinkFind(&abort_list, client_p) == NULL); m = make_dlink_node(); dlinkAdd(client_p, m, &abort_list); SetDead(client_p); /* You are dead my friend */ }
void refreshCheckSubmit(StoreEntry * entry, REFRESHCHECK * callback, void *callback_data) { MemBuf buf; const char *key; refresh_check_helper *def = Config.Program.refresh_check; refreshCheckState *state; dlink_node *node; refreshCheckState *oldstate = NULL; if (!def) { callback(callback_data, 0, NULL); return; } key = makeRefreshCheckRequest(entry, def->format); if (!key) { callback(callback_data, 0, NULL); return; } debug(84, 2) ("refreshCheckSubmit: for '%s'\n", key); /* Check for a pending lookup to hook into */ for (node = def->queue.head; node; node = node->next) { refreshCheckState *oldstatetmp = node->data; if (entry == oldstatetmp->entry) { oldstate = oldstatetmp; break; } } state = cbdataAlloc(refreshCheckState); state->def = def; cbdataLock(state->def); state->entry = entry; storeLockObject(entry); state->callback = callback; state->callback_data = callback_data; cbdataLock(state->callback_data); if (oldstate) { /* Hook into pending lookup */ state->queue = oldstate->queue; oldstate->queue = state; } else { /* No pending lookup found. Sumbit to helper */ /* Check for queue overload */ if (refreshCheckOverload(def)) { debug(84, 1) ("refreshCheckSubmit: queue overload\n"); cbdataFree(state); callback(callback_data, 0, "Overload"); return; } /* Send it off to the helper */ memBufDefInit(&buf); memBufPrintf(&buf, "%s\n", key); helperSubmit(def->helper, buf.buf, refreshCheckHandleReply, state); dlinkAdd(state, &state->list, &def->queue); memBufClean(&buf); } }
/* * make_client - create a new Client struct and set it to initial state. * * from == NULL, create local client (a client connected * to a socket). * * from, create remote client (behind a socket * associated with the client defined by * 'from'). ('from' is a local client!!). */ struct Client* make_client(struct Client* from) { struct Client* client_p = NULL; struct LocalUser *localClient; dlink_node *m; client_p = BlockHeapAlloc(client_heap); memset(client_p, 0, sizeof(struct Client)); if (from == NULL) { client_p->from = client_p; /* 'from' of local client is self! */ client_p->since = client_p->lasttime = client_p->firsttime = CurrentTime; localClient = (struct LocalUser *)BlockHeapAlloc(lclient_heap); memset(localClient, 0, sizeof(struct LocalUser)); client_p->localClient = localClient; client_p->localClient->fd = -1; client_p->localClient->ctrlfd = -1; #ifndef HAVE_SOCKETPAIR client_p->localClient->fd_r = -1; client_p->localClient->ctrlfd_r = -1; #endif /* as good a place as any... */ m = make_dlink_node(); dlinkAdd(client_p, m, &unknown_list); ++local_client_count; } else { /* from is not NULL */ client_p->localClient = NULL; client_p->from = from; /* 'from' of local client is self! */ ++remote_client_count; } client_p->status = STAT_UNKNOWN; strcpy(client_p->username, "unknown"); #if 0 client_p->name[0] = '\0'; client_p->flags = 0; client_p->next = NULL; client_p->prev = NULL; client_p->hnext = NULL; client_p->lnext = NULL; client_p->lprev = NULL; client_p->user = NULL; client_p->serv = NULL; client_p->servptr = NULL; client_p->whowas = NULL; client_p->allow_list.head = NULL; client_p->allow_list.tail = NULL; client_p->on_allow_list.head = NULL; client_p->on_allow_list.tail = NULL; #endif return client_p; }
void gethost_byname(const char *name, struct DNSQuery *query) { query->handle = WSAAsyncGetHostByName(wndhandle, WM_DNS, name, query->reply, sizeof(query->reply)); if (!query->handle) query->callback(query->ptr, NULL); else dlinkAdd(query, &query->node, &dns_queries); }
void connect_server() { struct Client *client = make_client(NULL); struct Server *server = make_server(client); struct Module *protomod; char modes[MODEBUFLEN+1] = ""; int i, j = 0; protomod = find_module(Connect.protocol, NO); if(protomod == NULL) { ilog(L_CRIT, "Unable to connect to uplink, protocol module %s not found.", Connect.protocol); services_die("Connect error", NO); } ServerModeList = (struct ModeList *)modsym(protomod->handle, "ModeList"); for(i = 0; ServerModeList[i].letter != '\0'; i++) { modes[j++] = ServerModeList[i].letter; if(j > MODEBUFLEN) break; } modes[j] = '\0'; ilog(L_DEBUG, "Loaded server mode list %p %s %d", ServerModeList, modes, j); strlcpy(server->pass, Connect.password, sizeof(server->pass)); strlcpy(client->name, Connect.name, sizeof(client->name)); strlcpy(client->host, Connect.host, sizeof(client->host)); SetConnecting(client); client->from = client; dlinkAdd(client, &client->node, &global_client_list); if(comm_open(&server->fd, AF_INET, SOCK_STREAM, 0, NULL) < 0) { ilog(L_CRIT, "connect_server: Could not open socket"); exit(1); } comm_connect_tcp(&server->fd, Connect.host, Connect.port, NULL, 0, serv_connect_callback, client, AF_INET, CONNECTTIMEOUT); eventAdd("Server connection check", try_reconnect, NULL, 60); }
void aioTruncate(const char *path, off_t length, AIOCB * callback, void *callback_data) { squidaio_ctrl_t *ctrlp; assert(initialised); squidaio_counts.unlink++; ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_TRUNCATE; cbdataLock(callback_data); ctrlp->result.data = ctrlp; squidaio_truncate(path, length, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); } /* aioTruncate */
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(); }
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 ! */ }
static int newblock(BlockHeap * bh) { MemBlock *newblk; Block *b; int i; void *offset; /* Setup the initial data structure. */ b = (Block *) calloc(1, sizeof(Block)); if (b == NULL) { return(1); } b->freeElems = bh->elemsPerBlock; b->free_list.head = b->free_list.tail = NULL; b->used_list.head = b->used_list.tail = NULL; b->next = bh->base; b->alloc_size = (bh->elemsPerBlock + 1) * (bh->elemSize + sizeof(MemBlock)); b->elems = get_block(b->alloc_size); if (b->elems == NULL) { return(1); } offset = b->elems; /* Setup our blocks now */ for (i = 0; i < bh->elemsPerBlock; i++) { void *data; newblk = (void *)offset; newblk->block = b; data = (void *)((size_t)offset + sizeof(MemBlock)); newblk->block = b; dlinkAdd(data, &newblk->self, &b->free_list); offset = (unsigned char *)((unsigned char *)offset + bh->elemSize + sizeof(MemBlock)); } ++bh->blocksAllocated; bh->freeElems += bh->elemsPerBlock; bh->base = b; return(0); }
void aioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callback_data) { squidaio_ctrl_t *ctrlp; assert(initialised); squidaio_counts.open++; ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_OPEN; cbdataLock(callback_data); ctrlp->result.data = ctrlp; squidaio_open(path, oflag, mode, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; }
void aioClose(int fd) { squidaio_ctrl_t *ctrlp; assert(initialised); squidaio_counts.close++; aioCancel(fd); ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = NULL; ctrlp->done_handler_data = NULL; ctrlp->operation = _AIO_CLOSE; ctrlp->result.data = ctrlp; squidaio_close(fd, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; }
void aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data) { squidaio_ctrl_t *ctrlp; assert(initialised); squidaio_counts.stat++; ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_STAT; cbdataLock(callback_data); ctrlp->result.data = ctrlp; squidaio_stat(path, sb, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } /* aioStat */
/*! \brief Blindly opers up given source_p, using conf info. * All checks on passwords have already been done. * \param source_p Pointer to given client to oper * \param conf operator {} configuration record */ static void oper_up(struct Client *source_p, const struct MaskItem *conf) { const unsigned int old = source_p->umodes; ++Count.oper; SetOper(source_p); if (conf->modes) AddUMode(source_p, conf->modes); else if (ConfigGeneral.oper_umodes) AddUMode(source_p, ConfigGeneral.oper_umodes); if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE)) ++Count.invisi; else if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE)) --Count.invisi; assert(dlinkFind(&oper_list, source_p) == NULL); dlinkAdd(source_p, make_dlink_node(), &oper_list); AddOFlag(source_p, conf->port); if (HasOFlag(source_p, OPER_FLAG_ADMIN)) AddUMode(source_p, UMODE_ADMIN); if (!EmptyString(conf->whois)) { svstag_attach(&source_p->svstags, RPL_WHOISOPERATOR, "+", conf->whois); sendto_server(NULL, 0, 0, ":%s SVSTAG %s %ju %u + :%s", me.id, source_p->id, source_p->tsinfo, RPL_WHOISOPERATOR, conf->whois); } ilog(LOG_TYPE_OPER, "OPER %s by %s!%s@%s", conf->name, source_p->name, source_p->username, source_p->host); sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%s is now an operator", get_oper_name(source_p)); sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s is now an operator", me.id, get_oper_name(source_p)); send_umode_out(source_p, old); sendto_one_numeric(source_p, &me, RPL_YOUREOPER); }
static void authenticateDecodeNegotiateAuth(auth_user_request_t * auth_user_request, const char *proxy_auth) { dlink_node *node; assert(auth_user_request->auth_user == NULL); auth_user_request->auth_user = authenticateAuthUserNew("negotiate"); auth_user_request->auth_user->auth_type = AUTH_NEGOTIATE; auth_user_request->auth_user->scheme_data = memPoolAlloc(negotiate_user_pool); auth_user_request->scheme_data = memPoolAlloc(negotiate_request_pool); memset(auth_user_request->scheme_data, '\0', sizeof(negotiate_request_t)); /* lock for the auth_user_request link */ authenticateAuthUserLock(auth_user_request->auth_user); node = dlinkNodeNew(); dlinkAdd(auth_user_request, node, &auth_user_request->auth_user->requests); /* the helper does the rest, with data collected in * authenticateNegotiateAuthenticateUser */ debug(29, 9) ("authenticateDecodeNegotiateAuth: Negotiate authentication\n"); return; }
/*! \brief Allocates a new block for addition to a blockheap * \param bh Pointer to parent blockheap * \return 0 if successful, 1 if not */ static int newblock(BlockHeap *bh) { MemBlock *newblk = NULL; Block *b = NULL; int i = 0; void *offset = NULL; /* Setup the initial data structure. */ if ((b = calloc(1, sizeof(Block))) == NULL) return 1; b->freeElems = bh->elemsPerBlock; b->next = bh->base; b->alloc_size = bh->elemsPerBlock * (bh->elemSize + sizeof(MemBlock)); b->elems = get_block(b->alloc_size); if (b->elems == NULL) return 1; offset = b->elems; /* Setup our blocks now */ for (; i < bh->elemsPerBlock; ++i) { void *data; newblk = offset; newblk->block = b; data = (void *)((size_t)offset + sizeof(MemBlock)); dlinkAdd(data, &newblk->self, &b->free_list); offset = (void *)((size_t)offset + bh->elemSize + sizeof(MemBlock)); } ++bh->blocksAllocated; bh->freeElems += bh->elemsPerBlock; bh->base = b; return 0; }
/* * client_from_server() */ static void uid_from_server(struct Client *client_p, struct Client *source_p, int parc, char *parv[], time_t newts, const char *svsid, char *nick, char *ugecos) { const char *m = NULL; const char *servername = source_p->name; source_p = make_client(client_p); dlinkAdd(source_p, &source_p->node, &global_client_list); source_p->hopcount = atoi(parv[2]); source_p->tsinfo = newts; strlcpy(source_p->svid, svsid, sizeof(source_p->svid)); /* copy the nick in place */ strlcpy(source_p->name, nick, sizeof(source_p->name)); strlcpy(source_p->id, parv[8], sizeof(source_p->id)); strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost)); strlcpy(source_p->info, ugecos, sizeof(source_p->info)); hash_add_client(source_p); hash_add_id(source_p); /* parse usermodes */ for (m = &parv[4][1]; *m; ++m) { unsigned int flag = user_modes[(unsigned char)*m]; if ((flag & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE)) ++Count.invisi; if ((flag & UMODE_OPER) && !HasUMode(source_p, UMODE_OPER)) ++Count.oper; source_p->umodes |= flag & SEND_UMODES; } register_remote_user(source_p, parv[5], parv[6], servername, ugecos); }
/* ************************************************************************ */ 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); }
/*! \brief Returns an element to the free pool, does not free() * \param bh Pointer to BlockHeap containing element * \param ptr Pointer to element to be "freed" * \return 0 if successful, 1 if element not contained within BlockHeap */ int BlockHeapFree(BlockHeap *bh, void *ptr) { Block *block = NULL; struct MemBlock *memblock = NULL; assert(bh != NULL); assert(ptr != NULL); memblock = (void *)((size_t)ptr - sizeof(MemBlock)); assert(memblock->block != NULL); if (memblock->block == NULL) outofmemory(); block = memblock->block; ++bh->freeElems; ++block->freeElems; mem_frob(ptr, bh->elemSize); dlinkAdd(ptr, &memblock->self, &block->free_list); return 0; }
static external_acl_entry * external_acl_cache_add(external_acl * def, const char *key, int result, char *user, char *error) { external_acl_entry *entry = hash_lookup(def->cache, key); debug(82, 2) ("external_acl_cache_add: Adding '%s' = %d\n", key, result); if (entry) { debug(82, 3) ("external_acl_cache_add: updating existing entry\n"); entry->date = squid_curtime; entry->result = result; safe_free(entry->user); safe_free(entry->error); if (user) entry->user = xstrdup(user); if (error) entry->error = xstrdup(error); external_acl_cache_touch(def, entry); return entry; } CBDATA_INIT_TYPE_FREECB(external_acl_entry, free_external_acl_entry); /* Maintain cache size */ if (def->cache_size && def->cache_entries >= def->cache_size) external_acl_cache_delete(def, def->lru_list.tail->data); entry = cbdataAlloc(external_acl_entry); entry->hash.key = xstrdup(key); entry->date = squid_curtime; entry->result = result; if (user) entry->user = xstrdup(user); if (error) entry->error = xstrdup(error); entry->def = def; hash_join(def->cache, &entry->hash); dlinkAdd(entry, &entry->lru, &def->lru_list); def->cache_entries += 1; return entry; }