# # # patch "server_manager.cc" # from [82f70dbe4c46d8b372d5e499b32f479904000a6a] # to [b942b53baa1e7a3261c3e02903434cce3d47b82d] # ============================================================ --- server_manager.cc 82f70dbe4c46d8b372d5e499b32f479904000a6a +++ server_manager.cc b942b53baa1e7a3261c3e02903434cce3d47b82d @@ -10,6 +10,7 @@ #include #include +//#include serversock::serversock(sock const &o) : sock(o) @@ -38,13 +39,19 @@ { unsigned int size = min(str.size(), r.str.size()); int c = strncmp(str.c_str(), r.str.c_str(), size); - int longer = str.size() - r.str.size(); + int longer = str.size() - r.str.size();// positive is *this is longer than r + int res = c; if (ok_shorter == r.ok_shorter) - return (c==0)?longer:c; + res = (c==0)?longer:c; else if (ok_shorter) - return (c==0)?max(longer,0):c; + res = (c==0)?max(longer,0):c; else // (r.ok_shorter) - return (c==0)?min(longer,0):c; + res = (c==0)?min(longer,0):c; +// fprintf(stderr, "cmp(<%s,%s>, <%s,%s>) = %i\n", +// str.c_str(), ok_shorter?"true":"false", +// r.str.c_str(), r.ok_shorter?"true":"false", +// res); + return res; } bool server_manager::prefix::operator<(prefix const &r) const { @@ -175,14 +182,14 @@ map >::iterator i; if (!host.empty() && !by_host.empty()) { - i = by_host.lower_bound(host); - if (i != by_host.end() && i->first == prefix(host)) + i = by_host.lower_bound(prefix(host, false)); + if (i != by_host.end()) srv = i->second; } if (!srv && !pattern.empty() && !by_pattern.empty()) { - i = by_pattern.lower_bound(pattern); - if (i != by_pattern.end() && i->first == prefix(host)) + i = by_pattern.lower_bound(prefix(pattern, false)); + if (i != by_pattern.end()) srv = i->second; } if (srv)