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:
parent
e2a0d2bc5e
commit
a75c525dcc
|
@ -1059,7 +1059,6 @@ SWITCH_STANDARD_APP(limit_hash_function)
|
||||||
char *xfer_exten = NULL;
|
char *xfer_exten = NULL;
|
||||||
int max = -1;
|
int max = -1;
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
char *szinterval = NULL;
|
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
/* Parse application data */
|
/* 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 max is omitted, only act as a counter and skip maximum checks */
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
|
char *szinterval = NULL;
|
||||||
if ((szinterval = strchr(argv[2], '/')))
|
if ((szinterval = strchr(argv[2], '/')))
|
||||||
{
|
{
|
||||||
*szinterval++ = '\0';
|
*szinterval++ = '\0';
|
||||||
|
@ -1121,7 +1121,6 @@ SWITCH_STANDARD_APP(limit_hash_execute_function)
|
||||||
char *app_arg = NULL;
|
char *app_arg = NULL;
|
||||||
int max = -1;
|
int max = -1;
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
char *szinterval = NULL;
|
|
||||||
|
|
||||||
/* Parse application data */
|
/* Parse application data */
|
||||||
if (!switch_strlen_zero(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])));
|
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);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "USAGE: limit_hash_execute %s\n", LIMITHASHEXECUTE_USAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1137,22 +1136,25 @@ SWITCH_STANDARD_APP(limit_hash_execute_function)
|
||||||
realm = argv[0];
|
realm = argv[0];
|
||||||
id = argv[1];
|
id = argv[1];
|
||||||
|
|
||||||
/* If max is omitted, only act as a counter and skip maximum checks */
|
/* Accept '-' as unlimited (act as counter)*/
|
||||||
if (argc > 2) {
|
if (argv[2][0] == '-') {
|
||||||
|
max = -1;
|
||||||
|
} else {
|
||||||
|
char *szinterval = NULL;
|
||||||
|
|
||||||
if ((szinterval = strchr(argv[2], '/')))
|
if ((szinterval = strchr(argv[2], '/')))
|
||||||
{
|
{
|
||||||
*szinterval++ = '\0';
|
*szinterval++ = '\0';
|
||||||
interval = atoi(szinterval);
|
interval = atoi(szinterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
max = atoi(argv[2]);
|
max = atoi(argv[2]);
|
||||||
|
|
||||||
if (max < 0) {
|
if (max < 0) {
|
||||||
max = 0;
|
max = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app = argv[3];
|
app = argv[3];
|
||||||
app_arg = argv[4];
|
app_arg = argv[4];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue