mirror of
https://gerrit.osmocom.org/osmo-gbproxy
synced 2024-08-21 18:36:25 +00:00
move allocation of talloc contexts into link-time constructor
This is much more optimal than checking if the context exists every time we allocate the respective object.
This commit is contained in:
parent
419c047ce9
commit
932e20d3ac
11 changed files with 64 additions and 53 deletions
|
@ -2056,10 +2056,6 @@ static int bs11_read_swl_file(struct abis_nm_bs11_sw *bs11_sw)
|
||||||
FILE *swl;
|
FILE *swl;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (!tall_fle_ctx)
|
|
||||||
tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"bs11_file_list_entry");
|
|
||||||
|
|
||||||
swl = fopen(bs11_sw->swl_fname, "r");
|
swl = fopen(bs11_sw->swl_fname, "r");
|
||||||
if (!swl)
|
if (!swl)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -2373,3 +2369,10 @@ int abis_nm_ipaccess_restart(struct gsm_bts *bts)
|
||||||
{
|
{
|
||||||
return __simple_cmd(bts, NM_MT_IPACC_RESTART);
|
return __simple_cmd(bts, NM_MT_IPACC_RESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_abis_nm(void)
|
||||||
|
{
|
||||||
|
tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"bs11_file_list_entry");
|
||||||
|
}
|
||||||
|
|
|
@ -370,10 +370,6 @@ e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
|
||||||
if (ts->type != E1INP_TS_TYPE_SIGN)
|
if (ts->type != E1INP_TS_TYPE_SIGN)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!tall_sigl_ctx)
|
|
||||||
tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"e1inp_sign_link");
|
|
||||||
|
|
||||||
link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link);
|
link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link);
|
||||||
if (!link)
|
if (!link)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -505,3 +501,9 @@ int e1inp_line_register(struct e1inp_line *line)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_e1_inp(void)
|
||||||
|
{
|
||||||
|
tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"e1inp_sign_link");
|
||||||
|
}
|
||||||
|
|
|
@ -350,9 +350,6 @@ static void allocate_loc_updating_req(struct gsm_lchan *lchan)
|
||||||
use_lchan(lchan);
|
use_lchan(lchan);
|
||||||
release_loc_updating_req(lchan);
|
release_loc_updating_req(lchan);
|
||||||
|
|
||||||
if (!tall_locop_ctx)
|
|
||||||
tall_locop_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"loc_updating_oper");
|
|
||||||
lchan->loc_operation = talloc_zero(tall_locop_ctx,
|
lchan->loc_operation = talloc_zero(tall_locop_ctx,
|
||||||
struct gsm_loc_updating_operation);
|
struct gsm_loc_updating_operation);
|
||||||
}
|
}
|
||||||
|
@ -408,6 +405,8 @@ static int gsm0408_handle_lchan_signal(unsigned int subsys, unsigned int signal,
|
||||||
*/
|
*/
|
||||||
static __attribute__((constructor)) void on_dso_load_0408(void)
|
static __attribute__((constructor)) void on_dso_load_0408(void)
|
||||||
{
|
{
|
||||||
|
tall_locop_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"loc_updating_oper");
|
||||||
register_signal_handler(SS_LCHAN, gsm0408_handle_lchan_signal, NULL);
|
register_signal_handler(SS_LCHAN, gsm0408_handle_lchan_signal, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,19 +162,11 @@ static int gsm340_rx_tpdu(struct msgb *msg)
|
||||||
u_int8_t address_lv[12]; /* according to 03.40 / 9.1.2.5 */
|
u_int8_t address_lv[12]; /* according to 03.40 / 9.1.2.5 */
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (!tall_sms_ctx)
|
|
||||||
tall_sms_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"sms_submit");
|
|
||||||
|
|
||||||
sms = talloc(tall_sms_ctx, struct sms_submit);
|
sms = talloc(tall_sms_ctx, struct sms_submit);
|
||||||
if (!sms)
|
if (!sms)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memset(sms, 0, sizeof(*sms));
|
memset(sms, 0, sizeof(*sms));
|
||||||
|
|
||||||
if (!tall_gsms_ctx)
|
|
||||||
tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"sms");
|
|
||||||
|
|
||||||
gsms = talloc(tall_gsms_ctx, struct gsm_sms);
|
gsms = talloc(tall_gsms_ctx, struct gsm_sms);
|
||||||
if (!gsms) {
|
if (!gsms) {
|
||||||
talloc_free(sms);
|
talloc_free(sms);
|
||||||
|
@ -513,3 +505,9 @@ int gsm0411_send_sms(struct gsm_lchan *lchan, struct sms_deliver *sms)
|
||||||
|
|
||||||
return gsm0411_sendmsg(msg);
|
return gsm0411_sendmsg(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_sms(void)
|
||||||
|
{
|
||||||
|
tall_sms_ctx = talloc_named_const(tall_bsc_ctx, 1, "sms_submit");
|
||||||
|
tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 1, "sms");
|
||||||
|
}
|
||||||
|
|
|
@ -103,10 +103,6 @@ struct gsm_subscriber *subscr_alloc(void)
|
||||||
{
|
{
|
||||||
struct gsm_subscriber *s;
|
struct gsm_subscriber *s;
|
||||||
|
|
||||||
if (!tall_subscr_ctx)
|
|
||||||
tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"subscriber");
|
|
||||||
|
|
||||||
s = talloc(tall_subscr_ctx, struct gsm_subscriber);
|
s = talloc(tall_subscr_ctx, struct gsm_subscriber);
|
||||||
if (!s)
|
if (!s)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -213,10 +209,6 @@ void subscr_get_channel(struct gsm_subscriber *subscr,
|
||||||
{
|
{
|
||||||
struct subscr_request *request;
|
struct subscr_request *request;
|
||||||
|
|
||||||
if (!tall_sub_req_ctx)
|
|
||||||
tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"subscr_request");
|
|
||||||
|
|
||||||
request = talloc(tall_sub_req_ctx, struct subscr_request);
|
request = talloc(tall_sub_req_ctx, struct subscr_request);
|
||||||
if (!request) {
|
if (!request) {
|
||||||
if (cbfn)
|
if (cbfn)
|
||||||
|
@ -273,3 +265,11 @@ void subscr_put_channel(struct gsm_lchan *lchan)
|
||||||
subscr_send_paging_request(lchan->subscr);
|
subscr_send_paging_request(lchan->subscr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_subscr(void)
|
||||||
|
{
|
||||||
|
tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 1, "subscriber");
|
||||||
|
|
||||||
|
tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"subscr_request");
|
||||||
|
}
|
||||||
|
|
|
@ -140,9 +140,6 @@ static int mncc_setup_ind(struct gsm_call *call, int msg_type,
|
||||||
if (call->remote_ref)
|
if (call->remote_ref)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!tall_call_ctx)
|
|
||||||
tall_call_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"gsm_call");
|
|
||||||
/* create remote call */
|
/* create remote call */
|
||||||
if (!(remote = talloc(tall_call_ctx, struct gsm_call))) {
|
if (!(remote = talloc(tall_call_ctx, struct gsm_call))) {
|
||||||
memset(&mncc, 0, sizeof(struct gsm_mncc));
|
memset(&mncc, 0, sizeof(struct gsm_mncc));
|
||||||
|
@ -306,9 +303,6 @@ int mncc_recv(struct gsm_network *net, int msg_type, void *arg)
|
||||||
if (!call) {
|
if (!call) {
|
||||||
if (msg_type != MNCC_SETUP_IND)
|
if (msg_type != MNCC_SETUP_IND)
|
||||||
return 0; /* drop */
|
return 0; /* drop */
|
||||||
if (!tall_call_ctx)
|
|
||||||
tall_call_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"gsm_call");
|
|
||||||
/* create call */
|
/* create call */
|
||||||
if (!(call = talloc_zero(tall_call_ctx, struct gsm_call))) {
|
if (!(call = talloc_zero(tall_call_ctx, struct gsm_call))) {
|
||||||
struct gsm_mncc rel;
|
struct gsm_mncc rel;
|
||||||
|
@ -395,3 +389,8 @@ int mncc_recv(struct gsm_network *net, int msg_type, void *arg)
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_trau_mncc(void)
|
||||||
|
{
|
||||||
|
tall_call_ctx = talloc_named_const(tall_bsc_ctx, 1, "gsm_call");
|
||||||
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ struct msgb *msgb_alloc(u_int16_t size, const char *name)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
|
||||||
if (!tall_msgb_ctx)
|
|
||||||
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
|
|
||||||
|
|
||||||
msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
|
msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
|
||||||
|
|
||||||
if (!msg)
|
if (!msg)
|
||||||
|
@ -76,3 +73,8 @@ struct msgb *msgb_dequeue(struct llist_head *queue)
|
||||||
|
|
||||||
return llist_entry(lh, struct msgb, list);
|
return llist_entry(lh, struct msgb, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_trau_msgb(void)
|
||||||
|
{
|
||||||
|
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
|
||||||
|
}
|
||||||
|
|
|
@ -219,9 +219,6 @@ static void _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
||||||
struct gsm_bts_paging_state *bts_entry = &bts->paging;
|
struct gsm_bts_paging_state *bts_entry = &bts->paging;
|
||||||
struct gsm_paging_request *req;
|
struct gsm_paging_request *req;
|
||||||
|
|
||||||
if (!tall_paging_ctx)
|
|
||||||
tall_paging_ctx = talloc_named_const(NULL, 1, "paging_request");
|
|
||||||
|
|
||||||
if (paging_pending_request(bts_entry, subscr)) {
|
if (paging_pending_request(bts_entry, subscr)) {
|
||||||
DEBUGP(DPAG, "Paging request already pending\n");
|
DEBUGP(DPAG, "Paging request already pending\n");
|
||||||
return;
|
return;
|
||||||
|
@ -310,3 +307,8 @@ void paging_update_buffer_space(struct gsm_bts *bts, u_int16_t free_slots)
|
||||||
{
|
{
|
||||||
bts->paging.available_slots = free_slots;
|
bts->paging.available_slots = free_slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_paging(void)
|
||||||
|
{
|
||||||
|
tall_paging_ctx = talloc_named_const(NULL, 1, "paging_request");
|
||||||
|
}
|
||||||
|
|
|
@ -39,9 +39,6 @@ int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data)
|
||||||
{
|
{
|
||||||
struct signal_handler *sig_data;
|
struct signal_handler *sig_data;
|
||||||
|
|
||||||
if (!tall_sigh_ctx)
|
|
||||||
tall_sigh_ctx = talloc_named_const(NULL, 1, "signal_handler");
|
|
||||||
|
|
||||||
sig_data = talloc(tall_sigh_ctx, struct signal_handler);
|
sig_data = talloc(tall_sigh_ctx, struct signal_handler);
|
||||||
if (!sig_data)
|
if (!sig_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -84,3 +81,8 @@ void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data
|
||||||
(*handler->cbfn)(subsys, signal, handler->data, signal_data);
|
(*handler->cbfn)(subsys, signal, handler->data, signal_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_signal(void)
|
||||||
|
{
|
||||||
|
tall_sigh_ctx = talloc_named_const(NULL, 1, "signal_handler");
|
||||||
|
}
|
||||||
|
|
|
@ -312,9 +312,6 @@ int subchan_mux_init(struct subch_mux *mx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!tall_tqe_ctx)
|
|
||||||
tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"subch_txq_entry");
|
|
||||||
memset(mx, 0, sizeof(*mx));
|
memset(mx, 0, sizeof(*mx));
|
||||||
for (i = 0; i < NR_SUBCH; i++) {
|
for (i = 0; i < NR_SUBCH; i++) {
|
||||||
struct mux_subch *sch = &mx->subch[i];
|
struct mux_subch *sch = &mx->subch[i];
|
||||||
|
@ -323,3 +320,9 @@ int subchan_mux_init(struct subch_mux *mx)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_ss_demux(void)
|
||||||
|
{
|
||||||
|
tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"subch_txq_entry");
|
||||||
|
}
|
||||||
|
|
|
@ -55,10 +55,6 @@ int trau_mux_map(const struct gsm_e1_subslot *src,
|
||||||
{
|
{
|
||||||
struct map_entry *me;
|
struct map_entry *me;
|
||||||
|
|
||||||
if (!tall_map_ctx)
|
|
||||||
tall_map_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"trau_map_entry");
|
|
||||||
|
|
||||||
me = talloc(tall_map_ctx, struct map_entry);
|
me = talloc(tall_map_ctx, struct map_entry);
|
||||||
if (!me)
|
if (!me)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -201,10 +197,6 @@ int trau_recv_lchan(struct gsm_lchan *lchan, u_int32_t callref)
|
||||||
struct gsm_e1_subslot *src_ss;
|
struct gsm_e1_subslot *src_ss;
|
||||||
struct upqueue_entry *ue;
|
struct upqueue_entry *ue;
|
||||||
|
|
||||||
if (!tall_upq_ctx)
|
|
||||||
tall_upq_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
|
||||||
"trau_upq_entry");
|
|
||||||
|
|
||||||
ue = talloc(tall_upq_ctx, struct upqueue_entry);
|
ue = talloc(tall_upq_ctx, struct upqueue_entry);
|
||||||
if (!ue)
|
if (!ue)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -243,3 +235,12 @@ int trau_send_lchan(struct gsm_lchan *lchan, struct decoded_trau_frame *tf)
|
||||||
return subchan_mux_enqueue(mx, dst_e1_ss->e1_ts_ss, trau_bits_out,
|
return subchan_mux_enqueue(mx, dst_e1_ss->e1_ts_ss, trau_bits_out,
|
||||||
TRAU_FRAME_BITS);
|
TRAU_FRAME_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void on_dso_load_trau_mux(void)
|
||||||
|
{
|
||||||
|
tall_map_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"trau_map_entry");
|
||||||
|
|
||||||
|
tall_upq_ctx = talloc_named_const(tall_bsc_ctx, 1,
|
||||||
|
"trau_upq_entry");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue