Received: (qmail 64688 invoked by uid 501); 9 May 2001 10:47:54 -0000 Message-Id: <20010509104754.64667.qmail@apache.org> Date: 9 May 2001 10:47:54 -0000 From: Giuseppe D'Ambrosio Reply-To: boltthrower@libero.it To: submit@bugz.apache.org Subject: map type rnd: doesn't give a random result X-Send-Pr-Version: 3.110 >Number: 7689 >Category: mod_rewrite >Synopsis: map type rnd: doesn't give a random result >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Wed May 09 03:50:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: boltthrower@libero.it >Release: 1.3.12 >Organization: apache >Environment: windows NT 4.0 serv.pack 4 compiled with MSVC 6 or binaries from the official distribution >Description: my problem was: setting a local proxy to joke a friend so that he couldn't get - *randomly* - a page; I've worked with mod_rewrite in this way (shortened and out of peculiarities): snippet from httpd.config ---- RewriteEngine on RewriteLog logs/rewrite.log RewriteLogLevel 5 RewriteMap map1 rnd:conf/map1.txt RewriteCond ${map1:random10} ^1$ RewriteRule (testcond$) ??x1 ---- the map map1.txt is ---- random10 1|2|3|4|5|6|7|8|9|10 ---- but in this way I always get the first case ("1" or whatever I put as first case) note: 1)I also submitted this on the new-httpd list some weeks ago but got no answer; 2)the httpd compiled from the 2.0.14a tree *crashes* with this config. (I think in do_expand) >How-To-Repeat: you can test repeatedly on a local URL such as http://127.0.0.1/testcond and check the rewrite.log file since this is probabilistic you can also modify the map1.txt adding a large number of possibilities; I've tryed more than 50 times with 100 cases (choices) and got ever the first (that's enough..) >Fix: I've got it to work only replacing the call to rand() with a locally-implemented function mt_rand() (eg. from http://www.math.keio.ac.jp/matumoto/) or, at first with something like sin(time()) as raw random generator >Release-Note: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]