[squid-dev] [PATCH] Fast SNI peek
Alex Rousskov
rousskov at measurement-factory.com
Tue May 17 17:28:40 UTC 2016
On 05/17/2016 08:39 AM, Amos Jeffries wrote:
> To answer Christos' question;
> For iostreams to print the pointer value in hex like seems to be wanted
> here one has to make sure the pointer is a void* and not a type that can
> be dereferenced. Otherwise the streams will try to display its contents
> which would either break, or "work" with unexpected values output.
> NP: 'this' pointer always has a known type, not void*.
To be more precise, std::ostream's shift operator prints void pointers
as hex values. Any pointer can be implicitly cast to void*. However, if
there is an std::ostream shift operator with a matching pointer type
other than void*, that more specific operator is used instead of
implicit casting.
Squid does provide such specific shift operators in a few cases to print
object IDs/state without pointer-dereferencing dangers.
If our intent here is to print the raw pointer, we should cast to void*
explicitly. If our intent is to print a tokenizer ID, and we are sure
that any future shift overload will print a tokenizer ID (and not
tokenizer _state_!), then we should not cast to remain
future-compatible. I think our intent is to print a tokenizer ID, but I
cannot be sure about future shift overloads.
Needless to say, the existing code is inconsistent:
$ bzr grep '<< this' | wc -l
169
$ bzr grep '<<.*void.*this' | wc -l
31
Casting is an easy way to avoid an argument so we should do it.
>>> * you dont need to put /* Ssl:Bio */ or /* ServerBio */ markers between
>>> definitions at the file global level.
>> Somebody added draconian "no double empty lines" rules to source
>> formatting scripts and those markers are the only thing that clearly
>> separates different class methods in .cc file now. FWIW, they _are_
>> useful to some of us browsing the code.
> So one browsing the file does not pay attention to the "ServerBio::" or
> "Ssl::Bio::" scope paths in every single method name?
Scope paths in methods do not stand out visually because all methods
have scope paths. Without additional visual clues, detecting the
boundary between classes takes extra time/effort. The lack of clearly
marked sections may also encourage folks to mix methods from different
classes.
Needless to say, those markers have negative side effects as well. I do
not insist on keeping these markers. @Christos, your call.
Alex.
More information about the squid-dev
mailing list