Commit f7184777 authored by Marko Mäkelä's avatar Marko Mäkelä

os_aio_validate_skip(): Fix a data race

parent 2a0b6de4
...@@ -1090,21 +1090,14 @@ os_aio_validate_skip() ...@@ -1090,21 +1090,14 @@ os_aio_validate_skip()
/** Try os_aio_validate() every this many times */ /** Try os_aio_validate() every this many times */
# define OS_AIO_VALIDATE_SKIP 13 # define OS_AIO_VALIDATE_SKIP 13
/** The os_aio_validate() call skip counter. static int os_aio_validate_count;
Use a signed type because of the race condition below. */
static int os_aio_validate_count = OS_AIO_VALIDATE_SKIP;
/* There is a race condition below, but it does not matter, if (my_atomic_add32_explicit(&os_aio_validate_count, -1,
because this call is only for heuristic purposes. We want to MY_MEMORY_ORDER_RELAXED)
reduce the call frequency of the costly os_aio_validate() % OS_AIO_VALIDATE_SKIP) {
check in debug builds. */ return true;
--os_aio_validate_count;
if (os_aio_validate_count > 0) {
return(true);
} }
os_aio_validate_count = OS_AIO_VALIDATE_SKIP;
return(os_aio_validate()); return(os_aio_validate());
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment