aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-18 17:50:05 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-18 17:52:08 +0100
commit90878590575cdcedbaf7b8f431e0fa102d0d2e50 (patch)
tree3dbd9fa72012b7f1ab8e1c417275e308a6d2a197
parentadfa01f041e3b9a515b65a732c92eabf74e2ba08 (diff)
ipa: Add API to clear the tx queue
Jacob noticed that after a re-connect old messages would be sent. This can be the wanted behavior but add a method that allows a caller to clear the tx queue. The implementation has not been verified and there is no existing unit test where I could easily add this code to.
-rw-r--r--include/osmocom/abis/ipa.h1
-rw-r--r--src/input/ipa.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/include/osmocom/abis/ipa.h b/include/osmocom/abis/ipa.h
index 6f40a40..6e9f9dd 100644
--- a/include/osmocom/abis/ipa.h
+++ b/include/osmocom/abis/ipa.h
@@ -84,6 +84,7 @@ int ipa_client_conn_open(struct ipa_client_conn *link);
void ipa_client_conn_close(struct ipa_client_conn *link);
void ipa_client_conn_send(struct ipa_client_conn *link, struct msgb *msg);
+size_t ipa_client_conn_clear_queue(struct ipa_client_conn *link);
int ipaccess_bts_handle_ccm(struct ipa_client_conn *link,
struct ipaccess_unit *dev, struct msgb *msg);
diff --git a/src/input/ipa.c b/src/input/ipa.c
index 1ddf802..a10a418 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -234,6 +234,20 @@ void ipa_client_conn_send(struct ipa_client_conn *link, struct msgb *msg)
link->ofd->when |= BSC_FD_WRITE;
}
+size_t ipa_client_conn_clear_queue(struct ipa_client_conn *link)
+{
+ size_t deleted = 0;
+
+ while (!llist_empty(&link->tx_queue)) {
+ struct msgb *msg = msgb_dequeue(&link->tx_queue);
+ msgb_free(msg);
+ deleted += 1;
+ }
+
+ link->ofd->when &= ~BSC_FD_WRITE;
+ return deleted;
+}
+
static int ipa_server_fd_cb(struct osmo_fd *ofd, unsigned int what)
{
int fd, ret;