Merge bts_alloc_ms() and ms_alloc()

gprs_default_cb_ms_idle() is changed to have the same implementation as
previous bts_ms_idle_cb(), since that's the only one being used in
osmo-pcu code. It makes no sense to use different callback logic in unit
tests.

This is another step towards simplifying the code and getting rid of the
idle/active_cb().

Change-Id: I2a06d17588572a21dc5a14ddbde83766076b446d
diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 3e95103..b9a1b76 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -63,7 +63,8 @@
 
 void gprs_default_cb_ms_idle(struct GprsMs *ms)
 {
-	talloc_free(ms);
+	if (ms_is_idle(ms))
+		talloc_free(ms);
 }
 
 void gprs_default_cb_ms_active(struct GprsMs *ms)
@@ -111,6 +112,7 @@
 	talloc_set_destructor(ms, ms_talloc_destructor);
 
 	llist_add(&ms->list, &bts->ms_list);
+	bts_stat_item_inc(bts, STAT_MS_PRESENT);
 
 	ms->bts = bts;
 	ms->cb = gprs_default_cb;
@@ -147,6 +149,8 @@
 	if (!ms->ctrs)
 		goto free_ret;
 
+	ms_set_timeout(ms, osmo_tdef_get(bts->pcu->T_defs, -2030, OSMO_TDEF_S, -1));
+
 	return ms;
 free_ret:
 	talloc_free(ms);
@@ -159,6 +163,7 @@
 
 	LOGPMS(ms, DRLCMAC, LOGL_INFO, "Destroying MS object\n");
 
+	bts_stat_item_dec(ms->bts, STAT_MS_PRESENT);
 	llist_del(&ms->list);
 
 	ms_set_reserved_slots(ms, NULL, 0, 0);