aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-09-15 12:56:58 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2011-09-19 03:00:43 +0200
commita0d9331cb13be85fb89fdf6973c50f0514a66bb3 (patch)
treed75cf5dc85fda9bc921405c71b586d48e20176d3
parentdc4479f27d14f1ed5e17ccac401f8169813843d7 (diff)
ipa: Add a callback to detect if the server_conn was closed
-rw-r--r--include/osmocom/abis/ipa.h3
-rw-r--r--src/input/ipa.c5
-rw-r--r--src/ipa_proxy.c2
3 files changed, 7 insertions, 3 deletions
diff --git a/include/osmocom/abis/ipa.h b/include/osmocom/abis/ipa.h
index 43422dc..397cf9c 100644
--- a/include/osmocom/abis/ipa.h
+++ b/include/osmocom/abis/ipa.h
@@ -24,11 +24,12 @@ struct ipa_server_conn {
struct ipa_server_link *server;
struct osmo_fd ofd;
struct llist_head tx_queue;
+ int (*closed_cb)(struct ipa_server_conn *peer);
int (*cb)(struct ipa_server_conn *peer, struct msgb *msg);
void *data;
};
-struct ipa_server_conn *ipa_server_conn_create(void *ctx, struct ipa_server_link *link, int fd, int (*cb)(struct ipa_server_conn *peer, struct msgb *msg), void *data);
+struct ipa_server_conn *ipa_server_conn_create(void *ctx, struct ipa_server_link *link, int fd, int (*cb)(struct ipa_server_conn *peer, struct msgb *msg), int (*closed_cb)(struct ipa_server_conn *peer), void *data);
void ipa_server_conn_destroy(struct ipa_server_conn *peer);
void ipa_server_conn_send(struct ipa_server_conn *peer, struct msgb *msg);
diff --git a/src/input/ipa.c b/src/input/ipa.c
index c881b22..a887959 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -443,7 +443,7 @@ static int ipa_server_conn_cb(struct osmo_fd *ofd, unsigned int what)
struct ipa_server_conn *
ipa_server_conn_create(void *ctx, struct ipa_server_link *link, int fd,
int (*cb)(struct ipa_server_conn *conn, struct msgb *msg),
- void *data)
+ int (*closed_cb)(struct ipa_server_conn *conn), void *data)
{
struct ipa_server_conn *conn;
@@ -459,6 +459,7 @@ ipa_server_conn_create(void *ctx, struct ipa_server_link *link, int fd,
conn->ofd.cb = ipa_server_conn_cb;
conn->ofd.when = BSC_FD_READ;
conn->cb = cb;
+ conn->closed_cb = closed_cb;
conn->data = data;
INIT_LLIST_HEAD(&conn->tx_queue);
@@ -474,6 +475,8 @@ void ipa_server_conn_destroy(struct ipa_server_conn *conn)
{
close(conn->ofd.fd);
osmo_fd_unregister(&conn->ofd);
+ if (conn->closed_cb)
+ conn->closed_cb(conn);
talloc_free(conn);
}
diff --git a/src/ipa_proxy.c b/src/ipa_proxy.c
index f4e1df8..9816d02 100644
--- a/src/ipa_proxy.c
+++ b/src/ipa_proxy.c
@@ -176,7 +176,7 @@ ipa_sock_src_accept_cb(struct ipa_server_link *link, int fd)
conn->route = route;
conn->src = ipa_server_conn_create(tall_ipa_proxy_ctx, link, fd,
- ipa_sock_src_cb, conn);
+ ipa_sock_src_cb, NULL, conn);
if (conn->src == NULL) {
LOGP(DLINP, LOGL_ERROR, "could not create server peer: %s\n",
strerror(errno));