[asterisk-commits] dhubbard: branch dhubbard/named_processors r108638 - in /team/dhubbard/named_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 13 17:50:24 CDT 2008
Author: dhubbard
Date: Thu Mar 13 17:50:24 2008
New Revision: 108638
URL: http://svn.digium.com/view/asterisk?view=rev&rev=108638
Log:
updated to adhere more to CODING-GUIDELINES and adjustments in response to feedback from russell
Modified:
team/dhubbard/named_processors/apps/app_queue.c
team/dhubbard/named_processors/include/asterisk/task.h
team/dhubbard/named_processors/include/asterisk/taskprocessor.h
team/dhubbard/named_processors/res/sandbox/configuration.c
team/dhubbard/named_processors/res/sandbox/include/task.h
team/dhubbard/named_processors/res/sandbox/simobject.c
team/dhubbard/named_processors/res/sandbox/task.c
team/dhubbard/named_processors/res/sandbox/taskconsumer.c
team/dhubbard/named_processors/res/sandbox/taskprocessor.c
team/dhubbard/named_processors/res/sandbox/taskproducer.c
Modified: team/dhubbard/named_processors/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/apps/app_queue.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/apps/app_queue.c (original)
+++ team/dhubbard/named_processors/apps/app_queue.c Thu Mar 13 17:50:24 2008
@@ -92,8 +92,8 @@
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/global_datastores.h"
+#include "asterisk/taskprocessor.h"
#include "asterisk/task.h"
-#include "asterisk/taskprocessor.h"
#include "asterisk/taskproducer.h"
/*!
@@ -691,13 +691,13 @@
char *technology;
struct statechange *sc = task->_datap;
- ast_log(LOG_NOTICE, "device %s received state change %s\n", sc->dev, devstate2str(sc->state));
-
technology = ast_strdupa(sc->dev);
loc = strchr(technology, '/');
if (loc) {
*loc++ = '\0';
} else {
+ ast_free(sc);
+ task->_datap = NULL;
return 0;
}
@@ -717,6 +717,8 @@
if (!curint) {
ast_debug(3, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
+ ast_free(sc);
+ task->_datap = NULL;
return 0;
}
@@ -763,7 +765,8 @@
queue_unref(q);
ao2_unlock(q);
}
-
+ ast_free(sc);
+ task->_datap = NULL;
return 0;
}
@@ -805,13 +808,11 @@
}
sc->state = state;
strcpy(sc->dev, device);
- t = get_available_task(handle_statechange, sc, datapsize, "app_queue-device_state_cb");
+ t = get_available_task(handle_statechange, sc, "app_queue-device_state_cb");
if (tpsp->queue_task(tpsp, t) < 0) {
ast_log(LOG_WARNING, "queue_task failed!!\n");
release_task(t);
}
- ast_log(LOG_NOTICE, "queued statechange for %s\n", device);
- ast_free(sc); /* maybe alloca ?? */
}
/*! \brief allocate space for new queue member and set fields based on parameters passed */
Modified: team/dhubbard/named_processors/include/asterisk/task.h
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/include/asterisk/task.h?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/include/asterisk/task.h (original)
+++ team/dhubbard/named_processors/include/asterisk/task.h Thu Mar 13 17:50:24 2008
@@ -40,7 +40,7 @@
* get an available a_task structure from the pool of available
* structures. If no structures are available, allocate one
*/
-struct a_task* get_available_task(int (*task_exe)(struct a_task *task), void* datap, size_t size, char* src);
+struct a_task* get_available_task(int (*task_exe)(struct a_task *task), void* datap, char* src);
int task_pool_size(void);
/*
* release a_task structure back to the pool
Modified: team/dhubbard/named_processors/include/asterisk/taskprocessor.h
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/include/asterisk/taskprocessor.h?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/include/asterisk/taskprocessor.h (original)
+++ team/dhubbard/named_processors/include/asterisk/taskprocessor.h Thu Mar 13 17:50:24 2008
@@ -61,7 +61,7 @@
struct a_task* pop_task_from_taskprocessor_singleton(struct taskprocessor_singleton_info* tp);
int size_of_taskprocessor_singleton_queue(struct taskprocessor_singleton_info* tp);
-int register_sandbox_taskprocessor_clis(void);
-int unregister_sandbox_taskprocessor_clis(void);
+int register_taskprocessor_clis(void);
+int unregister_taskprocessor_clis(void);
#endif
Modified: team/dhubbard/named_processors/res/sandbox/configuration.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/configuration.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/configuration.c (original)
+++ team/dhubbard/named_processors/res/sandbox/configuration.c Thu Mar 13 17:50:24 2008
@@ -15,6 +15,9 @@
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
#include "include/sandbox.h"
#include "include/configuration.h"
Modified: team/dhubbard/named_processors/res/sandbox/include/task.h
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/include/task.h?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/include/task.h (original)
+++ team/dhubbard/named_processors/res/sandbox/include/task.h Thu Mar 13 17:50:24 2008
@@ -29,7 +29,6 @@
struct a_task {
int (* execute)(struct a_task* t);
void *_datap;
- size_t _datapsize;
void* _p_producer;
void* _p_consumer;
time_t _timestamp;
@@ -41,7 +40,7 @@
* get an available a_task structure from the pool of available
* structures. If no structures are available, allocate one
*/
-struct a_task* get_available_task(int (*task_exe)(struct a_task *task), void* datap, size_t size, char* src);
+struct a_task* get_available_task(int (*task_exe)(struct a_task *task), void* datap, char* src);
int task_pool_size(void);
/*
* release a_task structure back to the pool
Modified: team/dhubbard/named_processors/res/sandbox/simobject.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/simobject.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/simobject.c (original)
+++ team/dhubbard/named_processors/res/sandbox/simobject.c Thu Mar 13 17:50:24 2008
@@ -15,6 +15,9 @@
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
#include "include/simobject.h"
#include "include/taskdefinitions.h"
@@ -121,7 +124,7 @@
struct a_task* t = NULL;
if (s && s->_producer) {
- t = get_available_task(simobject_taskhandler, 0, 0, "start_simobject");
+ t = get_available_task(simobject_taskhandler, 0, "start_simobject");
if (!t) {
ast_log(LOG_ERROR, "ERROR: task pool failed to supply a task\n");
return -1;
@@ -143,7 +146,7 @@
struct a_task* t = NULL;
if (s && s->_producer) {
- t = get_available_task(simobject_taskhandler, 0, 0, "start_simproducer");
+ t = get_available_task(simobject_taskhandler, 0, "start_simproducer");
if (!t) {
ast_log(LOG_ERROR, "ERROR: task pool failed to supply a task\n");
return -1;
@@ -226,7 +229,7 @@
ast_log(LOG_ERROR, "Huh? we have no private simobject pointer? This is bad!\n");
break;
}
- t = get_available_task(simobject_taskhandler, 0, 0, "_simproducer_thread_function");
+ t = get_available_task(simobject_taskhandler, 0, "_simproducer_thread_function");
if (!t) {
ast_log(LOG_ERROR, "ERROR: task pool failed to supply a task\n");
break;
Modified: team/dhubbard/named_processors/res/sandbox/task.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/task.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/task.c (original)
+++ team/dhubbard/named_processors/res/sandbox/task.c Thu Mar 13 17:50:24 2008
@@ -15,6 +15,9 @@
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
#include "include/task.h"
AST_LIST_HEAD_STATIC(_task_pool, a_task);
@@ -32,16 +35,11 @@
* get an available a_task structure from the pool of available
* structures. If no structures are available, allocate one
*/
-struct a_task* get_available_task(int (*task_exe)(struct a_task *task), void* datap, size_t size, char* src)
+struct a_task* get_available_task(int (*task_exe)(struct a_task *task), void* datap, char* src)
{
struct a_task *t;
- void *tdata;
int lock_failures = 0;
- tdata = ast_calloc(1, size);
- if (tdata) {
- memcpy(tdata, datap, size);
- }
AST_LIST_LOCK(&_task_pool);
while (ast_mutex_trylock(&_global_kill_taskpool_lock)) {
lock_failures++;
@@ -69,8 +67,7 @@
return NULL;
}
t->execute = task_exe;
- t->_datap = tdata;
- t->_datapsize = size;
+ t->_datap = datap;
strncpy(t->_source, src, sizeof(t->_source));
ast_mutex_unlock(&_global_kill_taskpool_lock);
AST_LIST_UNLOCK(&_task_pool);
@@ -82,8 +79,7 @@
AST_LIST_UNLOCK(&_task_pool);
if (t) {
t->execute = task_exe;
- t->_datap = tdata;
- t->_datapsize = size;
+ t->_datap = datap;
strncpy(t->_source, src, sizeof(t->_source));
}
return t;
Modified: team/dhubbard/named_processors/res/sandbox/taskconsumer.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/taskconsumer.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/taskconsumer.c (original)
+++ team/dhubbard/named_processors/res/sandbox/taskconsumer.c Thu Mar 13 17:50:24 2008
@@ -21,6 +21,9 @@
* task consumer is also an observer-subject than it needs to notify-observers about
* its event.
*/
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
#include "include/task.h"
#include "include/taskconsumer.h"
#include "include/taskprocessor.h"
Modified: team/dhubbard/named_processors/res/sandbox/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/taskprocessor.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/taskprocessor.c (original)
+++ team/dhubbard/named_processors/res/sandbox/taskprocessor.c Thu Mar 13 17:50:24 2008
@@ -18,7 +18,9 @@
/*
* Maintain a container of taskprocessor threads that are uniquely named
*/
-#include <asterisk.h>
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
#include <asterisk/cli.h>
#include <sys/time.h>
#include "include/taskprocessor.h"
@@ -85,7 +87,7 @@
return CLI_SUCCESS;
}
- t = get_available_task(taskprocessor_ping, 0, 0, "cli_taskprocessor_ping");
+ t = get_available_task(taskprocessor_ping, 0, "cli_taskprocessor_ping");
if (!t) {
ast_cli(a->fd, "\n%s failed: could not retrieve task from pool\n", e->command);
return RESULT_SUCCESS;
Modified: team/dhubbard/named_processors/res/sandbox/taskproducer.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/taskproducer.c?view=diff&rev=108638&r1=108637&r2=108638
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/taskproducer.c (original)
+++ team/dhubbard/named_processors/res/sandbox/taskproducer.c Thu Mar 13 17:50:24 2008
@@ -20,6 +20,9 @@
* that is assigned the producer. This module managers the basics about
* the creation and services of a task producer.
*/
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
#include "include/task.h"
#include "include/taskproducer.h"
#include "include/taskprocessor.h"
More information about the asterisk-commits
mailing list