Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stored: fix jcr->authenticate data race
The condition variable is not used correctly: // reader 1| while (!unprotected) { 2| wait(cond_var) } // writer 3| unprotected = true; 4| signal(cond_var) The execution order 1->3->4->2 will cause a deadlock. This is why the wait command takes a mutex: Everything that might change the condition to be true needs to lock the mutex, this way we can ensure that we either see the updated value or the wait sees the signal. Since jcr->authenticate is used all over the place in a lot of different situations, this problem could not be easily fixed by just protecting that variable (we do not want weird deadlocks to happen after all). We just do not rely on jcr->authenticate anymore when it comes to waiting on job start. Instead we have a single, properly protected bool `client_available` that we can wait on. This bool obviously needs to be set by whoever authenticates the FD/SD connection, otherwise the job will deadlock. But at least that is easily fixable.
- Loading branch information
Showing
7 changed files
with
59 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters