summaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-05-06 16:37:25 +0200
committerHarald Welte <laforge@gnumonks.org>2014-08-21 15:34:13 +0200
commit0e0cf37c44d70feb23123d7bff0ab89f97fc1c28 (patch)
treee7767a7d7635eb85e4ce76fb035a0c60aca1b1be /openbsc
parentad6451fc982defb05c7d9cbb4516342169d7334a (diff)
libctrl: Keep track of connections in struct ctrl_handle
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/libctrl/control_if.c12
1 files changed, 11 insertions, 1 deletions
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);