[Freeswitch-svn] [commit] r11955 - freeswitch/trunk/src/mod/applications/mod_limit
FreeSWITCH SVN
mrene at freeswitch.org
Thu Feb 12 13:19:52 PST 2009
Author: mrene
Date: Thu Feb 12 15:19:52 2009
New Revision: 11955
Log:
Make max argument optional on the limit app, set the limit_usage variable with the current count after inserting the call in the db
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Thu Feb 12 15:19:52 2009
@@ -701,7 +701,7 @@
}
}
-#define LIMIT_USAGE "<realm> <id> <max> [number [dialplan [context]]]"
+#define LIMIT_USAGE "<realm> <id> [<max> [number [dialplan [context]]]]"
#define LIMIT_DESC "limit access to a resource and transfer to an extension if the limit is exceeded"
static char *limit_def_xfer_exten = "limit_exceeded";
@@ -727,14 +727,23 @@
if (argc < 3) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: limit %s\n", LIMIT_USAGE);
- return;
+ goto done;
}
switch_mutex_lock(globals.mutex);
realm = argv[0];
id = argv[1];
- max = atoi(argv[2]);
+
+ if (argc > 2) {
+ max = atoi(argv[2]);
+ if (max < 0) {
+ max = 0;
+ }
+ }
+ else {
+ max = -1;
+ }
if (argc >= 4) {
xfer_exten = argv[3];
@@ -742,9 +751,6 @@
xfer_exten = limit_def_xfer_exten;
}
- if (max < 0) {
- max = 0;
- }
new_channel = !switch_channel_get_variable(channel, "limit_realm");
switch_channel_set_variable(channel, "limit_realm", realm);
@@ -758,7 +764,7 @@
switch_safe_free(sql);
got = atoi(buf);
- if (got + 1 > max) {
+ if (max > 0 && got + 1 > max) {
switch_ivr_session_transfer(session, xfer_exten, argv[4], argv[5]);
goto done;
}
@@ -771,8 +777,11 @@
switch_core_session_get_uuid(session));
limit_execute_sql(sql, NULL);
switch_safe_free(sql);
+
+ switch_channel_set_variable(channel, "limit_usage", switch_core_session_sprintf(session, "%d", ++got));
done:
+ switch_safe_free(mydata);
switch_mutex_unlock(globals.mutex);
}
More information about the Freeswitch-svn
mailing list