On 06.01.15 12:15, Steve Hill wrote:
Alternatively, A->absorb(B) could be altered to remove any notes from A that have the same keys as B's notes, before using appendNewOnly() to merge them?
I've implemented this for now in the attached patch and am currently testing it. Initial results suggest it resolves the problem.
It introduces a new method, NotePairs::appendAndReplace(), which iterates through the source NotePairs and removes any NotePairs in the destination that have the same key, then calls append().
This is not the most efficient way of erasing the notes, because Squid's Vector template doesn't appear to have an erase() method.
-- - Steve Hill Technical Director Opendium Limited http://www.opendium.com Direct contacts: Instant messager: xmpp:steve@xxxxxxxxxxxx Email: steve@xxxxxxxxxxxx Phone: sip:steve@xxxxxxxxxxxx Sales / enquiries contacts: Email: sales@xxxxxxxxxxxx Phone: +44-1792-824568 / sip:sales@xxxxxxxxxxxx Support contacts: Email: support@xxxxxxxxxxxx Phone: +44-1792-825748 / sip:support@xxxxxxxxxxxx
Index: source/src/Notes.cc =================================================================== --- source/src/Notes.cc (revision 354) +++ source/src/Notes.cc (working copy) @@ -221,6 +221,22 @@ } void +NotePairs::appendAndReplace(const NotePairs *src) +{ + for (Vector<NotePairs::Entry *>::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { + Vector<NotePairs::Entry *>::iterator j = entries.begin(); + while (j != entries.end()) { + if ((*j)->name.cmp((*i)->name.termedBuf()) == 0) { + entries.prune(*j); + j = entries.begin(); + } else + ++j; + } + } + append(src); +} + +void NotePairs::appendNewOnly(const NotePairs *src) { for (Vector<NotePairs::Entry *>::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { Index: source/src/Notes.h =================================================================== --- source/src/Notes.h (revision 354) +++ source/src/Notes.h (working copy) @@ -131,6 +131,12 @@ void append(const NotePairs *src); /** + * Append the entries of the src NotePairs list to our list, replacing any + * entries in the destination set that have the same keys. + */ + void appendAndReplace(const NotePairs *src); + + /** * Append any new entries of the src NotePairs list to our list. * Entries which already exist in the destination set are ignored. */ Index: source/src/auth/User.cc =================================================================== --- source/src/auth/User.cc (revision 354) +++ source/src/auth/User.cc (working copy) @@ -101,7 +101,7 @@ debugs(29, 5, HERE << "auth_user '" << from << "' into auth_user '" << this << "'."); // combine the helper response annotations. Ensuring no duplicates are copied. - notes.appendNewOnly(&from->notes); + notes.appendAndReplace(&from->notes); /* absorb the list of IP address sources (for max_user_ip controls) */ AuthUserIP *new_ipdata;
_______________________________________________ squid-users mailing list squid-users@xxxxxxxxxxxxxxxxxxxxx http://lists.squid-cache.org/listinfo/squid-users