[Kamailio-Users] custom module depends on usrloc, the load order

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 11 09:35:30 CEST 2008


Hello,

On 09/11/08 03:02, toly wrote:
> Greetings,
>
> I have 2 questions.
>
> 1. I've created custom module where I'd like to get number of users from
> usrloc module. Here is the code:
>
>  LOG(L_INFO,"PRESOURCE: Initializing\n");
>     bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
>     if ( !bind_usrloc ) {
>          LOG(L_CRIT, "Can't bind usrloc (find_export) check if loaded");
>          goto error;
>     }
>     if ( !bind_usrloc(&ul) ) {
>          LOG(L_CRIT, "Can't bind usrloc");
>          goto error;
>     }
>   
bind_usrloc() returns 0 on success, so the condition in the if is wrong. 
Actually the bind_usrloc() is successfully.

Cheers,
Daniel


> When this code is enabled if fails on second if. Looks like usrloc module is
> not loaded. Here's the log
>
> 09/10 18:50:57 4431 info  <statistics.c: 135> INFO: statistics manager
> successfully initialized
> 09/10 18:50:57 4431 info  <uac.c: 139> UAC - initializing
> 09/10 18:50:57 4431 info  <hslot.c: 44> INFO:ul_init_locks: locks array size
> 512
> 09/10 18:50:57 4431 info  <pike.c: 108> PIKE - initializing
> 09/10 18:50:57 4431 info  <ip_tree.c: 86> INFO:pike:init_lock_set: probing
> 256 set size
> 09/10 18:50:57 4431 info  <avpops.c: 164> AVPops - initializing
> 09/10 18:50:57 4431 info  <sl.c: 130> StateLess module - initializing
> 09/10 18:50:57 4431 info  <tm.c: 586> TM - initializing...
> 09/10 18:50:57 4431 notice  <maxfwd.c: 97> Maxfwd module- initializing
> 09/10 18:50:57 4431 info  <presource.c: 146> PRESOURCE: Initializing
> 09/10 18:50:57 4431 crit  <presource.c: 155> Can't bind usrloc
> 09/10 18:50:57 4431 err  <sr_module.c: 465> init_mod(): Error while
> initializing module presource
>
> In config script loadmodule("usrloc.so") is prior to load my custom module.
> When I disable above code, then load order follows config file order.
>
> 2. Here's how I wanted to get number of users:
> unsigned long get_number_of_users()
> {
>     return ul.get_number_of_users();
> }
>
> But usrloc_api_t does not contain this cmd function despite it's exported in
> usrloc module
>
> typedef struct usrloc_api {
>         int           use_domain;
>         int           db_mode;
>         unsigned int  nat_flag;
>
>         register_udomain_t   register_udomain;
>         get_all_ucontacts_t  get_all_ucontacts;
>
>         insert_urecord_t     insert_urecord;
>         delete_urecord_t     delete_urecord;
>         get_urecord_t        get_urecord;
>         lock_udomain_t       lock_udomain;
>         unlock_udomain_t     unlock_udomain;
>
>         release_urecord_t    release_urecord;
>         insert_ucontact_t    insert_ucontact;
>         delete_ucontact_t    delete_ucontact;
>         get_ucontact_t       get_ucontact;
>
>         update_ucontact_t    update_ucontact;
>
>         register_watcher_t   register_watcher;
>         unregister_watcher_t unregister_watcher;
>         register_ulcb_t      register_ulcb;
> } usrloc_api_t;
>
>
> Thanks,
> Toly
>
>   

-- 
Daniel-Constantin Mierla
http://www.asipto.com





More information about the Users mailing list