jinganix / enif_protobuf

A Google Protobuf implementation with enif (Erlang nif)
38 stars 21 forks source link

Fix tid not found error #9

Closed bwalkowi closed 5 years ago

bwalkowi commented 5 years ago

Hi,

this pr solves #8. As discussed in issue, I have replaced erlang:system_info(logical_processors) with erlang:system_info(schedulers) and clear locks when tid change. To avoid races it is not enough to just wait for state->cache_lock but also threads waiting for rlock on cache_lock needs to check that locks were not cleared during their waiting hence checking lock->tid.

For testing nif changes I have returned to using erlang:system_info(logical_processors), added checks for return value from encoding()/decoding() and run unit tests with +S32:32 (my cpu has 8 logic cores). Same tests fails on master with {error, tid_not_found}.

I have opened pr to solve eventual reservations about the code but I will yet conduct more tests.

jinganix commented 5 years ago

Great, another key point is checking lock->tid, I never considered this.