Closed stokito closed 1 year ago
I checked and creation of a hasher would create too many allocations. So we should reuse it. Since we can't make the pricer thread safe we need to create a new instance per request. It's not that bad because we can use sync.Pool() but still the pricer has a lot of fields that are simply not needed. I'll send a PR to remove them
I have a global
var pricer *doubleclick.DoubleClickPricer
and many requests are using the same pricer to decrypt a price. And I saw some strange results and today finally saw three panics with the following stack:The auction price string was totally correct and I decoded it successfully when tried locally.
So from what I see the panic is thrown from here
And the
hmac
may bedc.integrityKey
ordc.encryptionKey
fields. But here their value is changing! That's why two concurrent requests may erase each other values. I don't know how to fix this properly. Just for now I added a lock to avoid concurrent execution. But I'm afraid that I have to create a new instance of the pricer each time. Could you please confirm and suggest any possible fix for this? For example we may copy the i_key and e_key before the hmac calculation.