Pool activation is preceeded by taking a "lock" of pool_mark_busy which guarantees the number of running slaves drops to zero atomicly with the number of pool workers. This resolves race between the function caller thread and one that may be attempting to deactivate the pool. */
| 1974 | that may be attempting to deactivate the pool. |
| 1975 | */ |
| 1976 | int |
| 1977 | rpl_parallel_activate_pool(rpl_parallel_thread_pool *pool) |
| 1978 | { |
| 1979 | int rc= 0; |
| 1980 | struct pool_bkp_for_pfs* bkp= &pool->pfs_bkp; |
| 1981 | |
| 1982 | if ((rc= pool_mark_busy(pool, current_thd))) |
| 1983 | return rc; // killed |
| 1984 | |
| 1985 | if (!pool->count) |
| 1986 | { |
| 1987 | pool_mark_not_busy(pool); |
| 1988 | rc= rpl_parallel_change_thread_count(pool, opt_slave_parallel_threads, |
| 1989 | 0); |
| 1990 | if (!rc) |
| 1991 | { |
| 1992 | if (pool->count) |
| 1993 | { |
| 1994 | if (bkp->inited) |
| 1995 | { |
| 1996 | if (bkp->count != pool->count) |
| 1997 | { |
| 1998 | bkp->destroy(); |
| 1999 | bkp->init(pool->count); |
| 2000 | } |
| 2001 | } |
| 2002 | else |
| 2003 | bkp->init(pool->count); |
| 2004 | bkp->is_valid= false; // Mark backup as stale during pool init |
| 2005 | } |
| 2006 | } |
| 2007 | |
| 2008 | } |
| 2009 | else |
| 2010 | { |
| 2011 | pool_mark_not_busy(pool); |
| 2012 | } |
| 2013 | return rc; |
| 2014 | } |
| 2015 | |
| 2016 | |
| 2017 | int |
no test coverage detected