Thanks for your response Timo. I did not find the solution yet since I had to postpone this development for the future. I am sorry I forgot to reply you. Hopefully I can return to this in the future and I will let you know my code's situation.
Luis 2011/9/17 Timo Reimann <[email protected]> > Hey Luis, > > > Am 17.09.2011 um 17:44 schrieb Luis Martin Gil: > > This is Luis Martin. I am developing a new module for Kamailio. This > module will include some functions which will allow Kamailio to connect to > another servers and retrieve information. I'm thinking on creating a couple > of child from my main function, each child will execute a query to an > specific server. I read this file "doc/modules_init.txt", but I'm having > some troubles and I would appreciate if you could please help me with this. > > > > This is the how the the first draft of the forking code looks like: > > http://pastebin.com/MLXDN9p9 > > I call the "mod_child" function from my function like this: > > int myFunction () { > > (...) > > mod_child(randomNUMBER); > > (...) > > } > > > > But nothing happens, neither during the compilation process, nor the > execution. Nothing is printed on the logs. Can you please point me out any > suggestion or example? > > - How I am supposed to call the "mod_child()" function? > > You do not call it. It's called automatically by Kamailio for every child > configured. That is, if you have 16 workers set in your server > configuration, the function is called 16 times. Place initialization code > per child (e.g., establishing database connections) in that function, and > Kamailio will make sure the code will be carried out for each child. > > > > - Which should be the rank_number: PROC_MAIN? > > Again, you do not set the rank number, you use (read) it. As the > documentation states, the child initialization function is called multiple > times at different steps in the initialization process. By means of > comparing the rank number to PROC_MAIN and other constants, you can make > sure that you are doing specific tasks at the right time in the > initialization life cycle. > > The concept is the same as the way you do forking in Linux: fork()'s return > value of 0 indicates you're in a child process, anything else means you're > in the parent process. You do the comparison in the very same function, just > like you do in Kamailio's mod_child(). I noticed you fork off some children > yourself in your example code; not sure if that is supposed to work within > Kamailio, I've never done (or needed) it myself. If you're good with having > as many worker processes as there are configured in the Kamailio > configuration, you should be fine working with that. > > > > - How I am supposed to cal the "mod_init()" function? > > You don't. (I believe you got the idea by now. :) ). Just put your > non-child-specific initialization code there and let it get called by > Kamailio. > > > > - Again, could you please provide my any example? > > Pick a non-trivial module, many of them require child-based initialization. > Examples are the dialog or p_usrloc module. > > > HTH, > > --Timo
_______________________________________________ sr-dev mailing list [email protected] http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
