ice icon indicating copy to clipboard operation
ice copied to clipboard

Don't use a mutex for computing Reference hash

Open pepone opened this issue 1 year ago • 1 comments

I don't think we should use any mutex in this code.

Either the hash is very cheap to compute and we compute it each time. Or it's somewhat expensive to compute (== bad hash) and we compute it in the constructor. As far as I can tell, this class is immutable.

Originally posted by @bernardnormier in https://github.com/zeroc-ice/ice/pull/1707#pullrequestreview-1836571809

pepone avatar Jan 22 '24 14:01 pepone

Fixed by #2120 in C#. Fixed by #2123 in C++.

bernardnormier avatar May 28 '24 23:05 bernardnormier

Fixed by #2437 in Java. And Javascript has no mutex locking.

InsertCreativityHere avatar Jul 10 '24 22:07 InsertCreativityHere

ice % rg hashInit
js/src/Ice/Reference.js
45:        this._hashInitialized = false;
265:        if (this._hashInitialized) {
285:        this._hashInitialized = true;
990:        if (!this._hashInitialized) {

js/src/Ice/IPEndpointI.js
77:            this._hashCode = this.hashInit(5381);
170:    hashInit(h) {

js/src/Ice/TcpEndpointI.js
185:    hashInit(h) {
186:        h = super.hashInit(h);

Unfortunately, while JS doesn't use a mutex, it uses the undesirable "hash value caching" logic. Still needs to be fixed.

bernardnormier avatar Jul 11 '24 21:07 bernardnormier

JavaScript fixed in #2607

pepone avatar Aug 05 '24 08:08 pepone