From 90878590575cdcedbaf7b8f431e0fa102d0d2e50 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 18 Jan 2015 17:50:05 +0100 Subject: 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. --- include/osmocom/abis/ipa.h | 1 + src/input/ipa.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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; -- cgit v1.2.3