[asterisk-commits] file: branch file/res_sorcery_astdb r383407 - in /team/file/res_sorcery_astdb...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 20 09:55:29 CDT 2013
Author: file
Date: Wed Mar 20 09:55:27 2013
New Revision: 383407
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383407
Log:
Multiple revisions 383343,383377,383405
........
r383343 | dlee | 2013-03-19 13:00:22 -0300 (Tue, 19 Mar 2013) | 17 lines
Multiple revisions 383341-383342
........
r383341 | dlee | 2013-03-19 10:57:29 -0500 (Tue, 19 Mar 2013) | 5 lines
Removed codecs/g722/*.i on make clean
........
Merged revisions 383340 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
r383342 | dlee | 2013-03-19 10:58:33 -0500 (Tue, 19 Mar 2013) | 1 line
Remove codecs/speex/*.i on make clean
........
Merged revisions 383341-383342 from http://svn.asterisk.org/svn/asterisk/branches/11
........
r383377 | kmoore | 2013-03-19 16:07:46 -0300 (Tue, 19 Mar 2013) | 5 lines
Fix lock destruction/unlock inversion
When using scoped locks, the unref of an AO2 object should happen after
the unlock occurs which requires usage of scoped refs.
........
r383405 | file | 2013-03-20 11:52:23 -0300 (Wed, 20 Mar 2013) | 2 lines
Pass the sorcery instance to wizards for CUD operations as well as retrieve.
........
Merged revisions 383343,383377,383405 from http://svn.asterisk.org/svn/asterisk/trunk
Modified:
team/file/res_sorcery_astdb/ (props changed)
team/file/res_sorcery_astdb/codecs/Makefile
team/file/res_sorcery_astdb/include/asterisk/sorcery.h
team/file/res_sorcery_astdb/main/sorcery.c
team/file/res_sorcery_astdb/main/stasis_message_router.c
team/file/res_sorcery_astdb/res/res_sorcery_memory.c
team/file/res_sorcery_astdb/tests/test_sorcery.c
Propchange: team/file/res_sorcery_astdb/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Propchange: team/file/res_sorcery_astdb/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 20 09:55:27 2013
@@ -1,1 +1,1 @@
-/trunk:1-383321
+/trunk:1-383406
Modified: team/file/res_sorcery_astdb/codecs/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/codecs/Makefile?view=diff&rev=383407&r1=383406&r2=383407
==============================================================================
--- team/file/res_sorcery_astdb/codecs/Makefile (original)
+++ team/file/res_sorcery_astdb/codecs/Makefile Wed Mar 20 09:55:27 2013
@@ -53,8 +53,8 @@
for dir in $(SUB_DIRS); do \
$(MAKE) -C $$dir clean; \
done
- rm -f g722/*.[oa]
- rm -f speex/*.[oa]
+ rm -f g722/*.[oai]
+ rm -f speex/*.[oai]
.PHONY: $(SUB_DIRS)
Modified: team/file/res_sorcery_astdb/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/include/asterisk/sorcery.h?view=diff&rev=383407&r1=383406&r2=383407
==============================================================================
--- team/file/res_sorcery_astdb/include/asterisk/sorcery.h (original)
+++ team/file/res_sorcery_astdb/include/asterisk/sorcery.h Wed Mar 20 09:55:27 2013
@@ -203,7 +203,7 @@
void (*reload)(void *data, const struct ast_sorcery *sorcery, const char *type);
/*! \brief Callback for creating an object */
- int (*create)(void *data, void *object);
+ int (*create)(const struct ast_sorcery *sorcery, void *data, void *object);
/*! \brief Callback for retrieving an object using an id */
void *(*retrieve_id)(const struct ast_sorcery *sorcery, void *data, const char *type, const char *id);
@@ -218,10 +218,10 @@
void (*retrieve_multiple)(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const struct ast_variable *fields);
/*! \brief Callback for updating an object */
- int (*update)(void *data, void *object);
+ int (*update)(const struct ast_sorcery *sorcery, void *data, void *object);
/*! \brief Callback for deleting an object */
- int (*delete)(void *data, void *object);
+ int (*delete)(const struct ast_sorcery *sorcery, void *data, void *object);
/*! \brief Callback for closing a wizard */
void (*close)(void *data);
Modified: team/file/res_sorcery_astdb/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/main/sorcery.c?view=diff&rev=383407&r1=383406&r2=383407
==============================================================================
--- team/file/res_sorcery_astdb/main/sorcery.c (original)
+++ team/file/res_sorcery_astdb/main/sorcery.c Wed Mar 20 09:55:27 2013
@@ -888,16 +888,25 @@
}
}
+/*! \brief Structure used when calling create, update, or delete */
+struct sorcery_details {
+ /*! \brief Pointer to the sorcery instance */
+ const struct ast_sorcery *sorcery;
+ /*! \brief Pointer to the object itself */
+ void *obj;
+};
+
/*! \brief Internal function used to create an object in caching wizards */
static int sorcery_cache_create(void *obj, void *arg, int flags)
{
- struct ast_sorcery_object_wizard *object_wizard = obj;
+ const struct ast_sorcery_object_wizard *object_wizard = obj;
+ const struct sorcery_details *details = arg;
if (!object_wizard->caching || !object_wizard->wizard->create) {
return 0;
}
- object_wizard->wizard->create(object_wizard->data, arg);
+ object_wizard->wizard->create(details->sorcery, object_wizard->data, details->obj);
return 0;
}
@@ -1014,8 +1023,9 @@
static int sorcery_wizard_create(void *obj, void *arg, int flags)
{
const struct ast_sorcery_object_wizard *object_wizard = obj;
-
- return (!object_wizard->caching && !object_wizard->wizard->create(object_wizard->data, arg)) ? CMP_MATCH | CMP_STOP : 0;
+ const struct sorcery_details *details = arg;
+
+ return (!object_wizard->caching && !object_wizard->wizard->create(details->sorcery, object_wizard->data, details->obj)) ? CMP_MATCH | CMP_STOP : 0;
}
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
@@ -1023,12 +1033,16 @@
const struct ast_sorcery_object_details *details = object;
RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, details->type, OBJ_KEY), ao2_cleanup);
RAII_VAR(struct ast_sorcery_object_wizard *, object_wizard, NULL, ao2_cleanup);
+ struct sorcery_details sdetails = {
+ .sorcery = sorcery,
+ .obj = object,
+ };
if (!object_type) {
return -1;
}
- object_wizard = ao2_callback(object_type->wizards, 0, sorcery_wizard_create, object);
+ object_wizard = ao2_callback(object_type->wizards, 0, sorcery_wizard_create, &sdetails);
return object_wizard ? 0 : -1;
}
@@ -1037,8 +1051,9 @@
static int sorcery_wizard_update(void *obj, void *arg, int flags)
{
const struct ast_sorcery_object_wizard *object_wizard = obj;
-
- return (object_wizard->wizard->update && !object_wizard->wizard->update(object_wizard->data, arg) &&
+ const struct sorcery_details *details = arg;
+
+ return (object_wizard->wizard->update && !object_wizard->wizard->update(details->sorcery, object_wizard->data, details->obj) &&
!object_wizard->caching) ? CMP_MATCH | CMP_STOP : 0;
}
@@ -1047,12 +1062,16 @@
const struct ast_sorcery_object_details *details = object;
RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, details->type, OBJ_KEY), ao2_cleanup);
RAII_VAR(struct ast_sorcery_object_wizard *, object_wizard, NULL, ao2_cleanup);
+ struct sorcery_details sdetails = {
+ .sorcery = sorcery,
+ .obj = object,
+ };
if (!object_type) {
return -1;
}
- object_wizard = ao2_callback(object_type->wizards, 0, sorcery_wizard_update, object);
+ object_wizard = ao2_callback(object_type->wizards, 0, sorcery_wizard_update, &sdetails);
return object_wizard ? 0 : -1;
}
@@ -1061,8 +1080,9 @@
static int sorcery_wizard_delete(void *obj, void *arg, int flags)
{
const struct ast_sorcery_object_wizard *object_wizard = obj;
-
- return (object_wizard->wizard->delete && !object_wizard->wizard->delete(object_wizard->data, arg) &&
+ const struct sorcery_details *details = arg;
+
+ return (object_wizard->wizard->delete && !object_wizard->wizard->delete(details->sorcery, object_wizard->data, details->obj) &&
!object_wizard->caching) ? CMP_MATCH | CMP_STOP : 0;
}
@@ -1071,12 +1091,16 @@
const struct ast_sorcery_object_details *details = object;
RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, details->type, OBJ_KEY), ao2_cleanup);
RAII_VAR(struct ast_sorcery_object_wizard *, object_wizard, NULL, ao2_cleanup);
+ struct sorcery_details sdetails = {
+ .sorcery = sorcery,
+ .obj = object,
+ };
if (!object_type) {
return -1;
}
- object_wizard = ao2_callback(object_type->wizards, 0, sorcery_wizard_delete, object);
+ object_wizard = ao2_callback(object_type->wizards, 0, sorcery_wizard_delete, &sdetails);
return object_wizard ? 0 : -1;
}
Modified: team/file/res_sorcery_astdb/main/stasis_message_router.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/main/stasis_message_router.c?view=diff&rev=383407&r1=383406&r2=383407
==============================================================================
--- team/file/res_sorcery_astdb/main/stasis_message_router.c (original)
+++ team/file/res_sorcery_astdb/main/stasis_message_router.c Wed Mar 20 09:55:27 2013
@@ -91,6 +91,7 @@
struct stasis_message *message)
{
struct stasis_message_router *router = data;
+ RAII_VAR(struct stasis_message_router *, router_needs_cleanup, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message_route *, route, NULL, ao2_cleanup);
struct stasis_message_type *type = stasis_message_type(message);
size_t i;
@@ -123,7 +124,7 @@
}
if (stasis_subscription_final_message(sub, message)) {
- ao2_cleanup(router);
+ router_needs_cleanup = router;
return;
}
Modified: team/file/res_sorcery_astdb/res/res_sorcery_memory.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/res/res_sorcery_memory.c?view=diff&rev=383407&r1=383406&r2=383407
==============================================================================
--- team/file/res_sorcery_astdb/res/res_sorcery_memory.c (original)
+++ team/file/res_sorcery_astdb/res/res_sorcery_memory.c Wed Mar 20 09:55:27 2013
@@ -42,14 +42,14 @@
#define OBJECT_BUCKETS 53
static void *sorcery_memory_open(const char *data);
-static int sorcery_memory_create(void *data, void *object);
+static int sorcery_memory_create(const struct ast_sorcery *sorcery, void *data, void *object);
static void *sorcery_memory_retrieve_id(const struct ast_sorcery *sorcery, void *data, const char *type, const char *id);
static void *sorcery_memory_retrieve_fields(const struct ast_sorcery *sorcery, void *data, const char *type, const struct ast_variable *fields);
static void sorcery_memory_retrieve_multiple(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects,
const struct ast_variable *fields);
static void sorcery_memory_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex);
-static int sorcery_memory_update(void *data, void *object);
-static int sorcery_memory_delete(void *data, void *object);
+static int sorcery_memory_update(const struct ast_sorcery *sorcery, void *data, void *object);
+static int sorcery_memory_delete(const struct ast_sorcery *sorcery, void *data, void *object);
static void sorcery_memory_close(void *data);
static struct ast_sorcery_wizard memory_object_wizard = {
@@ -96,7 +96,7 @@
return !strcmp(ast_sorcery_object_get_id(obj), flags & OBJ_KEY ? id : ast_sorcery_object_get_id(arg)) ? CMP_MATCH | CMP_STOP : 0;
}
-static int sorcery_memory_create(void *data, void *object)
+static int sorcery_memory_create(const struct ast_sorcery *sorcery, void *data, void *object)
{
ao2_link(data, object);
return 0;
@@ -184,7 +184,7 @@
regfree(&expression);
}
-static int sorcery_memory_update(void *data, void *object)
+static int sorcery_memory_update(const struct ast_sorcery *sorcery, void *data, void *object)
{
RAII_VAR(void *, existing, NULL, ao2_cleanup);
@@ -202,7 +202,7 @@
return 0;
}
-static int sorcery_memory_delete(void *data, void *object)
+static int sorcery_memory_delete(const struct ast_sorcery *sorcery, void *data, void *object)
{
RAII_VAR(void *, existing, ao2_find(data, ast_sorcery_object_get_id(object), OBJ_KEY | OBJ_UNLINK), ao2_cleanup);
Modified: team/file/res_sorcery_astdb/tests/test_sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/tests/test_sorcery.c?view=diff&rev=383407&r1=383406&r2=383407
==============================================================================
--- team/file/res_sorcery_astdb/tests/test_sorcery.c (original)
+++ team/file/res_sorcery_astdb/tests/test_sorcery.c Wed Mar 20 09:55:27 2013
@@ -138,7 +138,7 @@
/*! \brief Global scope caching structure for testing */
static struct sorcery_test_caching cache = { 0, };
-static int sorcery_test_create(void *data, void *object)
+static int sorcery_test_create(const struct ast_sorcery *sorcery, void *data, void *object)
{
cache.created = 1;
cache.updated = 0;
@@ -151,13 +151,13 @@
return (cache.created && !cache.deleted) ? ast_sorcery_alloc(sorcery, type, id) : NULL;
}
-static int sorcery_test_update(void *data, void *object)
+static int sorcery_test_update(const struct ast_sorcery *sorcery, void *data, void *object)
{
cache.updated = 1;
return 0;
}
-static int sorcery_test_delete(void *data, void *object)
+static int sorcery_test_delete(const struct ast_sorcery *sorcery, void *data, void *object)
{
cache.deleted = 1;
return 0;
More information about the asterisk-commits
mailing list