[Mesa-dev] [PATCH 1/5] util/disk_cache: seed rand

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Wed Mar 15 18:47:46 UTC 2017


I thought rand() was not thread safe anyway, and hence we can't use it
in mesa as we don't know what application threads call it too?

On Tue, Mar 14, 2017 at 3:08 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> Otherwise we will always remove old cache entries from the same dirs.
> ---
>  src/util/disk_cache.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index 2a1024a..dc65d52 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -402,20 +402,22 @@ disk_cache_create(const char *gpu_name, const char *timestamp)
>     cache->max_size = max_size;
>
>     /* A limit of 32 jobs was choosen as observations of Deus Ex start-up times
>      * showed that we reached at most 11 jobs on an Intel i5-6400 CPU at 2.70GHz
>      * (a fairly modist desktop CPU). 1 thread was choosen because we don't
>      * really care about getting things to disk quickly just that it's not
>      * blocking other tasks.
>      */
>     util_queue_init(&cache->cache_queue, "disk_cache", 32, 1);
>
> +   srand(time(NULL));
> +
>     ralloc_free(local);
>
>     return cache;
>
>   fail:
>     if (fd != -1)
>        close(fd);
>     if (cache)
>        ralloc_free(cache);
>     ralloc_free(local);
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list