gprs: Do not put the subscr in gprs_subscr_delete
Currently gprs_subscr_delete implicitely calls subscr_put, which
makes the code more complex than necessary (additional subscr_get) in
a few places. It also makes it more difficult to see, whether get/put
are balanced within a function. In addition, the functions are not
named consistently (gprs_subscr_delete vs.
gprs_subscr_put_and_cancel).
This commit changes the semantics of gprs_subscr_delete and
indirectly of gprs_subscr_put_and_cancel to not call subscr_put on
their argument, but to leave that for the caller to do it
explicitely.
It renames gprs_subscr_put_and_cancel to gprs_subscr_cancel to
reflect that change in the name, too.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index acf37a2..fdf4840 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -200,6 +200,7 @@
mm->subscr = NULL;
subscr->sgsn_data->mm = NULL;
gprs_subscr_delete(subscr);
+ subscr_put(subscr);
}
/* Free all PDP contexts */
diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index d6d874b..b7e6af4 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -141,10 +141,9 @@
}
subscr->keep_in_ram = 0;
- subscr_put(subscr);
}
-void gprs_subscr_put_and_cancel(struct gsm_subscriber *subscr)
+void gprs_subscr_cancel(struct gsm_subscriber *subscr)
{
subscr->authorized = 0;
subscr->flags |= GPRS_SUBSCRIBER_CANCELLED;
@@ -380,7 +379,7 @@
/* Force silent cancellation */
subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
- gprs_subscr_put_and_cancel(subscr_get(subscr));
+ gprs_subscr_cancel(subscr);
return 0;
}
@@ -429,7 +428,7 @@
gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
- gprs_subscr_put_and_cancel(subscr_get(subscr));
+ gprs_subscr_cancel(subscr);
return 0;
}
diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index b4e1150..fb6cb78 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -560,7 +560,8 @@
return CMD_WARNING;
}
- gprs_subscr_put_and_cancel(subscr);
+ gprs_subscr_cancel(subscr);
+ subscr_put(subscr);
return CMD_SUCCESS;
}