handover: Call bsc_handover_clear from gsm0808_clear

The bsc_handover_clear will release an in-progress handover
and free the lchana and the data associated with this handover
This commit is contained in:
Holger Hans Peter Freyther 2010-06-30 12:58:14 +08:00
parent 0610947f4c
commit f2553a6c3a
4 changed files with 35 additions and 7 deletions

View File

@ -1,8 +1,14 @@
#ifndef _HANDOVER_H #ifndef _HANDOVER_H
#define _HANDOVER_H #define _HANDOVER_H
struct gsm_subscriber_connection;
/* Hand over the specified logical channel to the specified new BTS. /* Hand over the specified logical channel to the specified new BTS.
* This is the main entry point for the actual handover algorithm, * This is the main entry point for the actual handover algorithm,
* after it has decided it wants to initiate HO to a specific BTS */ * after it has decided it wants to initiate HO to a specific BTS */
int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts); int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts);
/* clear any operation for this connection */
void bsc_clear_handover(struct gsm_subscriber_connection *conn);
#endif /* _HANDOVER_H */ #endif /* _HANDOVER_H */

View File

@ -28,6 +28,7 @@
#include <openbsc/signal.h> #include <openbsc/signal.h>
#include <openbsc/abis_rsl.h> #include <openbsc/abis_rsl.h>
#include <openbsc/chan_alloc.h> #include <openbsc/chan_alloc.h>
#include <openbsc/handover.h>
#include <osmocore/talloc.h> #include <osmocore/talloc.h>
@ -115,6 +116,8 @@ int gsm0808_clear(struct gsm_subscriber_connection* conn)
{ {
struct gsm_lchan *lchan; struct gsm_lchan *lchan;
bsc_clear_handover(conn);
lchan = conn->lchan; lchan = conn->lchan;
subscr_con_free(conn); subscr_con_free(conn);
lchan_release(lchan, 1, 0); lchan_release(lchan, 1, 0);

View File

@ -478,13 +478,8 @@ void subscr_con_free(struct gsm_subscriber_connection *conn)
} }
/* Release a handover that might be in operation */ if (conn->ho_lchan)
if (conn->ho_lchan) { LOGP(DNM, LOGL_ERROR, "The ho_lchan should have been cleared.\n");
conn->ho_lchan->conn = NULL;
lchan_release(conn->ho_lchan, 0, 1);
conn->ho_lchan = NULL;
}
lchan = conn->lchan; lchan = conn->lchan;
talloc_free(conn); talloc_free(conn);

View File

@ -149,6 +149,30 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts)
return 0; return 0;
} }
void bsc_clear_handover(struct gsm_subscriber_connection *conn)
{
struct bsc_handover *ho;
ho = bsc_ho_by_new_lchan(conn->ho_lchan);
if (!ho && conn->ho_lchan)
LOGP(DHO, LOGL_ERROR, "BUG: We lost some state.\n");
if (!ho) {
LOGP(DHO, LOGL_ERROR, "unable to find HO record\n");
return;
}
conn->ho_lchan->conn = NULL;
conn->ho_lchan = NULL;
lchan_release(ho->new_lchan, 0, 1);
bsc_del_timer(&ho->T3103);
llist_del(&ho->list);
talloc_free(ho);
}
/* T3103 expired: Handover has failed without HO COMPLETE or HO FAIL */ /* T3103 expired: Handover has failed without HO COMPLETE or HO FAIL */
static void ho_T3103_cb(void *_ho) static void ho_T3103_cb(void *_ho)
{ {