Review Board 1.7.16


Add a reloadable option for sorcery type objects

Review Request #2807 - Created Aug. 29, 2013 and submitted

Kevin Harwell
12
ASTERISK-22382, ASTERISK-22384
Reviewers
asterisk-dev
Asterisk
Some configuration objects currently won't place nice if reloaded.  Specifically, in this case the pjsip transport objects.  Now when registering an object in sorcery one may specify that the object is allowed to be reloaded or not.  If the object is set to not reload then upon reloading of the configuration the objects of that type will not be reloaded.  The initially loaded objects of that type however will remain.

While the transport objects will not longer be reloaded it is still possible for a user to configure an endpoint to an invalid transport.  A couple of log messages were added to help diagnose this problem if it occurs.
Ran asterisk with a couple of pjsip endpoints configured for a valid transport.  Changed the transport name on the transport type and issued a 'core reload' and observed that the transport was not reloaded and calls could still be made.  Then changed the transport name on an endpoint to one that didn't exist and after reloading observed that calls failed, but an error message was logged stating that the transport could not be found.  Also verified the reported crash no longer occurred.
branches/12/include/asterisk/sorcery.h
Revision 398018 New Change
[20] 353 lines
[+20] [+] int __ast_sorcery_apply_default(struct ast_sorcery *sorcery, const char *type, const char *module, const char *name, const char *data);
354
 * macro'd versions should be used instead.
354
 * macro'd versions should be used instead.
355
 *
355
 *
356
 * \retval 0 success
356
 * \retval 0 success
357
 * \retval -1 failure
357
 * \retval -1 failure
358
 */
358
 */
359
int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply);
359
int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, unsigned int reloadable, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply);
360

    
   
360

   
361
/*!
361
/*!
362
 * \brief Register an object type
362
 * \brief Register an object type
363
 *
363
 *
364
 * \param sorcery Pointer to a sorcery structure
364
 * \param sorcery Pointer to a sorcery structure
[+20] [20] 4 lines
[+20] int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply); int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, unsigned int reloadable, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply);
369
 *
369
 *
370
 * \retval 0 success
370
 * \retval 0 success
371
 * \retval -1 failure
371
 * \retval -1 failure
372
 */
372
 */
373
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply) \
373
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply) \
374
	__ast_sorcery_object_register((sorcery), (type), 0, (alloc), (transform), (apply))
374
	__ast_sorcery_object_register((sorcery), (type), 0, 1, (alloc), (transform), (apply))

    
   
375

   

    
   
376
/*!

    
   
377
 * \brief Register an object type that is not reloadable

    
   
378
 *

    
   
379
 * \param sorcery Pointer to a sorcery structure

    
   
380
 * \param type Type of object

    
   
381
 * \param alloc Required object allocation callback

    
   
382
 * \param transform Optional transformation callback

    
   
383
 * \param apply Optional object set apply callback

    
   
384
 *

    
   
385
 * \retval 0 success

    
   
386
 * \retval -1 failure

    
   
387
 */

    
   
388
#define ast_sorcery_object_register_no_reload(sorcery, type, alloc, transform, apply) \

    
   
389
	__ast_sorcery_object_register((sorcery), (type), 0, 0, (alloc), (transform), (apply))
375

    
   
390

   
376
/*!
391
/*!
377
 * \brief Register an internal, hidden object type
392
 * \brief Register an internal, hidden object type
378
 *
393
 *
379
 * \param sorcery Pointer to a sorcery structure
394
 * \param sorcery Pointer to a sorcery structure
[+20] [20] 4 lines
[+20] int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply); int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, unsigned int reloadable, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply);
384
 *
399
 *
385
 * \retval 0 success
400
 * \retval 0 success
386
 * \retval -1 failure
401
 * \retval -1 failure
387
 */
402
 */
388
#define ast_sorcery_internal_object_register(sorcery, type, alloc, transform, apply) \
403
#define ast_sorcery_internal_object_register(sorcery, type, alloc, transform, apply) \
389
	__ast_sorcery_object_register((sorcery), (type), 1, (alloc), (transform), (apply))
404
	__ast_sorcery_object_register((sorcery), (type), 1, 1, (alloc), (transform), (apply))
390

    
   
405

   
391
/*!
406
/*!
392
 * \brief Set the copy handler for an object type
407
 * \brief Set the copy handler for an object type
393
 *
408
 *
394
 * \param sorcery Pointer to a sorcery structure
409
 * \param sorcery Pointer to a sorcery structure
[+20] [20] 417 lines
branches/12/main/sorcery.c
Revision 398018 New Change
 
branches/12/res/res_pjsip.c
Revision 398018 New Change
 
branches/12/res/res_pjsip_outbound_registration.c
Revision 398018 New Change
 
branches/12/res/res_pjsip/config_transport.c
Revision 398018 New Change
 
  1. branches/12/include/asterisk/sorcery.h: Loading...
  2. branches/12/main/sorcery.c: Loading...
  3. branches/12/res/res_pjsip.c: Loading...
  4. branches/12/res/res_pjsip_outbound_registration.c: Loading...
  5. branches/12/res/res_pjsip/config_transport.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.