void tube_remove_bg_listen(struct tube* tube) { if(tube->listen_com) { comm_point_delete(tube->listen_com); tube->listen_com = NULL; } free(tube->cmd_msg); tube->cmd_msg = NULL; }
struct listen_dnsport* listen_create(struct comm_base* base, struct listen_port* ports, size_t bufsize, int tcp_accept_count, void* sslctx, struct dt_env* dtenv, comm_point_callback_t* cb, void *cb_arg) { struct listen_dnsport* front = (struct listen_dnsport*) malloc(sizeof(struct listen_dnsport)); if(!front) return NULL; front->cps = NULL; front->udp_buff = sldns_buffer_new(bufsize); if(!front->udp_buff) { free(front); return NULL; } /* create comm points as needed */ while(ports) { struct comm_point* cp = NULL; if(ports->ftype == listen_type_udp) cp = comm_point_create_udp(base, ports->fd, front->udp_buff, cb, cb_arg); else if(ports->ftype == listen_type_tcp) cp = comm_point_create_tcp(base, ports->fd, tcp_accept_count, bufsize, cb, cb_arg); else if(ports->ftype == listen_type_ssl) { cp = comm_point_create_tcp(base, ports->fd, tcp_accept_count, bufsize, cb, cb_arg); cp->ssl = sslctx; } else if(ports->ftype == listen_type_udpancil) cp = comm_point_create_udp_ancil(base, ports->fd, front->udp_buff, cb, cb_arg); if(!cp) { log_err("can't create commpoint"); listen_delete(front); return NULL; } cp->dtenv = dtenv; cp->do_not_close = 1; if(!listen_cp_insert(cp, front)) { log_err("malloc failed"); comm_point_delete(cp); listen_delete(front); return NULL; } ports = ports->next; } if(!front->cps) { log_err("Could not open sockets to accept queries."); listen_delete(front); return NULL; } return front; }
void listen_list_delete(struct listen_list* list) { struct listen_list *p = list, *pn; while(p) { pn = p->next; comm_point_delete(p->com); free(p); p = pn; } }
/** decrease active count and remove commpoint from busy list */ static void clean_point(struct daemon_remote* rc, struct rc_state* s) { state_list_remove_elem(&rc->busy_list, s->c); rc->active --; if(s->ssl) { SSL_shutdown(s->ssl); SSL_free(s->ssl); } comm_point_delete(s->c); free(s); }
void tube_remove_bg_write(struct tube* tube) { if(tube->res_com) { comm_point_delete(tube->res_com); tube->res_com = NULL; } if(tube->res_list) { struct tube_res_list* np, *p = tube->res_list; tube->res_list = NULL; tube->res_last = NULL; while(p) { np = p->next; free(p->buf); free(p); p = np; } } }
void daemon_remote_clear(struct daemon_remote* rc) { struct rc_state* p, *np; if(!rc) return; /* but do not close the ports */ listen_list_delete(rc->accept_list); rc->accept_list = NULL; /* do close these sockets */ p = rc->busy_list; while(p) { np = p->next; if(p->ssl) SSL_free(p->ssl); comm_point_delete(p->c); free(p); p = np; } rc->busy_list = NULL; rc->active = 0; rc->worker = NULL; }