mheily / libkqueue

kqueue(2) compatibility library
Other
236 stars 77 forks source link

Use a rwlock instead of atomics in map.c #107

Closed mheily closed 3 years ago

mheily commented 3 years ago

I don't see a good reason to use atomic operations in map.c.

Let's use a rwlock instead.

mheily commented 3 years ago

This pertains to #103 but does not fix the problem.

Also some unused functions in map.c were removed.

arr2036 commented 3 years ago

Using mutexes like this would significantly increase contention on the map array. I'd like to understand why tsan is throwing errors first. They may be false positives.

arr2036 commented 3 years ago

Switching to C11 atomics, fixing map_delete to use atomic_exchange, and using atomic_load when accessing atomic variables silences TSAN's complaints. https://github.com/mheily/libkqueue/commit/f3eab262fcf961cfd465c0f52fa6896a4782aca2

There's still an issue with mutex use after destruction that we need to look at.