From 0e0cf37c44d70feb23123d7bff0ab89f97fc1c28 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Fri, 6 May 2011 16:37:25 +0200 Subject: libctrl: Keep track of connections in struct ctrl_handle --- openbsc/src/libctrl/control_if.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c index cc5709d5..36fdc280 100644 --- a/openbsc/src/libctrl/control_if.c +++ b/openbsc/src/libctrl/control_if.c @@ -65,6 +65,9 @@ struct ctrl_handle { struct osmo_fd listen_fd; struct gsm_network *gsmnet; + + /* List of control connections */ + struct llist_head ccon_list; }; vector ctrl_node_vec; @@ -196,6 +199,7 @@ static void control_close_conn(struct ctrl_connection *ccon) { close(ccon->write_queue.bfd.fd); osmo_fd_unregister(&ccon->write_queue.bfd); + llist_del(&ccon->list_entry); if (ccon->closed_cb) ccon->closed_cb(ccon); talloc_free(ccon); @@ -300,6 +304,7 @@ static struct ctrl_connection *ctrl_connection_alloc(void *ctx) static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) { int ret, fd, on; + struct ctrl_handle *ctrl; struct ctrl_connection *ccon; struct sockaddr_in sa; socklen_t sa_len = sizeof(sa); @@ -330,7 +335,8 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) return -1; } - ccon->write_queue.bfd.data = listen_bfd->data; + ctrl = listen_bfd->data; + ccon->write_queue.bfd.data = ctrl; ccon->write_queue.bfd.fd = fd; ccon->write_queue.bfd.when = BSC_FD_READ; ccon->write_queue.read_cb = handle_control_read; @@ -343,6 +349,8 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) talloc_free(ccon); } + llist_add(&ccon->list_entry, &ctrl->ccon_list); + return ret; } @@ -608,6 +616,8 @@ int controlif_setup(struct gsm_network *gsmnet, uint16_t port) if (!ctrl) return -ENOMEM; + INIT_LLIST_HEAD(&ctrl->ccon_list); + ctrl->gsmnet = gsmnet; ctrl_node_vec = vector_init(5); -- cgit v1.2.3