mod_limit: fix counter-only mode in limit_hash_execute

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14829 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Mathieu Rene 2009-09-11 16:03:52 +00:00
parent e2a0d2bc5e
commit a75c525dcc

View File

@ -1059,7 +1059,6 @@ SWITCH_STANDARD_APP(limit_hash_function)
char *xfer_exten = NULL;
int max = -1;
int interval = 0;
char *szinterval = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
/* Parse application data */
@ -1078,6 +1077,7 @@ SWITCH_STANDARD_APP(limit_hash_function)
/* If max is omitted, only act as a counter and skip maximum checks */
if (argc > 2) {
char *szinterval = NULL;
if ((szinterval = strchr(argv[2], '/')))
{
*szinterval++ = '\0';
@ -1121,7 +1121,6 @@ SWITCH_STANDARD_APP(limit_hash_execute_function)
char *app_arg = NULL;
int max = -1;
int interval = 0;
char *szinterval = NULL;
/* Parse application data */
if (!switch_strlen_zero(data)) {
@ -1129,7 +1128,7 @@ SWITCH_STANDARD_APP(limit_hash_execute_function)
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc < 2) {
if (argc < 5) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "USAGE: limit_hash_execute %s\n", LIMITHASHEXECUTE_USAGE);
return;
}
@ -1137,22 +1136,25 @@ SWITCH_STANDARD_APP(limit_hash_execute_function)
realm = argv[0];
id = argv[1];
/* If max is omitted, only act as a counter and skip maximum checks */
if (argc > 2) {
/* Accept '-' as unlimited (act as counter)*/
if (argv[2][0] == '-') {
max = -1;
} else {
char *szinterval = NULL;
if ((szinterval = strchr(argv[2], '/')))
{
*szinterval++ = '\0';
interval = atoi(szinterval);
}
max = atoi(argv[2]);
if (max < 0) {
max = 0;
}
}
}
app = argv[3];
app_arg = argv[4];