Hallvard B Furuseth wrote:
With so much common code I'd make this and pool_pause() wrappers around handle_pause(tpool, always_pause), returning !always_pause if it paused.
I thought of that at first, but the mutex conditions aren't the same and I didn't feel like adding a lock parameter to distinguish the two.
Needs clarification in this comment, at least: "/* See if a pause was requested; wait for it if so." What if more than one thread is waiting to pause? pool_pausecheck() lets through at least one, but not necessarily all. Sufficient for forward progress? Also a thread may request a pause just as pool_pausecheck() returns.
Yes. One at a time is sufficient for forward progress, as long as the pausecheck caller eventually comes back and checks again.
Note that this function should not normally be used. Most threads should just call pool_pausing() and exit if true. That's what result.c already does, and that's what the syncrepl consumer now does as well. (Mainly because it's possible for a config operation to delete the definitions pertaining to the active operation, so the only safe thing to do is to stop.)
Right now the only caller is in syncprov, and for the moment that call is safe (because there aren't any syncprov config keywords that could invalidate its execution context - all that's configurable is the sessionlog size and the contextCSN checkpoint frequency).