threading: fix race conditions in CLOS cache

Writes in the cache were not protected against interrupts, leading
    to segfaults when clear_list_from_cache or ecl_search_cache were
    interrupted.
This commit is contained in:
Marius Gerbershagen 2018-02-14 20:41:58 +01:00
parent 3c7085798d
commit e7838e4b86

View file

@ -56,6 +56,7 @@ clear_one_from_cache(ecl_cache_ptr cache, cl_object target)
static void
clear_list_from_cache(ecl_cache_ptr cache)
{
ecl_disable_interrupts();
cl_object list = ecl_atomic_get(&cache->clear_list);
cl_object table = cache->table;
cl_index i, total_size = table->vector.dim;
@ -68,6 +69,7 @@ clear_list_from_cache(ecl_cache_ptr cache)
}
}
}
ecl_enable_interrupts();
}
#endif
@ -137,6 +139,7 @@ ecl_search_cache(ecl_cache_ptr cache)
}
#endif
{
ecl_disable_interrupts();
cl_object table = cache->table;
cl_object keys = cache->keys;
cl_index argno = keys->vector.fillp;
@ -213,6 +216,7 @@ ecl_search_cache(ecl_cache_ptr cache)
RECORD_GEN_SET(e, g);
}
}
ecl_enable_interrupts();
return (ecl_cache_record_ptr)min_e;
}
}