[Users] lcr SQL query in load_gws

Nicolas Olivier nolivier at alphalink.fr
Fri Apr 7 17:14:44 CEST 2006


Hi,

I recently setup routing on my gateways with the lcr module.
I encounter a small problem, quoting from the README: "Matching gateways are then ordered for forwarding purpose (1) according to longest user part 
match, (2) according to gateway's priority, and (3) randomly."
But in fact, and according to the code, the ordering is done firstly on the smallest user part match.

Here is a patch, if what I'm say is correct:

--- openser-1.0.1-tls/modules/lcr/lcr_mod.c     2005-10-28 12:30:13.000000000 +0200
+++ openser-1.0.1-tls-new/modules/lcr/lcr_mod.c 2006-04-07 14:41:35.000000000 +0200
@@ -715,7 +715,7 @@
         from_uri = get_from(_m)->uri;
      }

-    q_len = snprintf(query, MAX_QUERY_SIZE, "SELECT %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s FROM %.*s, %.*s WHERE '%.*s' LIKE %.*s.%.*s 
AND '%.*s' LIKE CONCAT(%.*s.%.*s, '%%') AND %.*s.%.*s = %.*s.%.*s ORDER BY CHAR_LENGTH(%.*s.%.*s), %.*s.%.*s DESC, RAND()",
+    q_len = snprintf(query, MAX_QUERY_SIZE, "SELECT %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s, %.*s.%.*s FROM %.*s, %.*s WHERE '%.*s' LIKE %.*s.%.*s 
AND '%.*s' LIKE CONCAT(%.*s.%.*s, '%%') AND %.*s.%.*s = %.*s.%.*s ORDER BY CHAR_LENGTH(%.*s.%.*s) DESC, %.*s.%.*s DESC, RAND()",
                      gw_table.len, gw_table.s, ip_addr_col.len, ip_addr_col.s,
                      gw_table.len, gw_table.s, port_col.len, port_col.s,
                      gw_table.len, gw_table.s, uri_scheme_col.len, uri_scheme_col.s,


Regards,
Nicolas




More information about the Users mailing list