deactivate RF + exit when the Abis link is gone

The idea is that the BTS process is re-spawned from init/upstart/systemd
This commit is contained in:
Harald Welte 2011-06-29 20:42:14 +02:00
parent 1eb4d4893c
commit b849684181
7 changed files with 45 additions and 3 deletions

View File

@ -6,6 +6,7 @@
extern void *tall_bts_ctx;
int bts_init(struct gsm_bts *bts);
void bts_shutdown(struct gsm_bts *bts);
struct gsm_bts *create_bts(uint8_t num_trx, char *id);
int create_ms(struct gsm_bts_trx *trx, int maskc, uint8_t *maskv_tx,

View File

@ -31,4 +31,6 @@ int bts_model_rsl_chan_act(struct gsm_lchan *lchan, struct tlv_parsed *tp);
int bts_model_rsl_chan_rel(struct gsm_lchan *lchan);
int bts_model_rsl_deact_sacch(struct gsm_lchan *lchan);
int bts_model_trx_deact_rf(struct gsm_bts_trx *trx);
#endif

View File

@ -513,5 +513,13 @@ void abis_close(struct ipabis_link *link)
if (osmo_timer_pending(&link->timer))
osmo_timer_del(&link->timer);
/* for now, we simply terminate the program and re-spawn */
if (link->bts)
bts_shutdown(link->bts);
else if (link->trx)
bts_shutdown(link->trx->bts);
else
exit(43);
}

View File

@ -56,6 +56,27 @@ int bts_init(struct gsm_bts *bts)
return bts_model_init(bts);
}
static void shutdown_timer_cb(void *data)
{
exit(42);
}
static struct osmo_timer_list shutdown_timer = {
.cb = &shutdown_timer_cb,
};
void bts_shutdown(struct gsm_bts *bts)
{
struct gsm_bts_trx *trx;
llist_for_each_entry(trx, &bts->trx_list, list)
bts_model_trx_deact_rf(trx);
/* shedule a timer to make sure select loop logic can run again
* to dispatch any pending primitives */
osmo_timer_schedule(&shutdown_timer, 3, 0);
}
#if 0
struct osmobts_lchan *lchan_by_channelnr(struct osmobts_trx *trx,
uint8_t channelnr)

View File

@ -23,6 +23,8 @@
#include <osmo-bts/oml.h>
#include <osmo-bts/bts_model.h>
#include "l1_if.h"
int bts_model_rsl_chan_act(struct gsm_lchan *lchan, struct tlv_parsed *tp)
{
uint8_t mode = *TLVP_VAL(tp, RSL_IE_CHAN_MODE);
@ -44,3 +46,10 @@ int bts_model_rsl_deact_sacch(struct gsm_lchan *lchan)
{
return lchan_deactivate_sacch(lchan);
}
int bts_model_trx_deact_rf(struct gsm_bts_trx *trx)
{
struct femtol1_hdl *fl1 = trx_femtol1_hdl(trx);
return l1if_activate_rf(fl1, 0);
}

View File

@ -40,6 +40,7 @@ int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
struct femtol1_hdl *l1if_open(void *priv);
int l1if_close(struct femtol1_hdl *hdl);
int l1if_reset(struct femtol1_hdl *hdl);
int l1if_activate_rf(struct femtol1_hdl *hdl, int on);
struct msgb *l1p_msgb_alloc(void);
struct msgb *sysp_msgb_alloc(void);

View File

@ -160,6 +160,8 @@ static void handle_options(int argc, char **argv)
}
}
static struct gsm_bts *bts;
static void signal_handler(int signal)
{
fprintf(stderr, "signal %u received\n", signal);
@ -167,8 +169,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
//osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
sleep(3);
exit(0);
bts_shutdown(bts);
break;
case SIGABRT:
case SIGUSR1:
@ -182,7 +183,6 @@ static void signal_handler(int signal)
int main(int argc, char **argv)
{
struct gsm_bts *bts;
struct ipabis_link *link;
void *tall_msgb_ctx;
int rc;