diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-19 11:39:50 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-19 11:39:50 +0000 |
commit | a6471eb3134ec90b827b73c848a7258614558a1e (patch) | |
tree | cb2757b8103fb1c5a41c3ba623caf71622ebb954 /usr.sbin/relayd | |
parent | 3023350bc0500daf56c0e54c411eafe99e71abc2 (diff) |
move repeated code to cleanup a protocol tree into a function.
Diffstat (limited to 'usr.sbin/relayd')
-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; |