Hi All,

I was wondering if there was an existing pattern is Kamailio to deal with long-running code being executed on a callback. If we take, for example, usrloc. Lets say the domains are synced every 60 seconds. Assume there are going to be 200 expired contacts at the next fire. Now imagine the callback for each expired contact having to do some long IO (viz talking to DB, in IMS case doing diameter, etc). Under load, some of these task can be in excess of 100ms. In this specific case your timer (albeit most likely a slow timer in this case) will be "stuck" running the callbacks for a good (100ms x 200) = 20 seconds :-/

I can only think of using some form of async model to get around this. I know there would be the pain of most likely having to use reference counting, for example in usrloc on urecords and ucontacts. 

Does anyone have any ideas around this? Is there a gap to look at some core functionality for handling async callbacks? does it already exist and I have missed it?

ideas/comments welcome.

cheers
jason