aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-12-25 19:40:14 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-12-25 21:39:04 +0100
commite25445b8644310c73694b960f63f93f1e3110315 (patch)
treefce6fb794f9903fce74264cb1bd758660ae624ab
parent3d76e449688f304253aee4b330031e03b1d2cf5c (diff)
subscr: Sync the database before sending the attached signal
If a signal handler accesses the database he will still see the old lac. Make sure he is seeing the new one. Update the subscriber from the database in case the query failed or other things have changed.
-rw-r--r--openbsc/src/gsm_subscriber.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/openbsc/src/gsm_subscriber.c b/openbsc/src/gsm_subscriber.c
index 5dd680fce..dc7d638f1 100644
--- a/openbsc/src/gsm_subscriber.c
+++ b/openbsc/src/gsm_subscriber.c
@@ -294,6 +294,8 @@ struct gsm_subscriber *subscr_get_by_id(struct gsm_network *net,
int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason)
{
+ int rc;
+
/* FIXME: Migrate pending requests from one BSC to another */
switch (reason) {
case GSM_SUBSCRIBER_UPDATE_ATTACHED:
@@ -302,6 +304,8 @@ int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason)
s->lac = bts->location_area_code;
LOGP(DMM, LOGL_INFO, "Subscriber %s ATTACHED LAC=%u\n",
subscr_name(s), s->lac);
+ rc = db_sync_subscriber(s);
+ db_subscriber_update(s);
dispatch_signal(SS_SUBSCR, S_SUBSCR_ATTACHED, s);
break;
case GSM_SUBSCRIBER_UPDATE_DETACHED:
@@ -309,14 +313,19 @@ int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason)
if (bts->location_area_code == s->lac)
s->lac = GSM_LAC_RESERVED_DETACHED;
LOGP(DMM, LOGL_INFO, "Subscriber %s DETACHED\n", subscr_name(s));
+ rc = db_sync_subscriber(s);
+ db_subscriber_update(s);
dispatch_signal(SS_SUBSCR, S_SUBSCR_DETACHED, s);
break;
default:
fprintf(stderr, "subscr_update with unknown reason: %d\n",
reason);
+ rc = db_sync_subscriber(s);
+ db_subscriber_update(s);
break;
};
- return db_sync_subscriber(s);
+
+ return rc;
}
void subscr_update_from_db(struct gsm_subscriber *sub)