Revision
14920
Author
rupa
Date
2009-09-18 15:01:30 -0500 (Fri, 18 Sep 2009)

Log Message

make limit work with neg count like limit_hash

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (14919 => 14920)


--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	2009-09-18 15:55:10 UTC (rev 14919)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	2009-09-18 20:01:30 UTC (rev 14920)
@@ -63,9 +63,8 @@
 
 typedef struct {
 	switch_hash_t *hash;
-	} limit_hash_private_t;
+} limit_hash_private_t;
 
- 
 static char limit_sql[] =
 	"CREATE TABLE limit_data (\n"
 	"   hostname   VARCHAR(255),\n"
@@ -1172,20 +1171,24 @@
 	realm = argv[0];
 	id = argv[1];
 	
-	/* If max is omitted, only act as a counter and skip maximum checks */
+	/* If max is omitted or negative, only act as a counter and skip maximum checks */
 	if (argc > 2) {
-		char *szinterval = NULL;
-		if ((szinterval = strchr(argv[2], '/')))
-		{
-			*szinterval++ = '\0';
-			interval = atoi(szinterval);
+		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;
+			}
 		}
-		
-		max = atoi(argv[2]);
-		
-		if (max < 0) {
-			max = 0;
-		}
 	}
 
 	if (argc > 3) {