# # patch "ChangeLog" # from [c5b6af776442ffcda8b25b0b94a9785795da0817] # to [9e0ee021f2b1d81700e96ab1f2705ee47ab7723f] # # patch "netsync.cc" # from [5d33f00ec5c8e80c76ace7d2cbeb494c8a99424a] # to [e1239ee221729406ac7a958d4f9f8740f774b127] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,15 @@ +2005-06-15 Richard Levitte + + * netsync.cc (struct session): Add a pattern regex cache. + (analyze_ancestry_graph): Use the regex cache instead of the + pattern string itself. This is especially important when the + pattern is used as an old-style collection. + (process_hello_cmd): Recreate the pattern regex cache with the + conversion of the pattern to a regex when it's used as an + old-style collection. + (process_auth_cmd): When the pattern changes, change the regex + cache as well. + 2005-06-14 Richard Levitte * std_hooks.lua (get_preferred_merge2_command, --- netsync.cc +++ netsync.cc @@ -226,6 +226,7 @@ bool arm(); utf8 pattern; + boost::regex pattern_re; id remote_peer_key_hash; rsa_keypair_id remote_peer_key_name; bool authenticated; @@ -435,6 +436,7 @@ protocol_version(constants::netcmd_current_protocol_version), armed(false), pattern(""), + pattern_re(".*"), remote_peer_key_hash(""), remote_peer_key_name(""), authenticated(false), @@ -458,6 +460,7 @@ N(patterns.size() == 1, F("client can only sync one pattern at a time")); this->pattern = idx(patterns, 0); + this->pattern_re = boost::regex(this->pattern()); } dbw.set_on_revision_written(boost::bind(&session::rev_written_callback, @@ -1113,8 +1116,6 @@ set ok_branches, bad_branches; cert_name bcert_name(branch_cert_name); cert_name tcert_name(tag_cert_name); - //used for permission checking if we're the client - boost::regex reg(pattern()); for (map::iterator i = received_certs.begin(); i != received_certs.end(); ++i) { @@ -1136,7 +1137,7 @@ ok = app.lua.hook_get_netsync_write_permitted(name(), remote_peer_key_name); else - ok = boost::regex_match(name(), reg); + ok = boost::regex_match(name(), pattern_re); if (ok) { ok_branches.insert(name()); @@ -1716,15 +1717,15 @@ W(F("Talking to an old server. " "Using %s as a collection, not a regex.") % pattern); convert_pattern(pattern, pat); + this->pattern_re = boost::regex(pat()); } vector branchnames; set ok_branches; get_branches(app, branchnames); - boost::regex reg(pat()); for (vector::const_iterator i = branchnames.begin(); i != branchnames.end(); i++) { - if (boost::regex_match(*i, reg)) + if (boost::regex_match(*i, pattern_re)) ok_branches.insert(utf8(*i)); } rebuild_merkle_trees(app, ok_branches); @@ -2007,6 +2008,7 @@ decode_base64(sig, sig_raw); queue_confirm_cmd(sig_raw()); this->pattern = pattern; + this->pattern_re = boost::regex(this->pattern()); this->authenticated = true; this->remote_peer_key_name = their_id; // assume the (possibly degraded) opposite role