]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
make limit work with neg count like limit_hash
authorRupa Schomaker <rupa@rupa.com>
Fri, 18 Sep 2009 20:01:30 +0000 (20:01 +0000)
committerRupa Schomaker <rupa@rupa.com>
Fri, 18 Sep 2009 20:01:30 +0000 (20:01 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14920 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_limit/mod_limit.c

index 6c5ce869aecb688101194879049b1c2767f3d92e..68da1c0a7ee7da988d439ccfede6f5174db8a806 100644 (file)
@@ -63,9 +63,8 @@ typedef struct  {
 
 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,19 +1171,23 @@ SWITCH_STANDARD_APP(limit_hash_function)
        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);
-               }
-               
-               max = atoi(argv[2]);
-               
-               if (max < 0) {
-                       max = 0;
+               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;
+                       }
                }
        }