[asterisk-commits] oej: branch group/multiparking r104049 - /team/group/multiparking/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Feb 23 08:58:37 CST 2008
Author: oej
Date: Sat Feb 23 08:58:36 2008
New Revision: 104049
URL: http://svn.digium.com/view/asterisk?view=rev&rev=104049
Log:
Change name of "parkinglot" in main/features.c to "parkings" to avoid confusion with "parkinglots" in multiparking.
(To make life more easy and beer-friendly at FosDem Asterisk dev table)
Modified:
team/group/multiparking/main/features.c
Modified: team/group/multiparking/main/features.c
URL: http://svn.digium.com/view/asterisk/team/group/multiparking/main/features.c?view=diff&rev=104049&r1=104048&r2=104049
==============================================================================
--- team/group/multiparking/main/features.c (original)
+++ team/group/multiparking/main/features.c Sat Feb 23 08:58:36 2008
@@ -1,3 +1,10 @@
+/*
+ ASTOBJ PARKINGLOTS
+ -> List of parking spaces
+
+ TODO: Initialize the list of parkedcalls when initializing a parkinglot
+ Remove it when removing a parking lot
+*/
/*
* Asterisk -- An open source telephony toolkit.
*
@@ -103,6 +110,27 @@
static char pickup_ext[AST_MAX_EXTENSION]; /*!< Call pickup extension */
+/*! \brief Description of one parked call, added to a list while active, then removed.
+ The list belongs to a parkinglot
+*/
+struct parkeduser {
+ struct ast_channel *chan; /*!< Parking channel */
+ struct timeval start; /*!< Time the parking started */
+ int parkingnum; /*!< Parking lot */
+ char parkingexten[AST_MAX_EXTENSION]; /*!< If set beforehand, parking extension used for this call */
+ char context[AST_MAX_CONTEXT]; /*!< Where to go if our parking time expires */
+ char exten[AST_MAX_EXTENSION];
+ int priority;
+ int parkingtime; /*!< Maximum length in parking lot before return */
+ int notquiteyet;
+ char peername[1024];
+ unsigned char moh_trys;
+ struct ast_parkinglot *parkinglot;
+ AST_LIST_ENTRY(parkeduser) list; /* Temporary disabled, will come back to an Asterisk near you soon */
+};
+
+AST_LIST_HEAD(parkinglot_parklist, parkeduser);
+
/*! \brief Structure for parking lots in a linked list. */
struct ast_parkinglot {
ASTOBJ_COMPONENTS(struct ast_parkinglot); /*!< various object stuff, including ->name */
@@ -116,6 +144,7 @@
int parkingtime; /*!< Default parking time */
struct parkeduser *occupiedlots;
char parkmohclass[MAX_MUSICCLASS]; /*!< Music class used for parking */
+ struct parkinglot_parklist parkings; /*!< List of active parkings in this parkinglot */
};
/*! \brief The list of parking lots configured. Always at least one - the default parking lot */
@@ -177,23 +206,7 @@
static struct ast_app *stopmixmonitor_app = NULL;
static int stopmixmonitor_ok = 1;
-struct parkeduser {
- struct ast_channel *chan; /*!< Parking channel */
- struct timeval start; /*!< Time the parking started */
- int parkingnum; /*!< Parking lot */
- char parkingexten[AST_MAX_EXTENSION]; /*!< If set beforehand, parking extension used for this call */
- char context[AST_MAX_CONTEXT]; /*!< Where to go if our parking time expires */
- char exten[AST_MAX_EXTENSION];
- int priority;
- int parkingtime; /*!< Maximum length in parking lot before return */
- int notquiteyet;
- char peername[1024];
- unsigned char moh_trys;
- struct ast_parkinglot *parkinglot;
-// AST_LIST_ENTRY(parkeduser) list; /* Temporary disabled, will come back to an Asterisk near you soon */
-};
-
-//static AST_LIST_HEAD_STATIC(parkinglot, parkeduser); /* Temporary disabled, will come back to an Asterisk near you soon */
+
/* Forward declarations */
static struct ast_parkinglot *parkinglot_addref(struct ast_parkinglot *parkinglot);
@@ -455,14 +468,14 @@
ASTOBJ_WRLOCK(parkinglot);
- /* Lock parking lot */
- //AST_LIST_LOCK(&parkinglot);
+ /* Lock parking list */
+ AST_LIST_LOCK(&parkinglot->parkings);
/* Check for channel variable PARKINGEXTEN */
parkingexten = pbx_builtin_getvar_helper(chan, "PARKINGEXTEN");
if (!ast_strlen_zero(parkingexten)) {
if (ast_exists_extension(NULL, parkinglot->parking_con, parkingexten, 1, NULL)) {
- //AST_LIST_UNLOCK(&parkinglot);
- parkinglot_unref(parkinglot);
+ AST_LIST_UNLOCK(&parkinglot->parkings);
+ parkinglot_unref(parkinglot->parkings);
ast_free(pu);
ast_log(LOG_WARNING, "Requested parking extension already exists: %s@%s\n", parkingexten, parkinglot->parking_con);
return 1; /* Continue execution if possible */
@@ -524,12 +537,13 @@
pu->priority = chan->macropriority ? chan->macropriority : chan->priority;
pu->next = parkinglot->occupiedlots;
parkinglot->occupiedlots = pu;
- ASTOBJ_UNLOCK(parkinglot);
/* If parking a channel directly, don't quiet yet get parking running on it */
if (peer == chan)
pu->notquiteyet = 1;
- AST_LIST_UNLOCK(&parkinglot);
+ AST_LIST_UNLOCK(&parkinglot->parkings);
+
+ ASTOBJ_UNLOCK(parkinglot);
/* Wake up the (presumably select()ing) thread */
pthread_kill(parking_thread, SIGURG);
ast_verb(2, "Parked %s on %d (lot %s). Will timeout back to extension [%s] %s, %d in %d seconds\n", pu->chan->name, pu->parkingnum, parkinglot->name, pu->context, pu->exten, pu->priority, (pu->parkingtime/1000));
@@ -2260,6 +2274,7 @@
FD_ZERO(&efds);
for (;;) {
+SKREP
struct parkeduser *pu;
int ms = -1; /* select timeout, uninitialized */
int max = -1; /* max fd, none there yet */
@@ -2267,8 +2282,8 @@
FD_ZERO(&nrfds);
FD_ZERO(&nefds);
- AST_LIST_LOCK(&parkinglot);
- AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot, pu, list) {
+ AST_LIST_LOCK(&parkings);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&parkings, pu, list) {
struct ast_channel *chan = pu->chan; /* shorthand */
int tms; /* timeout for this item */
int x; /* fd index in channel */
@@ -2300,8 +2315,6 @@
ast_log(LOG_ERROR, "Parking dial context '%s' does not exist and unable to create\n", parking_con_dial);
}
if (con) {
- char returnexten[AST_MAX_EXTENSION];
- snprintf(returnexten, sizeof(returnexten), "%s,,t", peername);
ast_add_extension2(con, 1, peername_flat, 1, NULL, NULL, "Dial", ast_strdup(returnexten), ast_free_ptr, registrar);
}
if (comebacktoorigin) {
@@ -2402,7 +2415,7 @@
}
} /* end while */
AST_LIST_TRAVERSE_SAFE_END
- AST_LIST_UNLOCK(&parkinglot);
+ AST_LIST_UNLOCK(&parkings);
rfds = nrfds;
efds = nefds;
{
@@ -2469,15 +2482,15 @@
if (data)
park = atoi((char *)data);
- AST_LIST_LOCK(&parkinglot);
- AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot, pu, list) {
+ AST_LIST_LOCK(&parkings);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&parkings, pu, list) {
if (!data || pu->parkingnum == park) {
AST_LIST_REMOVE_CURRENT(list);
break;
}
}
AST_LIST_TRAVERSE_SAFE_END
- AST_LIST_UNLOCK(&parkinglot);
+ AST_LIST_UNLOCK(&parkings);
if (pu) {
peer = pu->chan;
@@ -3142,15 +3155,15 @@
ast_cli(a->fd, "%4s %25s (%-15s %-12s %-4s) %-6s \n", "Num", "Channel"
, "Context", "Extension", "Pri", "Timeout");
- AST_LIST_LOCK(&parkinglot);
- AST_LIST_TRAVERSE(&parkinglot, cur, list) {
+ AST_LIST_LOCK(&parkings);
+ AST_LIST_TRAVERSE(&parkings, cur, list) {
ast_cli(a->fd, "%-10.10s %25s (%-15s %-12s %-4d) %6lds\n"
,cur->parkingexten, cur->chan->name, cur->context, cur->exten
,cur->priority, cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL));
numparked++;
}
- AST_LIST_UNLOCK(&parkinglot);
+ AST_LIST_UNLOCK(&parkings);
ast_cli(a->fd, "%d parked call%s.\n", numparked, ESS(numparked));
@@ -3192,9 +3205,9 @@
astman_send_ack(s, m, "Parked calls will follow");
- AST_LIST_LOCK(&parkinglot);
-
- AST_LIST_TRAVERSE(&parkinglot, cur, list) {
+ AST_LIST_LOCK(&parkings);
+
+ AST_LIST_TRAVERSE(&parkings, cur, list) {
astman_append(s, "Event: ParkedCall\r\n"
"Exten: %d\r\n"
"Channel: %s\r\n"
@@ -3216,7 +3229,7 @@
"%s"
"\r\n",idText);
- AST_LIST_UNLOCK(&parkinglot);
+ AST_LIST_UNLOCK(&parkings);
return RESULT_SUCCESS;
}
More information about the asterisk-commits
mailing list