diff options
Diffstat (limited to 'usr.sbin/relayd/relayd.c')
-rw-r--r-- | usr.sbin/relayd/relayd.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index c8d181e07ac..82b31811c15 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.51 2007/11/15 17:02:01 pyr Exp $ */ +/* $OpenBSD: relayd.c,v 1.52 2007/11/19 11:39:49 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -48,6 +48,7 @@ int check_child(pid_t, const char *); int send_all(struct hoststated *, enum imsg_type, void *, u_int16_t); void reconfigure(void); +void purge_tree(struct proto_tree *); int pipe_parent2pfe[2]; int pipe_parent2hce[2]; @@ -438,7 +439,6 @@ purge_config(struct hoststated *env, u_int8_t what) struct service *service; struct address *virt; struct protocol *proto; - struct protonode *pnode; struct relay *rly; struct session *sess; @@ -498,26 +498,8 @@ purge_config(struct hoststated *env, u_int8_t what) if (what & PURGE_PROTOS && env->protos != NULL) { while ((proto = TAILQ_FIRST(env->protos)) != NULL) { TAILQ_REMOVE(env->protos, proto, entry); - while ((pnode = RB_ROOT(&proto->request_tree)) - != NULL) { - RB_REMOVE(proto_tree, &proto->request_tree, - pnode); - if (pnode->key != NULL) - free(pnode->key); - if (pnode->value != NULL) - free(pnode->value); - free(pnode); - } - while ((pnode = RB_ROOT(&proto->response_tree)) - != NULL) { - RB_REMOVE(proto_tree, &proto->response_tree, - pnode); - if (pnode->key != NULL) - free(pnode->key); - if (pnode->value != NULL) - free(pnode->value); - free(pnode); - } + purge_tree(&proto->request_tree); + purge_tree(&proto->response_tree); free(proto); } free(env->protos); @@ -526,6 +508,21 @@ purge_config(struct hoststated *env, u_int8_t what) } void +purge_tree(struct proto_tree *tree) +{ + struct protonode *proot; + + while ((proot = RB_ROOT(tree)) != NULL) { + RB_REMOVE(proto_tree, tree, proot); + if (proot->key != NULL) + free(proot->key); + if (proot->value != NULL) + free(proot->value); + free(proot); + } +} + +void imsg_event_add(struct imsgbuf *ibuf) { ibuf->events = EV_READ; |