From 4188c30c4a6574201d62df1be818eed038608d16 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Fri, 19 Dec 2014 18:50:05 +0100 Subject: gprs: Avoid sending stale GSUP requests after reconnect Currently, messages are added to the tx queue even if the connection is down for some reason and all of these messages are eventually sent after a re-connect. The MS has probably sent several Attach Requests while the connection was down and will continue doing so. Therefore these stored messages could be dropped. This patch clears the queue before re-connecting and also extends gprs_gsup_client_send to return immediately, when the connection is not established instead of calling ipa_client_conn_send. Sponsored-by: On-Waves ehf [hfreyther: Replaced while (!llist_empty(&gsupc->link->tx_queue)) llist_del(gsupc->link->tx_queue.next); with new libosmo-abis API] --- openbsc/src/gprs/gprs_gsup_client.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openbsc/src/gprs/gprs_gsup_client.c b/openbsc/src/gprs/gprs_gsup_client.c index 52099005c..aaf301755 100644 --- a/openbsc/src/gprs/gprs_gsup_client.c +++ b/openbsc/src/gprs/gprs_gsup_client.c @@ -46,6 +46,9 @@ static int gsup_client_connect(struct gprs_gsup_client *gsupc) osmo_timer_del(&gsupc->connect_timer); } + if (ipa_client_conn_clear_queue(gsupc->link) > 0) + LOGP(DLINP, LOGL_DEBUG, "GSUP connect: discarded stored messages\n"); + rc = ipa_client_conn_open(gsupc->link); if (rc >= 0) @@ -181,6 +184,11 @@ int gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg) return -ENOTCONN; } + if (!gsupc->is_connected) { + msgb_free(msg); + return -EAGAIN; + } + ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_GSUP); ipa_msg_push_header(msg, IPAC_PROTO_OSMO); ipa_client_conn_send(gsupc->link, msg); -- cgit v1.2.3